aboutsummaryrefslogtreecommitdiffstats
path: root/vm/vm.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-01 03:14:01 +0800
committerobscuren <geffobscura@gmail.com>2015-03-01 03:14:01 +0800
commit7adf065b10a0a05aea759e7f29a2a4acfa0f5521 (patch)
tree50ef5156d3495b46a9e57d6f959fb8c0bc92ca7b /vm/vm.go
parent6ea7aae29ca71e6fe857b85296b574e09df57184 (diff)
downloadgo-tangerine-7adf065b10a0a05aea759e7f29a2a4acfa0f5521.tar
go-tangerine-7adf065b10a0a05aea759e7f29a2a4acfa0f5521.tar.gz
go-tangerine-7adf065b10a0a05aea759e7f29a2a4acfa0f5521.tar.bz2
go-tangerine-7adf065b10a0a05aea759e7f29a2a4acfa0f5521.tar.lz
go-tangerine-7adf065b10a0a05aea759e7f29a2a4acfa0f5521.tar.xz
go-tangerine-7adf065b10a0a05aea759e7f29a2a4acfa0f5521.tar.zst
go-tangerine-7adf065b10a0a05aea759e7f29a2a4acfa0f5521.zip
Simple effective VM optimisation
Added a debug flag to the VM which determines if VM output is shown regardless of the log level set.
Diffstat (limited to 'vm/vm.go')
-rw-r--r--vm/vm.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/vm/vm.go b/vm/vm.go
index 7aeeea661..1f386d47c 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -16,6 +16,8 @@ type Vm struct {
logStr string
err error
+ // For logging
+ debug bool
Dbg Debugger
@@ -32,7 +34,7 @@ func New(env Environment) *Vm {
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) {
@@ -938,17 +940,21 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, callData []byte, context *
}
func (self *Vm) Printf(format string, v ...interface{}) VirtualMachine {
- if self.logTy == LogTyPretty {
- self.logStr += fmt.Sprintf(format, v...)
+ if self.debug {
+ if self.logTy == LogTyPretty {
+ self.logStr += fmt.Sprintf(format, v...)
+ }
}
return self
}
func (self *Vm) Endl() VirtualMachine {
- if self.logTy == LogTyPretty {
- vmlogger.Debugln(self.logStr)
- self.logStr = ""
+ if self.debug {
+ if self.logTy == LogTyPretty {
+ vmlogger.Debugln(self.logStr)
+ self.logStr = ""
+ }
}
return self