aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
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 /cmd
parent2855a93ede6e9437d05a82c2397d48744621db9b (diff)
downloadgo-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar
go-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.gz
go-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.bz2
go-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.lz
go-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.xz
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 'cmd')
-rw-r--r--cmd/evm/main.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/evm/main.go b/cmd/evm/main.go
index ef679e373..0ba6820e0 100644
--- a/cmd/evm/main.go
+++ b/cmd/evm/main.go
@@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/params"
)
var (
@@ -174,17 +175,23 @@ type VMEnv struct {
Gas *big.Int
time *big.Int
logs []vm.StructLog
+
+ evm *vm.Vm
}
func NewEnv(state *state.StateDB, transactor common.Address, value *big.Int) *VMEnv {
- return &VMEnv{
+ params.HomesteadBlock = new(big.Int)
+ env := &VMEnv{
state: state,
transactor: &transactor,
value: value,
time: big.NewInt(time.Now().Unix()),
}
+ env.evm = vm.EVM(env)
+ return env
}
+func (self *VMEnv) Vm() *vm.Vm { return self.evm }
func (self *VMEnv) Db() vm.Database { return self.state }
func (self *VMEnv) MakeSnapshot() vm.Database { return self.state.Copy() }
func (self *VMEnv) SetSnapshot(db vm.Database) { self.state.Set(db.(*state.StateDB)) }