mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/tracers: traceCall with txindex
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
a3be38127c
commit
74bf61fa99
1 changed files with 10 additions and 3 deletions
|
|
@ -164,6 +164,7 @@ type TraceCallConfig struct {
|
||||||
TraceConfig
|
TraceConfig
|
||||||
StateOverrides *ethapi.StateOverride
|
StateOverrides *ethapi.StateOverride
|
||||||
BlockOverrides *ethapi.BlockOverrides
|
BlockOverrides *ethapi.BlockOverrides
|
||||||
|
TxIndex *hexutil.Uint
|
||||||
}
|
}
|
||||||
|
|
||||||
// StdTraceConfig holds extra parameters to standard-json trace functions.
|
// StdTraceConfig holds extra parameters to standard-json trace functions.
|
||||||
|
|
@ -866,8 +867,10 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
|
||||||
func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (interface{}, error) {
|
func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (interface{}, error) {
|
||||||
// Try to retrieve the specified block
|
// Try to retrieve the specified block
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
block *types.Block
|
block *types.Block
|
||||||
|
statedb *state.StateDB
|
||||||
|
release StateReleaseFunc
|
||||||
)
|
)
|
||||||
if hash, ok := blockNrOrHash.Hash(); ok {
|
if hash, ok := blockNrOrHash.Hash(); ok {
|
||||||
block, err = api.blockByHash(ctx, hash)
|
block, err = api.blockByHash(ctx, hash)
|
||||||
|
|
@ -892,7 +895,11 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
||||||
if config != nil && config.Reexec != nil {
|
if config != nil && config.Reexec != nil {
|
||||||
reexec = *config.Reexec
|
reexec = *config.Reexec
|
||||||
}
|
}
|
||||||
statedb, release, err := api.backend.StateAtBlock(ctx, block, reexec, nil, true, false)
|
if config != nil && config.TxIndex != nil {
|
||||||
|
_, _, statedb, release, err = api.backend.StateAtTransaction(ctx, block, int(*config.TxIndex), reexec)
|
||||||
|
} else {
|
||||||
|
statedb, release, err = api.backend.StateAtBlock(ctx, block, reexec, nil, true, false)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue