diff --git a/slasher/db/testing/setup_db.go b/slasher/db/testing/setup_db.go index b7a5bc2ef509..7ab98b85d66d 100644 --- a/slasher/db/testing/setup_db.go +++ b/slasher/db/testing/setup_db.go @@ -27,10 +27,10 @@ func SetupSlasherDB(t testing.TB, spanCacheEnabled bool) *kv.Store { } cfg := &kv.Config{} db, err := slasherDB.NewDB(p, cfg) - db.EnableSpanCache(spanCacheEnabled) if err != nil { t.Fatalf("Failed to instantiate DB: %v", err) } + db.EnableSpanCache(spanCacheEnabled) t.Cleanup(func() { if err := db.Close(); err != nil { t.Fatalf("Failed to close database: %v", err) diff --git a/slasher/db/testing/setup_db_test.go b/slasher/db/testing/setup_db_test.go index 0705f84108d7..c0b263fe8c46 100644 --- a/slasher/db/testing/setup_db_test.go +++ b/slasher/db/testing/setup_db_test.go @@ -25,10 +25,10 @@ func TestClearDB(t *testing.T) { } cfg := &kv.Config{} db, err := slasherDB.NewDB(p, cfg) - db.EnableSpanCache(false) if err != nil { t.Fatalf("Failed to instantiate DB: %v", err) } + db.EnableSpanCache(false) if err := db.ClearDB(); err != nil { t.Fatal(err) } diff --git a/tools/enr-calculator/main.go b/tools/enr-calculator/main.go index 0d9f8b53f655..bb853eaa2590 100644 --- a/tools/enr-calculator/main.go +++ b/tools/enr-calculator/main.go @@ -51,11 +51,11 @@ func main() { } db, err := enode.OpenDB("") - defer db.Close() if err != nil { log.Fatalf("Could not open node's peer database: %v\n", err) return } + defer db.Close() localNode := enode.NewLocalNode(db, ecdsaPrivKey) ipEntry := enr.IP(net.ParseIP(*ipAddr)) diff --git a/tools/sendDepositTx/sendDeposits.go b/tools/sendDepositTx/sendDeposits.go index 64fc9d894ec3..96dfcd52490d 100644 --- a/tools/sendDepositTx/sendDeposits.go +++ b/tools/sendDepositTx/sendDeposits.go @@ -168,10 +168,10 @@ func main() { validatorKeys := make(map[string]*prysmKeyStore.Key) if randomKey { validatorKey, err := prysmKeyStore.NewKey() - validatorKeys[hex.EncodeToString(validatorKey.PublicKey.Marshal())] = validatorKey if err != nil { return errors.Wrap(err, "Could not generate random key") } + validatorKeys[hex.EncodeToString(validatorKey.PublicKey.Marshal())] = validatorKey } else { // Load from keystore store := prysmKeyStore.NewKeystore(prysmKeystorePath) diff --git a/validator/db/db.go b/validator/db/db.go index a3df2c895255..08671396d3d7 100644 --- a/validator/db/db.go +++ b/validator/db/db.go @@ -67,6 +67,9 @@ func createBuckets(tx *bolt.Tx, buckets ...[]byte) error { // and stores an open connection db object as a property of the Store struct. func NewKVStoreWithPublicKeyBuckets(dirPath string, pubKeys [][48]byte) (*Store, error) { kv, err := NewKVStore(dirPath) + if err != nil { + return nil, err + } // Initialize the required public keys into the DB to ensure they're not empty. if err := kv.initializeSubBuckets(pubKeys); err != nil { return nil, err