diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-04 21:39:15 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-04 21:39:15 +0800 |
commit | 987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9 (patch) | |
tree | 32ff13edca8c3d9b61b303f7d314291d0f216574 /xeth | |
parent | 1b905675465d96227f1a8144fe592e76f646f559 (diff) | |
parent | 08b03afa4bb3a40d2faf6543bc884a8ece5be2a1 (diff) | |
download | dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.gz dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.bz2 dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.lz dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.xz dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.zst dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.zip |
Merge branch 'poc8' into docbranch
Diffstat (limited to 'xeth')
-rw-r--r-- | xeth/pipe.go | 2 | ||||
-rw-r--r-- | xeth/vm_env.go | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/xeth/pipe.go b/xeth/pipe.go index cae6ee1de..05cefd8ad 100644 --- a/xeth/pipe.go +++ b/xeth/pipe.go @@ -87,7 +87,7 @@ func (self *XEth) ExecuteObject(object *Object, data []byte, value, gas, price * self.Vm.State = self.World().State().Copy() - vmenv := NewEnv(self.Vm.State, block, value.BigInt(), initiator.Address()) + vmenv := NewEnv(self.chainManager, self.Vm.State, block, value.BigInt(), initiator.Address()) return vmenv.Call(initiator, object.Address(), data, gas.BigInt(), price.BigInt(), value.BigInt()) } 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) } |