Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handles possible nil values #6042

Merged
merged 1 commit into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion slasher/db/testing/setup_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion slasher/db/testing/setup_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion tools/enr-calculator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tools/sendDepositTx/sendDeposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions validator/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down