Skip to content

Commit 3acf5a1

Browse files
jkawanJenita
andauthored
feat : Added changes to add amount to Utxo table to track coin amount (#854)
* feat: add amount to Utxo table to track amount Signed-off-by: Jenita <[email protected]> * feat: add amount to Utxo table to track amount Signed-off-by: Jenita <[email protected]> * feat: add amount to Utxo table to track amount Signed-off-by: Jenita <[email protected]> --------- Signed-off-by: Jenita <[email protected]> Co-authored-by: Jenita <[email protected]>
1 parent 5ca93ea commit 3acf5a1

File tree

6 files changed

+8
-0
lines changed

6 files changed

+8
-0
lines changed

database/plugin/metadata/sqlite/models/utxo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type Utxo struct {
2222
DeletedSlot uint64 `gorm:"index"`
2323
PaymentKey []byte `gorm:"index"`
2424
StakingKey []byte `gorm:"index"`
25+
Amount uint64 `gorm:"index"`
2526
Cbor []byte `gorm:"-"` // This is here for convenience but not represented in the metadata DB
2627
}
2728

database/plugin/metadata/sqlite/utxo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ func (d *MetadataStoreSqlite) SetUtxo(
202202
slot uint64, // slot
203203
payment []byte, // payment
204204
stake []byte, // stake
205+
amount uint64, // amount
205206
txn *gorm.DB,
206207
) error {
207208
tmpUtxo := models.Utxo{

database/plugin/metadata/store.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ type MetadataStore interface {
203203
uint64, // slot
204204
[]byte, // payment
205205
[]byte, // stake
206+
uint64, // amount
206207
*gorm.DB,
207208
) error
208209
SetVoteDelegation(

database/utxo.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type Utxo struct {
3232
DeletedSlot uint64 `gorm:"index"`
3333
PaymentKey []byte `gorm:"index"`
3434
StakingKey []byte `gorm:"index"`
35+
Amount uint64 `gorm:"index"`
3536
Cbor []byte `gorm:"-"` // This is not represented in the metadata DB
3637
}
3738

@@ -64,6 +65,7 @@ func (d *Database) NewUtxo(
6465
outputIdx uint32,
6566
slot uint64,
6667
paymentKey, stakeKey, cbor []byte,
68+
amt uint64,
6769
txn *Txn,
6870
) error {
6971
if txn == nil {
@@ -82,6 +84,7 @@ func (d *Database) NewUtxo(
8284
slot,
8385
paymentKey,
8486
stakeKey,
87+
amt,
8588
txn.Metadata(),
8689
)
8790
}

ledger/chainsync.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ func (ls *LedgerState) createGenesisBlock() error {
241241
outAddr.PaymentKeyHash().Bytes(),
242242
outAddr.StakeKeyHash().Bytes(),
243243
outputCbor,
244+
utxo.Output.Amount(),
244245
txn,
245246
)
246247
if err != nil {

ledger/delta.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func (d *LedgerDelta) apply(ls *LedgerState, txn *database.Txn) error {
7171
outAddr.PaymentKeyHash().Bytes(),
7272
outAddr.StakeKeyHash().Bytes(),
7373
produced.Output.Cbor(),
74+
produced.Output.Amount(),
7475
txn,
7576
)
7677
if err != nil {

0 commit comments

Comments
 (0)