From b53b8715e8484bd7bb1e0e5416c92df16137ec3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ethan=20Kim=28=EA=B9=80=EA=B2=BD=EC=97=85=29?= Date: Mon, 20 Apr 2020 15:42:30 +0900 Subject: [PATCH] Add a txhash field on txTraceResult --- node/cn/api_tracer.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/node/cn/api_tracer.go b/node/cn/api_tracer.go index 930eebb3d3..6a300d8802 100644 --- a/node/cn/api_tracer.go +++ b/node/cn/api_tracer.go @@ -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 } @@ -207,7 +208,7 @@ 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 } @@ -215,12 +216,12 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl 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 { @@ -491,7 +492,7 @@ 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 } @@ -499,10 +500,10 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block, 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} } }() }