aboutsummaryrefslogtreecommitdiffstats
path: root/xeth/vm_env.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 /xeth/vm_env.go
parent16f417f5af16de8f1c2c140f8b249bd989200bd3 (diff)
downloaddexon-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 'xeth/vm_env.go')
-rw-r--r--xeth/vm_env.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/xeth/vm_env.go b/xeth/vm_env.go
index d2a21afd5..1470b9eaa 100644
--- a/xeth/vm_env.go
+++ b/xeth/vm_env.go
@@ -10,6 +10,7 @@ import (
)
type VMEnv struct {
+ chain *core.ChainManager
state *state.StateDB
block *types.Block
value *big.Int
@@ -18,7 +19,7 @@ type VMEnv struct {
depth int
}
-func NewEnv(state *state.StateDB, block *types.Block, value *big.Int, sender []byte) *VMEnv {
+func NewEnv(chain *core.ChainManager, state *state.StateDB, block *types.Block, value *big.Int, sender []byte) *VMEnv {
return &VMEnv{
state: state,
block: block,
@@ -33,12 +34,18 @@ func (self *VMEnv) PrevHash() []byte { return self.block.ParentHash() }
func (self *VMEnv) Coinbase() []byte { return self.block.Coinbase() }
func (self *VMEnv) Time() int64 { return self.block.Time() }
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty() }
-func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit() }
func (self *VMEnv) Value() *big.Int { return self.value }
func (self *VMEnv) State() *state.StateDB { return self.state }
func (self *VMEnv) Depth() int { return self.depth }
func (self *VMEnv) SetDepth(i int) { self.depth = i }
+func (self *VMEnv) GetHash(n uint64) []byte {
+ if block := self.chain.GetBlockByNumber(n); block != nil {
+ return block.Hash()
+ }
+
+ return nil
+}
func (self *VMEnv) AddLog(log state.Log) {
self.state.AddLog(log)
}