Skip to content

Commit

Permalink
core: prevent nil pointer exception
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden committed May 23, 2022
1 parent e48b1ae commit 489bb50
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/blockchain.go
Expand Up @@ -2059,7 +2059,9 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
}
// Insert the new chain(except the head block(reverse order)),
// taking care of the proper incremental order.
log.Warn("Long reorg", "newchain length", len(newChain), "from", newChain[0].number, "to", newChain[len(newChain)-1].number)
if len(newChain) > 0 {
log.Warn("Long reorg", "newchain length", len(newChain), "from", newChain[0].number, "to", newChain[len(newChain)-1].number)
}
for i := len(newChain) - 1; i >= 1; i-- {
// Insert the block in the canonical way, re-writing history
block := bc.GetBlock(newChain[i].hash, newChain[i].number)
Expand Down

0 comments on commit 489bb50

Please sign in to comment.