Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/tracers: make transaction trace response compatible with geth #648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,30 @@ type StdTraceConfig struct {

// txTraceResult is the result of a single transaction trace.
type txTraceResult struct {
TransactionHash common.Hash `json:"transactionHash,omitempty"`
TransactionHash common.Hash `json:"transactionHash"`
Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer
Error string `json:"error,omitempty"` // Trace failure produced by the tracer
}

// Create a response that is compatible with go-ethereum
// with txHash field but still keep transactionHash field
// to avoid breaking change for current user.
func (result txTraceResult) MarshalJSON() ([]byte, error) {
newResult := struct {
TxHash common.Hash `json:"txHash"`
TransactionHash common.Hash `json:"transactionHash"`
Result interface{} `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}{
TxHash: result.TransactionHash,
TransactionHash: result.TransactionHash,
Result: result.Result,
Error: result.Error,
}

return json.Marshal(&newResult)
}

// internalAndAccountResult is the result of a single transaction trace.
type internalAndAccountResult struct {
InternalTxs []*txTraceResult `json:"internalTxs,omitempty"` // Trace results produced by the tracer
Expand Down
Loading