diff --git a/dapps/valuetransfers/packages/branchmanager/branchmanager.go b/dapps/valuetransfers/packages/branchmanager/branchmanager.go index 981eb0827735abbcb667c7a595fd27129b37677f..ff50636f00bd38cdb5b7e05ac549e430e7e0e567 100644 --- a/dapps/valuetransfers/packages/branchmanager/branchmanager.go +++ b/dapps/valuetransfers/packages/branchmanager/branchmanager.go @@ -5,13 +5,12 @@ import ( "fmt" "sort" + "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/hive.go/kvstore" "github.com/iotaledger/hive.go/marshalutil" "github.com/iotaledger/hive.go/objectstorage" "github.com/iotaledger/hive.go/types" "golang.org/x/crypto/blake2b" - - "github.com/iotaledger/goshimmer/packages/storageprefix" ) // BranchManager is an entity that manages the branches of a UTXODAG. It offers methods to add, delete and modify @@ -40,7 +39,7 @@ type BranchManager struct { // New is the constructor of the BranchManager. func New(store kvstore.KVStore) (branchManager *BranchManager) { - osFactory := objectstorage.NewFactory(store, storageprefix.ValueTransfers) + osFactory := objectstorage.NewFactory(store, database.PrefixValueTransfers) branchManager = &BranchManager{ branchStorage: osFactory.New(osBranch, BranchFromObjectStorage, osBranchOptions...), diff --git a/dapps/valuetransfers/packages/tangle/tangle.go b/dapps/valuetransfers/packages/tangle/tangle.go index e093463ec4fe299126a8142e59d72ba0f7d0be83..b36da574659b21a8e2162cd50caeeb175b6565af 100644 --- a/dapps/valuetransfers/packages/tangle/tangle.go +++ b/dapps/valuetransfers/packages/tangle/tangle.go @@ -6,6 +6,7 @@ import ( "fmt" "math" + "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/hive.go/async" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/kvstore" @@ -18,7 +19,6 @@ import ( "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/branchmanager" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/payload" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" - "github.com/iotaledger/goshimmer/packages/storageprefix" ) // Tangle represents the value tangle that consists out of value payloads. @@ -43,7 +43,7 @@ type Tangle struct { // New is the constructor of a Tangle and creates a new Tangle object from the given details. func New(store kvstore.KVStore) (tangle *Tangle) { - osFactory := objectstorage.NewFactory(store, storageprefix.ValueTransfers) + osFactory := objectstorage.NewFactory(store, database.PrefixValueTransfers) tangle = &Tangle{ branchManager: branchmanager.New(store), diff --git a/packages/database/prefix.go b/packages/database/prefix.go new file mode 100644 index 0000000000000000000000000000000000000000..bb135db30fca48753339eb85cdd91f774241b7be --- /dev/null +++ b/packages/database/prefix.go @@ -0,0 +1,12 @@ +package database + +const ( + // PrefixAutoPeering defines the prefix of the autopeering db. + PrefixAutoPeering byte = iota + // PrefixHealth defines the prefix of the health db. + PrefixHealth + // PrefixMessageLayer defines the storage prefix for the message layer. + PrefixMessageLayer + // PrefixValueTransfers defines the storage prefix for value transfer. + PrefixValueTransfers +) diff --git a/packages/database/prefix/prefix.go b/packages/database/prefix/prefix.go deleted file mode 100644 index 955428b65e49e5190e2f101224c79df889ff41e2..0000000000000000000000000000000000000000 --- a/packages/database/prefix/prefix.go +++ /dev/null @@ -1,18 +0,0 @@ -package prefix - -const ( - // DBPrefixApprovers defines the prefix of the approvers db - DBPrefixApprovers byte = iota - // DBPrefixTransaction defines the prefix of the transaction db - DBPrefixTransaction - // DBPrefixBundle defines the prefix of the bundles db - DBPrefixBundle - // DBPrefixTransactionMetadata defines the prefix of the transaction metadata db - DBPrefixTransactionMetadata - // DBPrefixAddressTransactions defines the prefix of the address transactions db - DBPrefixAddressTransactions - // DBPrefixAutoPeering defines the prefix of the autopeering db. - DBPrefixAutoPeering - // DBPrefixHealth defines the prefix of the health db. - DBPrefixHealth -) diff --git a/packages/storageprefix/storageprefix.go b/packages/storageprefix/storageprefix.go deleted file mode 100644 index f6f6fd620353aa15c6f16bfed53589cfcd232b5d..0000000000000000000000000000000000000000 --- a/packages/storageprefix/storageprefix.go +++ /dev/null @@ -1,13 +0,0 @@ -package storageprefix - -const ( - // the following values are a list of prefixes defined as an enum - // package specific prefixes used for the objectstorage in the corresponding packages - - _ byte = iota - - // MessageLayer defines the storage prefix for the message layer - MessageLayer - // ValueTransfers defines the storage prefix for value transfer. - ValueTransfers -) diff --git a/packages/tangle/tangle.go b/packages/tangle/tangle.go index 3ffca644819a9a24decea3c9b6dde6b7bf420f1f..6fd24baf84e41f2aab4d6162b2d89e75b77f94e5 100644 --- a/packages/tangle/tangle.go +++ b/packages/tangle/tangle.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - "github.com/iotaledger/goshimmer/packages/storageprefix" + "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/hive.go/async" "github.com/iotaledger/hive.go/kvstore" "github.com/iotaledger/hive.go/objectstorage" @@ -44,7 +44,7 @@ type Tangle struct { // New creates a new Tangle. func New(store kvstore.KVStore) (result *Tangle) { - osFactory := objectstorage.NewFactory(store, storageprefix.MessageLayer) + osFactory := objectstorage.NewFactory(store, database.PrefixMessageLayer) result = &Tangle{ shutdown: make(chan struct{}), diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go index d3fbdf923cad36b8e5ca204ab56a90f42dd24d94..27da57e5485b98ca9b4e03bdbd1854b429f91204 100644 --- a/plugins/autopeering/local/local.go +++ b/plugins/autopeering/local/local.go @@ -7,7 +7,7 @@ import ( "strings" "sync" - "github.com/iotaledger/goshimmer/packages/database/prefix" + databasePkg "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/goshimmer/plugins/config" "github.com/iotaledger/goshimmer/plugins/database" "github.com/iotaledger/hive.go/autopeering/peer" @@ -70,7 +70,7 @@ func configureLocal() *peer.Local { } seed = append(seed, bytes) } - peerDB, err := peer.NewDB(database.StoreRealm([]byte{prefix.DBPrefixAutoPeering})) + peerDB, err := peer.NewDB(database.StoreRealm([]byte{databasePkg.PrefixAutoPeering})) if err != nil { log.Fatalf("Error creating peer DB: %s", err) } diff --git a/plugins/database/health.go b/plugins/database/health.go index af6a4770c9261245a2535a7f9f25798be046f2df..9432ef79ead78fecdf2870bf06951109b0d220e5 100644 --- a/plugins/database/health.go +++ b/plugins/database/health.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/iotaledger/goshimmer/packages/database/prefix" + "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/hive.go/kvstore" ) @@ -14,7 +14,7 @@ var ( ) func configureHealthStore(store kvstore.KVStore) { - healthStore = store.WithRealm([]byte{prefix.DBPrefixHealth}) + healthStore = store.WithRealm([]byte{database.PrefixHealth}) } // MarkDatabaseUnhealthy marks the database as not healthy, meaning diff --git a/plugins/database/versioning.go b/plugins/database/versioning.go index dc434ef0cc1bb8b3f5375e49dcf1e29e03513d9e..219102affd1944afc465f91f9f439f40a3cd26b6 100644 --- a/plugins/database/versioning.go +++ b/plugins/database/versioning.go @@ -10,7 +10,7 @@ import ( const ( // DBVersion defines the version of the database schema this version of GoShimmer supports. // Every time there's a breaking change regarding the stored data, this version flag should be adjusted. - DBVersion = 8 + DBVersion = 9 ) var (