diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-04 00:18:43 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-04 00:18:43 +0800 |
commit | ca1b2a1a91401255ab4e26cec7eb575b99ecb8da (patch) | |
tree | 87b3c8fed57f688c138288ed5d90a0a3a1e3274b /core/chain_manager.go | |
parent | 16f417f5af16de8f1c2c140f8b249bd989200bd3 (diff) | |
download | dexon-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.tar dexon-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.tar.gz dexon-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.tar.bz2 dexon-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.tar.lz dexon-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.tar.xz dexon-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.tar.zst dexon-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.zip |
Changed prev_hash to block_hash, state transition now uses vm env
* PREVHASH => BLOCKHASH( N )
* State transition object uses VMEnv as it's query interface
* Updated vm.Enviroment has GetHash( n ) for BLOCKHASH instruction
* Added GetHash to xeth, core, utils & test environments
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r-- | core/chain_manager.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go index ece98d783..82b17cd93 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -271,15 +271,15 @@ func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block { self.mu.RLock() defer self.mu.RUnlock() - block := self.currentBlock - for ; block != nil; block = self.GetBlock(block.Header().ParentHash) { - if block.Header().Number.Uint64() == num { - break - } - } + var block *types.Block - if block != nil && block.Header().Number.Uint64() == 0 && num != 0 { - return nil + if num <= self.currentBlock.Number().Uint64() { + block = self.currentBlock + for ; block != nil; block = self.GetBlock(block.Header().ParentHash) { + if block.Header().Number.Uint64() == num { + break + } + } } return block |