Skip to content

Commit

Permalink
core: add nil condition and comment for writeHeadBlock if bc empty
Browse files Browse the repository at this point in the history
Signed-off-by: meows <[email protected]>
  • Loading branch information
meowsbits committed Aug 28, 2020
1 parent 7269a17 commit 448fb71
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig ctyp
if frozen > 0 {
txIndexBlock = frozen
}
bc.writeHeadBlock(bc.genesisBlock)
// loadLastState and other steps below assume that CurrentBlock is not nil.
if bc.CurrentBlock() == nil {
bc.writeHeadBlock(bc.genesisBlock)
}
}
if err := bc.loadLastState(); err != nil {
return nil, err
Expand Down

0 comments on commit 448fb71

Please sign in to comment.