diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-03-03 15:54:13 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-03-03 15:54:13 +0800 |
commit | a38e1a9c00c6a0b95408269a035b409b8ff6c228 (patch) | |
tree | cff164d8c18cf4d7342f2ed16410f538de833f59 /core | |
parent | faf713632c307e3fd77a492481846b858ad991f9 (diff) | |
download | dexon-a38e1a9c00c6a0b95408269a035b409b8ff6c228.tar dexon-a38e1a9c00c6a0b95408269a035b409b8ff6c228.tar.gz dexon-a38e1a9c00c6a0b95408269a035b409b8ff6c228.tar.bz2 dexon-a38e1a9c00c6a0b95408269a035b409b8ff6c228.tar.lz dexon-a38e1a9c00c6a0b95408269a035b409b8ff6c228.tar.xz dexon-a38e1a9c00c6a0b95408269a035b409b8ff6c228.tar.zst dexon-a38e1a9c00c6a0b95408269a035b409b8ff6c228.zip |
core: reorg logs crashed, add a check for corner cases
Diffstat (limited to 'core')
-rw-r--r-- | core/blockchain.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 88ba76bc7..3879f0644 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1145,13 +1145,16 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error { } } // Ensure the user sees large reorgs - logFn := log.Debug - if len(oldChain) > 63 { - logFn = log.Warn + 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()) } - 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 // insert blocks. Order does not matter. Last block will be written in ImportChain itself which creates the new head properly for _, block := range newChain { |