Merge pull request #3738 from karalabe/impossible-reorg-warning

core: reorg logs crashed, add a check for corner cases
pull/3755/head
Péter Szilágyi 8 years ago committed by GitHub
commit 1a00e39539
  1. 15
      core/blockchain.go

@ -1145,13 +1145,16 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
} }
} }
// Ensure the user sees large reorgs // Ensure the user sees large reorgs
logFn := log.Debug if len(oldChain) > 0 && len(newChain) > 0 {
if len(oldChain) > 63 { logFn := log.Debug
logFn = log.Warn if len(oldChain) > 63 {
logFn = log.Warn
}
logFn("Chain split detected", "number", commonBlock.Number(), "hash", commonBlock.Hash(),
"drop", len(oldChain), "dropfrom", oldChain[0].Hash(), "add", len(newChain), "addfrom", newChain[0].Hash())
} else {
log.Error("Impossible reorg, please file an issue", "oldnum", oldBlock.Number(), "oldhash", oldBlock.Hash(), "newnum", newBlock.Number(), "newhash", newBlock.Hash())
} }
logFn("Chain split detected", "number", commonBlock.Number(), "hash", commonBlock.Hash(),
"drop", len(oldChain), "dropfrom", oldChain[0].Hash(), "add", len(newChain), "addfrom", newChain[0].Hash())
var addedTxs types.Transactions var addedTxs types.Transactions
// insert blocks. Order does not matter. Last block will be written in ImportChain itself which creates the new head properly // insert blocks. Order does not matter. Last block will be written in ImportChain itself which creates the new head properly
for _, block := range newChain { for _, block := range newChain {

Loading…
Cancel
Save