vm, ethapi: add limit option to traceTransaction

that specifies the maximum number of elements in the `structLogs`
output.  This option is useful for debugging a transaction that
involves a large number of repetition.

For example,
```
debug.traceTransaction(tx, {disableStorage: true, limit: 2})
```
shows at most the first two steps in the `structLogs`.
This commit is contained in:
Yoichi Hirai
2016-09-30 12:22:42 +02:00
parent b4cc8cbac4
commit bb6115b737
4 changed files with 16 additions and 4 deletions

View File

@ -183,7 +183,10 @@ func (evm *EVM) Run(contract *Contract, input []byte) (ret []byte, err error) {
mem.Resize(newMemSize.Uint64())
// Add a log message
if evm.cfg.Debug {
evm.cfg.Tracer.CaptureState(evm.env, pc, op, contract.Gas, cost, mem, stack, contract, evm.env.Depth(), nil)
err = evm.cfg.Tracer.CaptureState(evm.env, pc, op, contract.Gas, cost, mem, stack, contract, evm.env.Depth(), nil)
if err != nil {
return nil, err
}
}
if opPtr := evm.jumpTable[op]; opPtr.valid {