Skip to content

Commit

Permalink
bugfix: Fixing the currentHeader crash on restart after unclean shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers committed Sep 21, 2023
1 parent 8816d5c commit e5a12b9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/headerchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ func (hc *HeaderChain) loadLastState() error {
if head := rawdb.ReadHeadBlockHash(hc.headerDb); head != (common.Hash{}) {
if chead := hc.GetHeaderByHash(head); chead != nil {
hc.currentHeader.Store(chead)
} else {
// This is only done if during the stop, currenthead hash was not stored
// properly and it doesn't crash the nodes
hc.currentHeader.Store(hc.genesisHeader)
}
}

Expand Down

0 comments on commit e5a12b9

Please sign in to comment.