aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-27 06:17:04 +0800
committerobscuren <geffobscura@gmail.com>2014-06-27 06:17:04 +0800
commit6c7e58643c18d42d616b4849bf4c81586c4afed1 (patch)
tree14b17e68208025e2edb968403666d1804137d24e
parente3ad2a39699a4c33a3ee5ee0525552d1f1ecedfc (diff)
parent423beddf574383ec58246938f738f08cd50f031a (diff)
downloaddexon-6c7e58643c18d42d616b4849bf4c81586c4afed1.tar
dexon-6c7e58643c18d42d616b4849bf4c81586c4afed1.tar.gz
dexon-6c7e58643c18d42d616b4849bf4c81586c4afed1.tar.bz2
dexon-6c7e58643c18d42d616b4849bf4c81586c4afed1.tar.lz
dexon-6c7e58643c18d42d616b4849bf4c81586c4afed1.tar.xz
dexon-6c7e58643c18d42d616b4849bf4c81586c4afed1.tar.zst
dexon-6c7e58643c18d42d616b4849bf4c81586c4afed1.zip
Merge branch 'develop'
-rw-r--r--ethchain/block_chain.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go
index d0fea6641..6e4c72b27 100644
--- a/ethchain/block_chain.go
+++ b/ethchain/block_chain.go
@@ -221,9 +221,16 @@ func (bc *BlockChain) GetChainFromHash(hash []byte, max uint64) []interface{} {
startNumber := parentNumber + count
num := lastNumber
- for ; num > startNumber; currentHash = bc.GetBlock(currentHash).PrevHash {
+ for num > startNumber {
num--
+
+ block := bc.GetBlock(currentHash)
+ if block == nil {
+ break
+ }
+ currentHash = block.PrevHash
}
+
for i := uint64(0); bytes.Compare(currentHash, hash) != 0 && num >= parentNumber && i < count; i++ {
// Get the block of the chain
block := bc.GetBlock(currentHash)