Skip to content

Commit

Permalink
add safty checks to BlockChain.Stop
Browse files Browse the repository at this point in the history
  • Loading branch information
magicxyyz committed Oct 10, 2023
1 parent 2b1eb7e commit f5e52cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,13 +1041,13 @@ func (bc *BlockChain) Stop() {
for _, offset := range []uint64{0, 1, bc.cacheConfig.TriesInMemory - 1, math.MaxUint64} {
if number := bc.CurrentBlock().Number.Uint64(); number > offset {
var recent *types.Block
if offset == math.MaxUint {
if offset == math.MaxUint && !bc.triegc.Empty() {
_, latest := bc.triegc.Peek()
recent = bc.GetBlockByNumber(uint64(-latest))
} else {
recent = bc.GetBlockByNumber(number - offset)
}
if recent.Root() == (common.Hash{}) {
if recent == nil || recent.Root() == (common.Hash{}) {
continue
}

Expand Down

0 comments on commit f5e52cb

Please sign in to comment.