@@ -79,8 +79,8 @@ type StructLog struct {
79
79
Err error `json:"-"`
80
80
}
81
81
82
- func NewStructlog (pc uint64 , op OpCode , gas , cost uint64 , depth int , err error ) StructLog {
83
- return StructLog {
82
+ func NewStructlog (pc uint64 , op OpCode , gas , cost uint64 , depth int , err error ) * StructLog {
83
+ return & StructLog {
84
84
Pc : pc ,
85
85
Op : op ,
86
86
Gas : gas ,
@@ -90,6 +90,14 @@ func NewStructlog(pc uint64, op OpCode, gas, cost uint64, depth int, err error)
90
90
}
91
91
}
92
92
93
+ func (s * StructLog ) clean () {
94
+ s .Memory .Reset ()
95
+ s .Stack = s .Stack [:0 ]
96
+ s .ReturnData .Reset ()
97
+ s .Storage = nil
98
+ s .Err = nil
99
+ }
100
+
93
101
// overrides for gencodec
94
102
type structLogMarshaling struct {
95
103
Gas math.HexOrDecimal64
@@ -151,7 +159,7 @@ type StructLogger struct {
151
159
createdAccount * types.AccountWrapper
152
160
153
161
callStackLogInd []int
154
- logs []StructLog
162
+ logs []* StructLog
155
163
output []byte
156
164
err error
157
165
}
@@ -351,7 +359,7 @@ func (l *StructLogger) TracedBytecodes() map[common.Hash]CodeInfo {
351
359
func (l * StructLogger ) CreatedAccount () * types.AccountWrapper { return l .createdAccount }
352
360
353
361
// StructLogs returns the captured log entries.
354
- func (l * StructLogger ) StructLogs () []StructLog { return l .logs }
362
+ func (l * StructLogger ) StructLogs () []* StructLog { return l .logs }
355
363
356
364
// Error returns the VM error captured by the trace.
357
365
func (l * StructLogger ) Error () error { return l .err }
@@ -360,7 +368,7 @@ func (l *StructLogger) Error() error { return l.err }
360
368
func (l * StructLogger ) Output () []byte { return l .output }
361
369
362
370
// WriteTrace writes a formatted trace to the given writer
363
- func WriteTrace (writer io.Writer , logs []StructLog ) {
371
+ func WriteTrace (writer io.Writer , logs []* StructLog ) {
364
372
for _ , log := range logs {
365
373
fmt .Fprintf (writer , "%-16spc=%08d gas=%v cost=%v" , log .Op , log .Pc , log .Gas , log .GasCost )
366
374
if log .Err != nil {
@@ -480,8 +488,8 @@ func (t *mdLogger) CaptureEnter(typ OpCode, from common.Address, to common.Addre
480
488
func (t * mdLogger ) CaptureExit (output []byte , gasUsed uint64 , err error ) {}
481
489
482
490
// FormatLogs formats EVM returned structured logs for json output
483
- func FormatLogs (logs []StructLog ) []types.StructLogRes {
484
- formatted := make ([]types.StructLogRes , 0 , len (logs ))
491
+ func FormatLogs (logs []* StructLog ) []* types.StructLogRes {
492
+ formatted := make ([]* types.StructLogRes , 0 , len (logs ))
485
493
486
494
for _ , trace := range logs {
487
495
logRes := types .NewStructLogResBasic (trace .Pc , trace .Op .String (), trace .Gas , trace .GasCost , trace .Depth , trace .RefundCounter , trace .Err )
0 commit comments