core: reorg logs crashed, add a check for corner cases

pull/3738/head
Péter Szilágyi 8 years ago
parent faf713632c
commit a38e1a9c00
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
  1. 5
      core/blockchain.go

@ -1145,13 +1145,16 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
}
}
// Ensure the user sees large reorgs
if len(oldChain) > 0 && len(newChain) > 0 {
logFn := log.Debug
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())
}
var addedTxs types.Transactions
// insert blocks. Order does not matter. Last block will be written in ImportChain itself which creates the new head properly
for _, block := range newChain {

Loading…
Cancel
Save