diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-19 19:19:19 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-19 19:19:19 +0800 |
commit | 80261c803a82e51413608a3dc5273c982844d135 (patch) | |
tree | 07bae1473db846065d62ac86b339aaadc9d781c1 /ethchain | |
parent | 863785a52046bcfbbcaa57c83b4b43c215368760 (diff) | |
download | go-tangerine-80261c803a82e51413608a3dc5273c982844d135.tar.gz go-tangerine-80261c803a82e51413608a3dc5273c982844d135.tar.zst go-tangerine-80261c803a82e51413608a3dc5273c982844d135.zip |
Fixed deref ptr
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/block_chain.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go index 1e29f1188..7c9b60fc5 100644 --- a/ethchain/block_chain.go +++ b/ethchain/block_chain.go @@ -164,6 +164,7 @@ func (bc *BlockChain) setLastBlock() { bc.Add(bc.genesisBlock) fk := append([]byte("bloom"), bc.genesisBlock.Hash()...) bc.Ethereum.Db().Put(fk, make([]byte, 255)) + bc.CurrentBlock = bc.genesisBlock } // Set the last know difficulty (might be 0x0 as initial value, Genesis) @@ -201,10 +202,13 @@ func (bc *BlockChain) GetBlock(hash []byte) *Block { func (self *BlockChain) GetBlockByNumber(num uint64) *Block { block := self.CurrentBlock - for ; block.Number.Uint64() != num; block = self.GetBlock(block.PrevHash) { + for ; block != nil; block = self.GetBlock(block.PrevHash) { + if block.Number.Uint64() == num { + break + } } - if block.Number.Uint64() == 0 && num != 0 { + if block != nil && block.Number.Uint64() == 0 && num != 0 { return nil } |