aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-05-29 00:21:14 +0800
committerobscuren <geffobscura@gmail.com>2015-05-29 00:21:14 +0800
commit0e703d92ac9df61e2ededa8c895c70ded101a607 (patch)
treeee77ef0d6d1dd5f00f877776c65bad969389fbad
parentf082c1b8959c1c729a4b62d6ff101d7569e8ba0f (diff)
parent12b90600eb96c86ba1b5b80478be437d02b70891 (diff)
downloaddexon-0e703d92ac9df61e2ededa8c895c70ded101a607.tar
dexon-0e703d92ac9df61e2ededa8c895c70ded101a607.tar.gz
dexon-0e703d92ac9df61e2ededa8c895c70ded101a607.tar.bz2
dexon-0e703d92ac9df61e2ededa8c895c70ded101a607.tar.lz
dexon-0e703d92ac9df61e2ededa8c895c70ded101a607.tar.xz
dexon-0e703d92ac9df61e2ededa8c895c70ded101a607.tar.zst
dexon-0e703d92ac9df61e2ededa8c895c70ded101a607.zip
Merge branch 'release/0.9.26'
-rw-r--r--core/chain_manager.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 86e90a815..3e8ef6fd8 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -680,21 +680,20 @@ func (self *ChainManager) diff(oldBlock, newBlock *types.Block) (types.Blocks, e
// first reduce whoever is higher bound
if oldBlock.NumberU64() > newBlock.NumberU64() {
// reduce old chain
- for oldBlock = oldBlock; oldBlock.NumberU64() != newBlock.NumberU64(); oldBlock = self.GetBlock(oldBlock.ParentHash()) {
- if oldBlock == nil {
- return nil, fmt.Errorf("Invalid old chain")
- }
+ for oldBlock = oldBlock; oldBlock != nil && oldBlock.NumberU64() != newBlock.NumberU64(); oldBlock = self.GetBlock(oldBlock.ParentHash()) {
}
} else {
// reduce new chain and append new chain blocks for inserting later on
- for newBlock = newBlock; newBlock.NumberU64() != oldBlock.NumberU64(); newBlock = self.GetBlock(newBlock.ParentHash()) {
- if newBlock == nil {
- return nil, fmt.Errorf("Invalid new chain")
- }
-
+ for newBlock = newBlock; newBlock != nil && newBlock.NumberU64() != oldBlock.NumberU64(); newBlock = self.GetBlock(newBlock.ParentHash()) {
newChain = append(newChain, newBlock)
}
}
+ if oldBlock == nil {
+ return nil, fmt.Errorf("Invalid old chain")
+ }
+ if newBlock == nil {
+ return nil, fmt.Errorf("Invalid new chain")
+ }
numSplit := newBlock.Number()
for {