Skip to content

Commit 1d4a737

Browse files
authored
fix(database): track amount in deregistration certificate (#1004)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent a13a453 commit 1d4a737

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

database/models/account.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type Deregistration struct {
6161
ID uint `gorm:"primarykey"`
6262
CertificateID uint `gorm:"index"`
6363
AddedSlot uint64
64+
Amount int64
6465
}
6566

6667
func (Deregistration) TableName() string {

database/plugin/metadata/sqlite/account.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package sqlite
1616

1717
import (
1818
"errors"
19+
"fmt"
1920

2021
"github.com/blinklabs-io/dingo/database/models"
2122
lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
@@ -80,7 +81,7 @@ func (d *MetadataStoreSqlite) SetDeregistration(
8081
stakeKey := cert.StakeCredential.Credential.Bytes()
8182
tmpAccount, err := d.GetAccount(stakeKey, txn)
8283
if err != nil {
83-
return err
84+
return fmt.Errorf("failed getting account: %w", err)
8485
}
8586
if tmpAccount == nil {
8687
// Account not found, nothing to deregister
@@ -89,6 +90,7 @@ func (d *MetadataStoreSqlite) SetDeregistration(
8990
tmpItem := models.Deregistration{
9091
StakingKey: stakeKey,
9192
AddedSlot: slot,
93+
Amount: cert.Amount,
9294
}
9395
tmpAccount.Active = false
9496
if txn != nil {

0 commit comments

Comments
 (0)