diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2016-01-21 22:29:58 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-03-23 07:04:00 +0800 |
commit | 342ae7ce7dfd7a0eab2dd06bfa65199825279f05 (patch) | |
tree | 4d90314e50e137bcd8ee837cbb396fee40e2bb4b /core/vm_env.go | |
parent | 2855a93ede6e9437d05a82c2397d48744621db9b (diff) | |
download | dexon-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.gz dexon-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.zst dexon-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.zip |
core, core/vm, tests: changed the initialisation behaviour of the EVM
The EVM was previously initialised and created for every CALL, CALLCODE,
DELEGATECALL and CREATE. This PR changes this behaviour so that the same
EVM can be used through the session and beyond as long as the
Environment sticks around.
Diffstat (limited to 'core/vm_env.go')
-rw-r--r-- | core/vm_env.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/vm_env.go b/core/vm_env.go index 7b9a1a0f9..0fab4a090 100644 --- a/core/vm_env.go +++ b/core/vm_env.go @@ -51,10 +51,11 @@ type VMEnv struct { getHashFn func(uint64) common.Hash // structured logging logs []vm.StructLog + evm *vm.Vm } func NewEnv(state *state.StateDB, chain *BlockChain, msg Message, header *types.Header) *VMEnv { - return &VMEnv{ + env := &VMEnv{ chain: chain, state: state, header: header, @@ -62,8 +63,11 @@ func NewEnv(state *state.StateDB, chain *BlockChain, msg Message, header *types. typ: vm.StdVmTy, getHashFn: GetHashFn(header.ParentHash, chain), } + env.evm = vm.EVM(env) + return env } +func (self *VMEnv) Vm() *vm.Vm { return self.evm } func (self *VMEnv) Origin() common.Address { f, _ := self.msg.From(); return f } func (self *VMEnv) BlockNumber() *big.Int { return self.header.Number } func (self *VMEnv) Coinbase() common.Address { return self.header.Coinbase } |