aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/runtime
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2016-01-21 22:29:58 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-03-23 07:04:00 +0800
commit342ae7ce7dfd7a0eab2dd06bfa65199825279f05 (patch)
tree4d90314e50e137bcd8ee837cbb396fee40e2bb4b /core/vm/runtime
parent2855a93ede6e9437d05a82c2397d48744621db9b (diff)
downloadgo-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.gz
go-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.zst
go-tangerine-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/runtime')
-rw-r--r--core/vm/runtime/env.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/core/vm/runtime/env.go b/core/vm/runtime/env.go
index 77519df81..e9bf828ea 100644
--- a/core/vm/runtime/env.go
+++ b/core/vm/runtime/env.go
@@ -41,11 +41,13 @@ type Env struct {
logs []vm.StructLog
getHashFn func(uint64) common.Hash
+
+ evm *vm.Vm
}
// NewEnv returns a new vm.Environment
func NewEnv(cfg *Config, state *state.StateDB) vm.Environment {
- return &Env{
+ env := &Env{
state: state,
origin: cfg.Origin,
coinbase: cfg.Coinbase,
@@ -54,6 +56,9 @@ func NewEnv(cfg *Config, state *state.StateDB) vm.Environment {
difficulty: cfg.Difficulty,
gasLimit: cfg.GasLimit,
}
+ env.evm = vm.EVM(env)
+
+ return env
}
func (self *Env) StructLogs() []vm.StructLog {
@@ -64,6 +69,7 @@ func (self *Env) AddStructLog(log vm.StructLog) {
self.logs = append(self.logs, log)
}
+func (self *Env) Vm() *vm.Vm { return self.evm }
func (self *Env) Origin() common.Address { return self.origin }
func (self *Env) BlockNumber() *big.Int { return self.number }
func (self *Env) Coinbase() common.Address { return self.coinbase }