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 /cmd | |
parent | 16f417f5af16de8f1c2c140f8b249bd989200bd3 (diff) | |
download | go-tangerine-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.tar.gz go-tangerine-ca1b2a1a91401255ab4e26cec7eb575b99ecb8da.tar.zst go-tangerine-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 'cmd')
-rw-r--r-- | cmd/mist/debugger.go | 2 | ||||
-rw-r--r-- | cmd/utils/vm_env.go | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/cmd/mist/debugger.go b/cmd/mist/debugger.go index 0e97a6652..618e31f4e 100644 --- a/cmd/mist/debugger.go +++ b/cmd/mist/debugger.go @@ -151,7 +151,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data block := self.lib.eth.ChainManager().CurrentBlock() - env := utils.NewEnv(statedb, block, account.Address(), value) + env := utils.NewEnv(self.lib.eth.ChainManager(), statedb, block, account.Address(), value) self.Logf("callsize %d", len(script)) go func() { diff --git a/cmd/utils/vm_env.go b/cmd/utils/vm_env.go index 19091bdc5..acc2ffad9 100644 --- a/cmd/utils/vm_env.go +++ b/cmd/utils/vm_env.go @@ -10,6 +10,7 @@ import ( ) type VMEnv struct { + chain *core.ChainManager state *state.StateDB block *types.Block @@ -20,8 +21,9 @@ type VMEnv struct { Gas *big.Int } -func NewEnv(state *state.StateDB, block *types.Block, transactor []byte, value *big.Int) *VMEnv { +func NewEnv(chain *core.ChainManager, state *state.StateDB, block *types.Block, transactor []byte, value *big.Int) *VMEnv { return &VMEnv{ + chain: chain, state: state, block: block, transactor: transactor, @@ -35,12 +37,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) } |