Skip to content

Commit

Permalink
Add a txhash field on txTraceResult
Browse files Browse the repository at this point in the history
  • Loading branch information
KimKyungup committed Apr 27, 2020
1 parent b223055 commit b53b871
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions node/cn/api_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type StdTraceConfig struct {

// txTraceResult is the result of a single transaction trace.
type txTraceResult struct {
TxHash common.Hash `json:"txHash,omitempty"` // transaction hash
Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer
Error string `json:"error,omitempty"` // Trace failure produced by the tracer
}
Expand Down Expand Up @@ -207,20 +208,20 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl
msg, err := tx.AsMessageWithAccountKeyPicker(signer, task.statedb, task.block.NumberU64())
if err != nil {
logger.Warn("Tracing failed", "hash", tx.Hash(), "block", task.block.NumberU64(), "err", err)
task.results[i] = &txTraceResult{Error: err.Error()}
task.results[i] = &txTraceResult{TxHash: tx.Hash(), Error: err.Error()}
break
}

vmctx := blockchain.NewEVMContext(msg, task.block.Header(), api.cn.blockchain, nil)

res, err := api.traceTx(ctx, msg, vmctx, task.statedb, config)
if err != nil {
task.results[i] = &txTraceResult{Error: err.Error()}
task.results[i] = &txTraceResult{TxHash: tx.Hash(), Error: err.Error()}
logger.Warn("Tracing failed", "hash", tx.Hash(), "block", task.block.NumberU64(), "err", err)
break
}
task.statedb.Finalise(true, true)
task.results[i] = &txTraceResult{Result: res}
task.results[i] = &txTraceResult{TxHash: tx.Hash(), Result: res}
}
// Stream the result back to the user or abort on teardown
select {
Expand Down Expand Up @@ -491,18 +492,18 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block,
msg, err := txs[task.index].AsMessageWithAccountKeyPicker(signer, task.statedb, block.NumberU64())
if err != nil {
logger.Warn("Tracing failed", "tx idx", task.index, "block", block.NumberU64(), "err", err)
results[task.index] = &txTraceResult{Error: err.Error()}
results[task.index] = &txTraceResult{TxHash: txs[task.index].Hash(), Error: err.Error()}
continue
}

vmctx := blockchain.NewEVMContext(msg, block.Header(), api.cn.blockchain, nil)

res, err := api.traceTx(ctx, msg, vmctx, task.statedb, config)
if err != nil {
results[task.index] = &txTraceResult{Error: err.Error()}
results[task.index] = &txTraceResult{TxHash: txs[task.index].Hash(), Error: err.Error()}
continue
}
results[task.index] = &txTraceResult{Result: res}
results[task.index] = &txTraceResult{TxHash: txs[task.index].Hash(), Result: res}
}
}()
}
Expand Down

0 comments on commit b53b871

Please sign in to comment.