Skip to content

Commit

Permalink
core/vm: dedup config check in markdown logger (ethereum#21655)
Browse files Browse the repository at this point in the history
* core/vm: dedup config check

* review feedback: reuse buffer
  • Loading branch information
gballet authored Oct 8, 2020
1 parent 5e86e4e commit 43cd31e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions core/vm/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,21 @@ func (t *mdLogger) CaptureStart(from common.Address, to common.Address, create b
func (t *mdLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, rStack *ReturnStack, rData []byte, contract *Contract, depth int, err error) error {
fmt.Fprintf(t.out, "| %4d | %10v | %3d |", pc, op, cost)

if !t.cfg.DisableStack { // format stack
if !t.cfg.DisableStack {
// format stack
var a []string
for _, elem := range stack.data {
a = append(a, fmt.Sprintf("%d", elem))
}
b := fmt.Sprintf("[%v]", strings.Join(a, ","))
fmt.Fprintf(t.out, "%10v |", b)
}
if !t.cfg.DisableStack { // format return stack
var a []string

// format return stack
a = a[:0]
for _, elem := range rStack.data {
a = append(a, fmt.Sprintf("%2d", elem))
}
b := fmt.Sprintf("[%v]", strings.Join(a, ","))
b = fmt.Sprintf("[%v]", strings.Join(a, ","))
fmt.Fprintf(t.out, "%10v |", b)
}
fmt.Fprintln(t.out, "")
Expand Down

0 comments on commit 43cd31e

Please sign in to comment.