Skip to content

Commit

Permalink
Fix storage prefix mixup and MockedTransaction serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jonastheis committed Apr 5, 2022
1 parent 43f6905 commit e8cdd6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
5 changes: 4 additions & 1 deletion packages/database/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ const (
// PrefixMarkers defines the storage prefix for the markers used to optimize structural checks in the tangle.
PrefixMarkers

// PrefixLedger defines the storage prefix for the ledgerstate package.
// PrefixLedger defines the storage prefix for the ledger package.
PrefixLedger

// PrefixBranchDAG defines the storage prefix for the branchDAG package.
PrefixBranchDAG

// PrefixMana defines the storage prefix for the mana package.
PrefixMana

Expand Down
8 changes: 4 additions & 4 deletions packages/ledger/branchdag/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ type Storage struct {
func newStorage(branchDAG *BranchDAG) (new *Storage) {
new = &Storage{
branchStorage: objectstorage.New[*Branch](
branchDAG.options.store.WithRealm([]byte{database.PrefixLedger, PrefixBranchStorage}),
branchDAG.options.store.WithRealm([]byte{database.PrefixBranchDAG, PrefixBranchStorage}),
branchDAG.options.cacheTimeProvider.CacheTime(branchCacheTime),
objectstorage.LeakDetectionEnabled(false),
),
childBranchStorage: objectstorage.New[*ChildBranch](
branchDAG.options.store.WithRealm([]byte{database.PrefixLedger, PrefixChildBranchStorage}),
branchDAG.options.store.WithRealm([]byte{database.PrefixBranchDAG, PrefixChildBranchStorage}),
ChildBranchKeyPartition,
branchDAG.options.cacheTimeProvider.CacheTime(branchCacheTime),
objectstorage.LeakDetectionEnabled(false),
objectstorage.StoreOnCreation(true),
),
conflictStorage: objectstorage.New[*Conflict](
branchDAG.options.store.WithRealm([]byte{database.PrefixLedger, PrefixConflictStorage}),
branchDAG.options.store.WithRealm([]byte{database.PrefixBranchDAG, PrefixConflictStorage}),
branchDAG.options.cacheTimeProvider.CacheTime(consumerCacheTime),
objectstorage.LeakDetectionEnabled(false),
),
conflictMemberStorage: objectstorage.New[*ConflictMember](
branchDAG.options.store.WithRealm([]byte{database.PrefixLedger, PrefixConflictMemberStorage}),
branchDAG.options.store.WithRealm([]byte{database.PrefixBranchDAG, PrefixConflictMemberStorage}),
ConflictMemberKeyPartition,
branchDAG.options.cacheTimeProvider.CacheTime(conflictCacheTime),
objectstorage.LeakDetectionEnabled(false),
Expand Down
12 changes: 11 additions & 1 deletion packages/ledger/testframework.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,17 @@ func (m *MockedTransaction) Inputs() []utxo.Input {
}

func (m *MockedTransaction) Bytes() []byte {
return nil
marshalUtil := marshalutil.New().
WriteUint16(uint16(len(m.inputs)))

for i := 0; i < len(m.inputs); i++ {
marshalUtil.Write(m.inputs[i])
}

return marshalUtil.
WriteUint16(m.outputCount).
WriteUint64(m.uniqueEssence).
Bytes()
}

func (m *MockedTransaction) String() (humanReadable string) {
Expand Down

0 comments on commit e8cdd6b

Please sign in to comment.