diff options
author | Martin Holst Swende <martin@swende.se> | 2017-01-17 20:10:26 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-01-17 20:10:26 +0800 |
commit | 6fb76443b34ac5797c4b561ec38148eb3868a47e (patch) | |
tree | 1016e6108fc1bcc0179a60a185fa8c2b7f2902d3 /core | |
parent | 2eefed84c9fc005eec1cb5e7d1a3593aab3e0537 (diff) | |
download | dexon-6fb76443b34ac5797c4b561ec38148eb3868a47e.tar dexon-6fb76443b34ac5797c4b561ec38148eb3868a47e.tar.gz dexon-6fb76443b34ac5797c4b561ec38148eb3868a47e.tar.bz2 dexon-6fb76443b34ac5797c4b561ec38148eb3868a47e.tar.lz dexon-6fb76443b34ac5797c4b561ec38148eb3868a47e.tar.xz dexon-6fb76443b34ac5797c4b561ec38148eb3868a47e.tar.zst dexon-6fb76443b34ac5797c4b561ec38148eb3868a47e.zip |
core/blockchain: Made logging of reorgs more structured (#3573)
* core: Made logging of reorgs more structured, also always log if reorg is > 63 blocks long
* core/blockchain: go fmt
* core/blockchain: Minor fixes to the reorg reporting
Diffstat (limited to 'core')
-rw-r--r-- | core/blockchain.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 2e522d97c..90bb0b5a8 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1088,8 +1088,6 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error { newChain types.Blocks oldChain types.Blocks commonBlock *types.Block - oldStart = oldBlock - newStart = newBlock deletedTxs types.Transactions deletedLogs []*types.Log // collectLogs collects the logs that were generated during the @@ -1130,7 +1128,6 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error { return fmt.Errorf("Invalid new chain") } - numSplit := newBlock.Number() for { if oldBlock.Hash() == newBlock.Hash() { commonBlock = oldBlock @@ -1151,9 +1148,19 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error { } } - if glog.V(logger.Debug) { - commonHash := commonBlock.Hash() - glog.Infof("Chain split detected @ %x. Reorganising chain from #%v %x to %x", commonHash[:4], numSplit, oldStart.Hash().Bytes()[:4], newStart.Hash().Bytes()[:4]) + if oldLen := len(oldChain); oldLen > 63 || glog.V(logger.Debug) { + newLen := len(newChain) + newLast := newChain[0] + newFirst := newChain[newLen-1] + oldLast := oldChain[0] + oldFirst := oldChain[oldLen-1] + glog.Infof("Chain split detected after #%v [%x…]. Reorganising chain (-%v +%v blocks), rejecting #%v-#%v [%x…/%x…] in favour of #%v-#%v [%x…/%x…]", + commonBlock.Number(), commonBlock.Hash().Bytes()[:4], + oldLen, newLen, + oldFirst.Number(), oldLast.Number(), + oldFirst.Hash().Bytes()[:4], oldLast.Hash().Bytes()[:4], + newFirst.Number(), newLast.Number(), + newFirst.Hash().Bytes()[:4], newLast.Hash().Bytes()[:4]) } var addedTxs types.Transactions |