mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
core: Made logging of reorgs more structured, also always log if reorg is > 63 blocks long
This commit is contained in:
parent
b5a100b859
commit
661442886e
1 changed files with 17 additions and 5 deletions
|
|
@ -1082,8 +1082,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
|
||||
|
|
@ -1124,7 +1122,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
|
||||
|
|
@ -1145,9 +1142,24 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
|
|||
}
|
||||
}
|
||||
|
||||
if glog.V(logger.Debug) {
|
||||
oldLen := len(oldChain)
|
||||
|
||||
if glog.V(logger.Debug) || oldLen > 63 {
|
||||
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])
|
||||
commonNumber := commonBlock.Number()
|
||||
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) from #%v-#%v [%x/%x] in favour of #%v-#%v [%x/%x]",
|
||||
commonNumber, commonHash[: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
|
||||
|
|
|
|||
Loading…
Reference in a new issue