aboutsummaryrefslogtreecommitdiffstats
path: root/core/execution.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-29 03:03:25 +0800
committerobscuren <geffobscura@gmail.com>2015-03-29 03:03:25 +0800
commit3b7e4173ce00fb82ee2f186350dd2aca528ea60d (patch)
tree8f80238dd5cbe37919e7a3afcbaf5c6b382c64e6 /core/execution.go
parent3ea8c7301e6227467e39ae3daa0f382f06b16fba (diff)
downloadgo-tangerine-3b7e4173ce00fb82ee2f186350dd2aca528ea60d.tar.gz
go-tangerine-3b7e4173ce00fb82ee2f186350dd2aca528ea60d.tar.zst
go-tangerine-3b7e4173ce00fb82ee2f186350dd2aca528ea60d.zip
Cleanup VM
Diffstat (limited to 'core/execution.go')
-rw-r--r--core/execution.go27
1 files changed, 15 insertions, 12 deletions
diff --git a/core/execution.go b/core/execution.go
index 72eb22bd5..24e085e6d 100644
--- a/core/execution.go
+++ b/core/execution.go
@@ -11,14 +11,18 @@ import (
)
type Execution struct {
- env vm.Environment
- address *common.Address
- input []byte
+ env vm.Environment
+ address *common.Address
+ input []byte
+ evm vm.VirtualMachine
+
Gas, price, value *big.Int
}
func NewExecution(env vm.Environment, address *common.Address, input []byte, gas, gasPrice, value *big.Int) *Execution {
- return &Execution{env: env, address: address, input: input, Gas: gas, price: gasPrice, value: value}
+ exe := &Execution{env: env, address: address, input: input, Gas: gas, price: gasPrice, value: value}
+ exe.evm = vm.NewVm(env)
+ return exe
}
func (self *Execution) Call(codeAddr common.Address, caller vm.ContextRef) ([]byte, error) {
@@ -28,11 +32,17 @@ func (self *Execution) Call(codeAddr common.Address, caller vm.ContextRef) ([]by
return self.exec(&codeAddr, code, caller)
}
+func (self *Execution) Create(caller vm.ContextRef) (ret []byte, err error, account *state.StateObject) {
+ ret, err = self.exec(nil, self.input, caller)
+ account = self.env.State().GetStateObject(*self.address)
+ return
+}
+
func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm.ContextRef) (ret []byte, err error) {
start := time.Now()
env := self.env
- evm := vm.NewVm(env)
+ evm := self.evm
if env.Depth() == vm.MaxCallDepth {
caller.ReturnGas(self.Gas, self.price)
@@ -70,10 +80,3 @@ func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm.
return
}
-
-func (self *Execution) Create(caller vm.ContextRef) (ret []byte, err error, account *state.StateObject) {
- ret, err = self.exec(nil, self.input, caller)
- account = self.env.State().GetStateObject(*self.address)
-
- return
-}