Skip to content
Snippets Groups Projects
Commit d951039d authored by muXxer's avatar muXxer
Browse files

Removed badger import in packages and plugins

parent b3f3ae19
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@ package accountability
import (
"sync"
"github.com/dgraph-io/badger"
"github.com/iotaledger/goshimmer/packages/database"
"github.com/iotaledger/goshimmer/packages/identity"
"github.com/iotaledger/goshimmer/packages/settings"
)
......@@ -39,7 +39,7 @@ func generateNewIdentity() *identity.Identity {
func getIdentity() *identity.Identity {
publicKey, err := settings.Get([]byte("ACCOUNTABILITY_PUBLIC_KEY"))
if err != nil {
if err == badger.ErrKeyNotFound {
if err == database.ErrKeyNotFound {
return generateNewIdentity()
} else {
panic(err)
......@@ -48,7 +48,7 @@ func getIdentity() *identity.Identity {
privateKey, err := settings.Get([]byte("ACCOUNTABILITY_PRIVATE_KEY"))
if err != nil {
if err == badger.ErrKeyNotFound {
if err == database.ErrKeyNotFound {
return generateNewIdentity()
} else {
panic(err)
......
......@@ -6,8 +6,12 @@ import (
"github.com/dgraph-io/badger"
)
var dbMap = make(map[string]*prefixDb)
var mu sync.Mutex
var (
ErrKeyNotFound = badger.ErrKeyNotFound
dbMap = make(map[string]*prefixDb)
mu sync.Mutex
)
type prefixDb struct {
db *badger.DB
......@@ -52,7 +56,7 @@ func (this *prefixDb) Contains(key []byte) (bool, error) {
return err
})
if err == badger.ErrKeyNotFound {
if err == ErrKeyNotFound {
return false, nil
} else {
return err == nil, err
......
......@@ -3,8 +3,8 @@ package saltmanager
import (
"time"
"github.com/dgraph-io/badger"
"github.com/iotaledger/goshimmer/packages/daemon"
"github.com/iotaledger/goshimmer/packages/database"
"github.com/iotaledger/goshimmer/packages/node"
"github.com/iotaledger/goshimmer/packages/settings"
"github.com/iotaledger/goshimmer/plugins/autopeering/types/salt"
......@@ -33,7 +33,7 @@ func generateNewSalt(key []byte, lifetime time.Duration) *salt.Salt {
func getSalt(key []byte, lifetime time.Duration) *salt.Salt {
saltBytes, err := settings.Get(key)
if err != nil {
if err == badger.ErrKeyNotFound {
if err == database.ErrKeyNotFound {
return generateNewSalt(key, lifetime)
} else {
panic(err)
......
package tangle
import (
"github.com/dgraph-io/badger"
"github.com/iotaledger/iota.go/trinary"
"github.com/iotaledger/goshimmer/packages/database"
"github.com/iotaledger/goshimmer/packages/datastructure"
"github.com/iotaledger/goshimmer/packages/errors"
"github.com/iotaledger/goshimmer/packages/model/approvers"
"github.com/iotaledger/goshimmer/packages/node"
"github.com/iotaledger/goshimmer/packages/typeutils"
"github.com/iotaledger/iota.go/trinary"
)
// region global public api ////////////////////////////////////////////////////////////////////////////////////////////
......@@ -99,7 +99,7 @@ func storeApproversInDatabase(approvers *approvers.Approvers) errors.Identifiabl
func getApproversFromDatabase(transactionHash trinary.Trytes) (*approvers.Approvers, errors.IdentifiableError) {
approversData, err := approversDatabase.Get(typeutils.StringToBytes(transactionHash))
if err != nil {
if err == badger.ErrKeyNotFound {
if err == database.ErrKeyNotFound {
return nil, nil
}
......
package tangle
import (
"github.com/dgraph-io/badger"
"github.com/iotaledger/iota.go/trinary"
"github.com/iotaledger/goshimmer/packages/database"
"github.com/iotaledger/goshimmer/packages/datastructure"
"github.com/iotaledger/goshimmer/packages/errors"
"github.com/iotaledger/goshimmer/packages/model/bundle"
"github.com/iotaledger/goshimmer/packages/node"
"github.com/iotaledger/goshimmer/packages/typeutils"
"github.com/iotaledger/iota.go/trinary"
)
// region global public api ////////////////////////////////////////////////////////////////////////////////////////////
......@@ -103,7 +103,7 @@ func storeBundleInDatabase(bundle *bundle.Bundle) errors.IdentifiableError {
func getBundleFromDatabase(transactionHash trinary.Trytes) (*bundle.Bundle, errors.IdentifiableError) {
bundleData, err := bundleDatabase.Get(typeutils.StringToBytes(transactionHash))
if err != nil {
if err == badger.ErrKeyNotFound {
if err == database.ErrKeyNotFound {
return nil, nil
}
......
package tangle
import (
"github.com/dgraph-io/badger"
"github.com/iotaledger/iota.go/trinary"
"github.com/iotaledger/goshimmer/packages/database"
"github.com/iotaledger/goshimmer/packages/datastructure"
"github.com/iotaledger/goshimmer/packages/errors"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/goshimmer/packages/node"
"github.com/iotaledger/goshimmer/packages/typeutils"
"github.com/iotaledger/iota.go/trinary"
)
// region public api ///////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -100,7 +100,7 @@ func storeTransactionInDatabase(transaction *value_transaction.ValueTransaction)
func getTransactionFromDatabase(transactionHash trinary.Trytes) (*value_transaction.ValueTransaction, errors.IdentifiableError) {
txData, err := transactionDatabase.Get(typeutils.StringToBytes(transactionHash))
if err != nil {
if err == badger.ErrKeyNotFound {
if err == database.ErrKeyNotFound {
return nil, nil
} else {
return nil, ErrDatabaseError.Derive(err, "failed to retrieve transaction")
......
package tangle
import (
"github.com/dgraph-io/badger"
"github.com/iotaledger/iota.go/trinary"
"github.com/iotaledger/goshimmer/packages/database"
"github.com/iotaledger/goshimmer/packages/datastructure"
"github.com/iotaledger/goshimmer/packages/errors"
"github.com/iotaledger/goshimmer/packages/model/transactionmetadata"
"github.com/iotaledger/goshimmer/packages/node"
"github.com/iotaledger/goshimmer/packages/typeutils"
"github.com/iotaledger/iota.go/trinary"
)
// region public api ///////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -104,7 +104,7 @@ func storeTransactionMetadataInDatabase(metadata *transactionmetadata.Transactio
func getTransactionMetadataFromDatabase(transactionHash trinary.Trytes) (*transactionmetadata.TransactionMetadata, errors.IdentifiableError) {
txMetadata, err := transactionMetadataDatabase.Get(typeutils.StringToBytes(transactionHash))
if err != nil {
if err == badger.ErrKeyNotFound {
if err == database.ErrKeyNotFound {
return nil, nil
} else {
return nil, ErrDatabaseError.Derive(err, "failed to retrieve transaction")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment