TraceChain returns the structured logs created during the execution of EVM between two blocks (excluding start) and returns them as a JSON object.
(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig)
| 93 | // TraceChain returns the structured logs created during the execution of EVM |
| 94 | // between two blocks (excluding start) and returns them as a JSON object. |
| 95 | func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error) { |
| 96 | // Fetch the block interval that we want to trace |
| 97 | var from, to *types.Block |
| 98 | |
| 99 | switch start { |
| 100 | case rpc.PendingBlockNumber: |
| 101 | from = api.cpc.miner.PendingBlock() |
| 102 | case rpc.LatestBlockNumber: |
| 103 | from = api.cpc.blockchain.CurrentBlock() |
| 104 | default: |
| 105 | from = api.cpc.blockchain.GetBlockByNumber(uint64(start)) |
| 106 | } |
| 107 | switch end { |
| 108 | case rpc.PendingBlockNumber: |
| 109 | to = api.cpc.miner.PendingBlock() |
| 110 | case rpc.LatestBlockNumber: |
| 111 | to = api.cpc.blockchain.CurrentBlock() |
| 112 | default: |
| 113 | to = api.cpc.blockchain.GetBlockByNumber(uint64(end)) |
| 114 | } |
| 115 | // Trace the chain if we've found all our blocks |
| 116 | if from == nil { |
| 117 | return nil, fmt.Errorf("starting block #%d not found", start) |
| 118 | } |
| 119 | if to == nil { |
| 120 | return nil, fmt.Errorf("end block #%d not found", end) |
| 121 | } |
| 122 | |
| 123 | // cf. https://github.com/ethereum/go-ethereum/pull/17460 |
| 124 | if from.Number().Cmp(to.Number()) >= 0 { |
| 125 | return nil, fmt.Errorf("end block (#%d) needs to come after start block (#%d)", end, start) |
| 126 | } |
| 127 | |
| 128 | return api.traceChain(ctx, from, to, config) |
| 129 | } |
| 130 | |
| 131 | // traceChain configures a new tracer according to the provided configuration, and |
| 132 | // executes all the transactions contained within. The return value will be one item |
nothing calls this directly
no test coverage detected