core/vm: check debug flag for printing output.

This commit is contained in:
dm4 2018-03-16 16:55:21 +08:00
parent 2a9a6f1fcf
commit 339c13a2f3
2 changed files with 8 additions and 4 deletions

View file

@ -76,6 +76,7 @@ func runCmd(ctx *cli.Context) error {
logconfig := &vm.LogConfig{ logconfig := &vm.LogConfig{
DisableMemory: ctx.GlobalBool(DisableMemoryFlag.Name), DisableMemory: ctx.GlobalBool(DisableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name), DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
Debug: ctx.GlobalBool(DebugFlag.Name),
} }
var ( var (
@ -236,10 +237,6 @@ Gas used: %d
} }
if tracer != nil { if tracer != nil {
tracer.CaptureEnd(ret, initialGas-leftOverGas, execTime, err) tracer.CaptureEnd(ret, initialGas-leftOverGas, execTime, err)
fmt.Printf("0x%x", ret)
if err != nil {
fmt.Printf(" error: %v\n", err)
}
} else { } else {
fmt.Printf("0x%x\n", ret) fmt.Printf("0x%x\n", ret)
if err != nil { if err != nil {

View file

@ -45,6 +45,7 @@ type LogConfig struct {
DisableMemory bool // disable memory capture DisableMemory bool // disable memory capture
DisableStack bool // disable stack capture DisableStack bool // disable stack capture
DisableStorage bool // disable storage capture DisableStorage bool // disable storage capture
Debug bool // print output during capture end
Limit int // maximum length of output, but zero means unlimited Limit int // maximum length of output, but zero means unlimited
} }
@ -184,6 +185,12 @@ func (l *StructLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost ui
func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error { func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error {
l.output = output l.output = output
l.err = err l.err = err
if l.cfg.Debug {
fmt.Printf("0x%x", output)
if err != nil {
fmt.Printf(" error: %v\n", err)
}
}
return nil return nil
} }