File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
2020 "slices"
2121
2222 "github.com/blinklabs-io/dingo/database/models"
23+ "github.com/blinklabs-io/gouroboros/cbor"
2324 "github.com/blinklabs-io/gouroboros/ledger"
2425 "github.com/dgraph-io/badger/v4"
2526)
@@ -56,7 +57,16 @@ func (d *Database) AddUtxos(
5657 utxoSlot .Utxo .Id .Id ().Bytes (),
5758 utxoSlot .Utxo .Id .Index (),
5859 )
59- err := txn .Blob ().Set (key , utxoSlot .Utxo .Output .Cbor ())
60+ utxoCbor := utxoSlot .Utxo .Output .Cbor ()
61+ // Encode output to CBOR if stored CBOR is empty
62+ if len (utxoCbor ) == 0 {
63+ var err error
64+ utxoCbor , err = cbor .Encode (utxoSlot .Utxo .Output )
65+ if err != nil {
66+ return err
67+ }
68+ }
69+ err := txn .Blob ().Set (key , utxoCbor )
6070 if err != nil {
6171 return err
6272 }
You can’t perform that action at this time.
0 commit comments