Merge remote-tracking branch 'upstream/develop' into evmjit
This commit is contained in:
23
vm/vm.go
23
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) {
|
||||
@@ -664,6 +666,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
|
||||
}
|
||||
addr = ref.Address()
|
||||
|
||||
fmt.Printf("CREATE %X\n", addr)
|
||||
stack.Push(ethutil.BigD(addr))
|
||||
|
||||
}
|
||||
@@ -727,7 +730,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
|
||||
|
||||
self.Printf(" => (%x) %v", receiver.Address()[:4], balance)
|
||||
|
||||
receiver.AddAmount(balance)
|
||||
receiver.AddBalance(balance)
|
||||
statedb.Delete(context.Address())
|
||||
|
||||
fallthrough
|
||||
@@ -828,7 +831,7 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
|
||||
// 0 => non 0
|
||||
mult = ethutil.Big3
|
||||
} else if len(val) > 0 && len(y.Bytes()) == 0 {
|
||||
statedb.Refund(caller.Address(), GasSStoreRefund)
|
||||
statedb.Refund(self.env.Origin(), GasSStoreRefund)
|
||||
|
||||
mult = ethutil.Big0
|
||||
} else {
|
||||
@@ -937,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
|
||||
|
Reference in New Issue
Block a user