aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm_env.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2016-02-04 06:46:27 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-03-24 06:02:42 +0800
commit14013372aeca2d7f1d8c3a87b7df7c27868314be (patch)
treed4951dbe1d7f1b25b4bbde786b14b5b0b6107bcc /core/vm_env.go
parent342ae7ce7dfd7a0eab2dd06bfa65199825279f05 (diff)
downloadgo-tangerine-14013372aeca2d7f1d8c3a87b7df7c27868314be.tar.gz
go-tangerine-14013372aeca2d7f1d8c3a87b7df7c27868314be.tar.zst
go-tangerine-14013372aeca2d7f1d8c3a87b7df7c27868314be.zip
core: Added EVM configuration options
The EVM is now initialised with an additional configured object that allows you to turn on debugging options.
Diffstat (limited to 'core/vm_env.go')
-rw-r--r--core/vm_env.go41
1 files changed, 24 insertions, 17 deletions
diff --git a/core/vm_env.go b/core/vm_env.go
index 0fab4a090..880baa7b0 100644
--- a/core/vm_env.go
+++ b/core/vm_env.go
@@ -41,33 +41,42 @@ func GetHashFn(ref common.Hash, chain *BlockChain) func(n uint64) common.Hash {
}
type VMEnv struct {
- state *state.StateDB
- header *types.Header
- msg Message
- depth int
- chain *BlockChain
- typ vm.Type
-
- getHashFn func(uint64) common.Hash
- // structured logging
- logs []vm.StructLog
- evm *vm.Vm
+ state *state.StateDB // State to use for executing
+ evm *vm.EVM // The Ethereum Virtual Machine
+ depth int // Current execution depth
+ msg Message // Message appliod
+
+ header *types.Header // Header information
+ chain *BlockChain // Blockchain handle
+ logs []vm.StructLog // Logs for the custom structured logger
+ getHashFn func(uint64) common.Hash // getHashFn callback is used to retrieve block hashes
+
}
-func NewEnv(state *state.StateDB, chain *BlockChain, msg Message, header *types.Header) *VMEnv {
+func NewEnv(state *state.StateDB, chain *BlockChain, msg Message, header *types.Header, cfg *vm.Config) *VMEnv {
env := &VMEnv{
chain: chain,
state: state,
header: header,
msg: msg,
- typ: vm.StdVmTy,
getHashFn: GetHashFn(header.ParentHash, chain),
}
- env.evm = vm.EVM(env)
+
+ // initialise a default config if none present
+ if cfg == nil {
+ cfg = new(vm.Config)
+ }
+
+ // if no log collector is present set self as the collector
+ if cfg.Logger.Collector == nil {
+ cfg.Logger.Collector = env
+ }
+
+ env.evm = vm.New(env, cfg)
return env
}
-func (self *VMEnv) Vm() *vm.Vm { return self.evm }
+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 }
@@ -78,8 +87,6 @@ func (self *VMEnv) Value() *big.Int { return self.msg.Value() }
func (self *VMEnv) Db() vm.Database { return self.state }
func (self *VMEnv) Depth() int { return self.depth }
func (self *VMEnv) SetDepth(i int) { self.depth = i }
-func (self *VMEnv) VmType() vm.Type { return self.typ }
-func (self *VMEnv) SetVmType(t vm.Type) { self.typ = t }
func (self *VMEnv) GetHash(n uint64) common.Hash {
return self.getHashFn(n)
}