aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-10-21 08:31:46 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-10-21 08:31:46 +0800
commit80f26086eeb126cb87000f283cb5ccc3df95dbcc (patch)
tree298cd91b9102053a65cfb18ae4e43ca7980fb8f3 /core
parent796952a49ac12caa3949587e22a7a03c30a8910c (diff)
downloadgo-tangerine-80f26086eeb126cb87000f283cb5ccc3df95dbcc.tar
go-tangerine-80f26086eeb126cb87000f283cb5ccc3df95dbcc.tar.gz
go-tangerine-80f26086eeb126cb87000f283cb5ccc3df95dbcc.tar.bz2
go-tangerine-80f26086eeb126cb87000f283cb5ccc3df95dbcc.tar.lz
go-tangerine-80f26086eeb126cb87000f283cb5ccc3df95dbcc.tar.xz
go-tangerine-80f26086eeb126cb87000f283cb5ccc3df95dbcc.tar.zst
go-tangerine-80f26086eeb126cb87000f283cb5ccc3df95dbcc.zip
core, tests: get_hash fix
Make sure that we're fetching the hash from the current chain and not the canonical chain.
Diffstat (limited to 'core')
-rw-r--r--core/vm/environment.go2
-rw-r--r--core/vm_env.go6
2 files changed, 5 insertions, 3 deletions
diff --git a/core/vm/environment.go b/core/vm/environment.go
index ec739b26c..299d12674 100644
--- a/core/vm/environment.go
+++ b/core/vm/environment.go
@@ -39,7 +39,7 @@ type Environment interface {
// The block number this VM is invoken on
BlockNumber() *big.Int
// The n'th hash ago from this block number
- GetHash(n uint64) common.Hash
+ GetHash(uint64) common.Hash
// The handler's address
Coinbase() common.Address
// The current time (block time)
diff --git a/core/vm_env.go b/core/vm_env.go
index 715fde52f..c8b50debc 100644
--- a/core/vm_env.go
+++ b/core/vm_env.go
@@ -59,8 +59,10 @@ func (self *VMEnv) SetDepth(i int) { self.depth = i }
func (self *VMEnv) VmType() vm.Type { return self.typ }
func (self *VMEnv) SetVmType(t vm.Type) { self.typ = t }
func (self *VMEnv) GetHash(n uint64) common.Hash {
- if block := self.chain.GetBlockByNumber(n); block != nil {
- return block.Hash()
+ for block := self.chain.GetBlock(self.header.ParentHash); block != nil; block = self.chain.GetBlock(block.ParentHash()) {
+ if block.NumberU64() == n {
+ return block.Hash()
+ }
}
return common.Hash{}