MCPcopy Create free account
hub / github.com/CPChain/chain / TraceChain

Method TraceChain

protocols/cpc/api_tracer.go:95–129  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
95func (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

Callers

nothing calls this directly

Calls 6

NumberMethod · 0.95
traceChainMethod · 0.95
PendingBlockMethod · 0.80
CmpMethod · 0.80
CurrentBlockMethod · 0.65
GetBlockByNumberMethod · 0.65

Tested by

no test coverage detected