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

Method TraceBlockByNumber

protocols/cpc/api_tracer.go:352–369  ·  view source on GitHub ↗

TraceBlockByNumber returns the structured logs created during the execution of EVM and returns them as a JSON object.

(ctx context.Context, number rpc.BlockNumber, config *TraceConfig)

Source from the content-addressed store, hash-verified

350// TraceBlockByNumber returns the structured logs created during the execution of
351// EVM and returns them as a JSON object.
352func (api *PrivateDebugAPI) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error) {
353 // Fetch the block that we want to trace
354 var block *types.Block
355
356 switch number {
357 case rpc.PendingBlockNumber:
358 block = api.cpc.miner.PendingBlock()
359 case rpc.LatestBlockNumber:
360 block = api.cpc.blockchain.CurrentBlock()
361 default:
362 block = api.cpc.blockchain.GetBlockByNumber(uint64(number))
363 }
364 // Trace the block if it was found
365 if block == nil {
366 return nil, fmt.Errorf("block #%d not found", number)
367 }
368 return api.traceBlock(ctx, block, config)
369}
370
371// TraceBlockByHash returns the structured logs created during the execution of
372// EVM and returns them as a JSON object.

Callers

nothing calls this directly

Calls 4

traceBlockMethod · 0.95
PendingBlockMethod · 0.80
CurrentBlockMethod · 0.65
GetBlockByNumberMethod · 0.65

Tested by

no test coverage detected