aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-04 00:18:43 +0800
committerobscuren <geffobscura@gmail.com>2015-01-04 00:18:43 +0800
commitca1b2a1a91401255ab4e26cec7eb575b99ecb8da (patch)
tree87b3c8fed57f688c138288ed5d90a0a3a1e3274b /core/chain_manager.go
parent16f417f5af16de8f1c2c140f8b249bd989200bd3 (diff)
downloaddexon-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.tar.gz
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.go16
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