Skip to content

Commit 0e703d9

Browse files
committed
Merge branch 'release/0.9.26'
2 parents f082c1b + 12b9060 commit 0e703d9

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

core/chain_manager.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -680,21 +680,20 @@ func (self *ChainManager) diff(oldBlock, newBlock *types.Block) (types.Blocks, e
680680
// first reduce whoever is higher bound
681681
if oldBlock.NumberU64() > newBlock.NumberU64() {
682682
// reduce old chain
683-
for oldBlock = oldBlock; oldBlock.NumberU64() != newBlock.NumberU64(); oldBlock = self.GetBlock(oldBlock.ParentHash()) {
684-
if oldBlock == nil {
685-
return nil, fmt.Errorf("Invalid old chain")
686-
}
683+
for oldBlock = oldBlock; oldBlock != nil && oldBlock.NumberU64() != newBlock.NumberU64(); oldBlock = self.GetBlock(oldBlock.ParentHash()) {
687684
}
688685
} else {
689686
// reduce new chain and append new chain blocks for inserting later on
690-
for newBlock = newBlock; newBlock.NumberU64() != oldBlock.NumberU64(); newBlock = self.GetBlock(newBlock.ParentHash()) {
691-
if newBlock == nil {
692-
return nil, fmt.Errorf("Invalid new chain")
693-
}
694-
687+
for newBlock = newBlock; newBlock != nil && newBlock.NumberU64() != oldBlock.NumberU64(); newBlock = self.GetBlock(newBlock.ParentHash()) {
695688
newChain = append(newChain, newBlock)
696689
}
697690
}
691+
if oldBlock == nil {
692+
return nil, fmt.Errorf("Invalid old chain")
693+
}
694+
if newBlock == nil {
695+
return nil, fmt.Errorf("Invalid new chain")
696+
}
698697

699698
numSplit := newBlock.Number()
700699
for {

0 commit comments

Comments
 (0)