core/vm: capture error and output in StructLogger

This commit is contained in:
Felix Lange 2018-01-04 12:22:15 +01:00
parent 7a59a9380e
commit fc2c730a51

View file

@ -100,6 +100,8 @@ type StructLogger struct {
logs []StructLog logs []StructLog
changedValues map[common.Address]Storage changedValues map[common.Address]Storage
output []byte
err error
} }
// NewStructLogger returns a new logger // NewStructLogger returns a new logger
@ -172,17 +174,19 @@ 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 {
fmt.Printf("0x%x", output) l.output = output
if err != nil { l.err = err
fmt.Printf(" error: %v\n", err)
}
return nil return nil
} }
// StructLogs returns a list of captured log entries // StructLogs returns the captured log entries.
func (l *StructLogger) StructLogs() []StructLog { func (l *StructLogger) StructLogs() []StructLog { return l.logs }
return l.logs
} // Error returns the VM error captured by the trace.
func (l *StructLogger) Error() error { return l.err }
// Output returns the VM return value captured by the trace.
func (l *StructLogger) Output() []byte { return l.output }
// WriteTrace writes a formatted trace to the given writer // WriteTrace writes a formatted trace to the given writer
func WriteTrace(writer io.Writer, logs []StructLog) { func WriteTrace(writer io.Writer, logs []StructLog) {