Skip to content

Commit

Permalink
chore: close db if node initialized check fails (ChainSafe#1551)
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed May 4, 2021
1 parent b86c7ff commit d7b87f1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions dot/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ func NodeInitialized(basepath string, expected bool) bool {
return false
}

defer func() {
// close database
err = db.Close()
if err != nil {
logger.Error("failed to close database", "error", err)
}
}()

// load genesis data from initialised node database
_, err = state.NewBaseState(db).LoadGenesisData()
if err != nil {
Expand All @@ -164,12 +172,6 @@ func NodeInitialized(basepath string, expected bool) bool {
return false
}

// close database
err = db.Close()
if err != nil {
logger.Error("failed to close database", "error", err)
}

return true
}

Expand Down

0 comments on commit d7b87f1

Please sign in to comment.