diff options
author | Aaron Buchwald <[email protected]> | 2020-10-16 15:22:23 -0400 |
---|---|---|
committer | Aaron Buchwald <[email protected]> | 2020-10-16 15:22:23 -0400 |
commit | 77a2d0f97f142261a351f0cdcc1d001d0cead4cf (patch) | |
tree | 31b5eb91d754c6c46f8d749d7a08c17d3cc9ec13 /eth/api_tracer.go | |
parent | 3b3cf1aeaa1eb41f64383e2a18c00240ffde7d2b (diff) |
Clean up use of pending/latest meta block numbers
Diffstat (limited to 'eth/api_tracer.go')
-rw-r--r-- | eth/api_tracer.go | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/eth/api_tracer.go b/eth/api_tracer.go index c044dcc..23209de 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -105,26 +105,18 @@ func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end rpc.Block // Fetch the block interval that we want to trace var from, to *types.Block - switch start { - case rpc.PendingBlockNumber: - from = api.eth.miner.PendingBlock() - case rpc.LatestBlockNumber: - from = api.eth.blockchain.CurrentBlock() - case rpc.AcceptedBlockNumber: + if start.IsAccepted() { from = api.eth.AcceptedBlock() - default: + } else { from = api.eth.blockchain.GetBlockByNumber(uint64(start)) } - switch end { - case rpc.PendingBlockNumber: - to = api.eth.miner.PendingBlock() - case rpc.LatestBlockNumber: - to = api.eth.blockchain.CurrentBlock() - case rpc.AcceptedBlockNumber: - from = api.eth.AcceptedBlock() - default: + + if end.IsAccepted() { + to = api.eth.AcceptedBlock() + } else { to = api.eth.blockchain.GetBlockByNumber(uint64(end)) } + // Trace the chain if we've found all our blocks if from == nil { return nil, fmt.Errorf("starting block #%d not found", start) @@ -360,16 +352,12 @@ func (api *PrivateDebugAPI) TraceBlockByNumber(ctx context.Context, number rpc.B // Fetch the block that we want to trace var block *types.Block - switch number { - case rpc.PendingBlockNumber: - block = api.eth.miner.PendingBlock() - case rpc.LatestBlockNumber: - block = api.eth.blockchain.CurrentBlock() - case rpc.AcceptedBlockNumber: + if number.IsAccepted() { block = api.eth.AcceptedBlock() - default: + } else { block = api.eth.blockchain.GetBlockByNumber(uint64(number)) } + // Trace the block if it was found if block == nil { return nil, fmt.Errorf("block #%d not found", number) |