forked from cerc-io/plugeth
Simple effective VM optimisation
Added a debug flag to the VM which determines if VM output is shown regardless of the log level set.
This commit is contained in:
parent
6ea7aae29c
commit
7adf065b10
8
vm/vm.go
8
vm/vm.go
@ -16,6 +16,8 @@ type Vm struct {
|
|||||||
logStr string
|
logStr string
|
||||||
|
|
||||||
err error
|
err error
|
||||||
|
// For logging
|
||||||
|
debug bool
|
||||||
|
|
||||||
Dbg Debugger
|
Dbg Debugger
|
||||||
|
|
||||||
@ -32,7 +34,7 @@ func New(env Environment) *Vm {
|
|||||||
lt = LogTyDiff
|
lt = LogTyDiff
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Vm{env: env, logTy: lt, Recoverable: true}
|
return &Vm{debug: false, env: env, logTy: lt, Recoverable: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
|
func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
|
||||||
@ -938,18 +940,22 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, callData []byte, context *
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *Vm) Printf(format string, v ...interface{}) VirtualMachine {
|
func (self *Vm) Printf(format string, v ...interface{}) VirtualMachine {
|
||||||
|
if self.debug {
|
||||||
if self.logTy == LogTyPretty {
|
if self.logTy == LogTyPretty {
|
||||||
self.logStr += fmt.Sprintf(format, v...)
|
self.logStr += fmt.Sprintf(format, v...)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Vm) Endl() VirtualMachine {
|
func (self *Vm) Endl() VirtualMachine {
|
||||||
|
if self.debug {
|
||||||
if self.logTy == LogTyPretty {
|
if self.logTy == LogTyPretty {
|
||||||
vmlogger.Debugln(self.logStr)
|
vmlogger.Debugln(self.logStr)
|
||||||
self.logStr = ""
|
self.logStr = ""
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user