diff options
author | Determinant <[email protected]> | 2019-10-01 13:28:55 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-10-01 13:28:55 -0400 |
commit | bc43122f54ed8de21f74ee6393549c9554d732e8 (patch) | |
tree | 549fffb8771dd280b29eec1e8691e67eb4b24895 /eth/api_tracer.go | |
parent | 841b2b7225a9318718c3c856a9debdf01bc4f061 (diff) |
support "accepted" as block number in JSON-RPC
Diffstat (limited to 'eth/api_tracer.go')
-rw-r--r-- | eth/api_tracer.go | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 618e7c8..b87a9fe 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -28,6 +28,8 @@ import ( "sync" "time" + "github.com/ava-labs/coreth/internal/ethapi" + myrpc "github.com/ava-labs/coreth/rpc" "github.com/ava-labs/go-ethereum/common" "github.com/ava-labs/go-ethereum/common/hexutil" "github.com/ava-labs/go-ethereum/core" @@ -36,7 +38,6 @@ import ( "github.com/ava-labs/go-ethereum/core/types" "github.com/ava-labs/go-ethereum/core/vm" "github.com/ava-labs/go-ethereum/eth/tracers" - "github.com/ava-labs/coreth/internal/ethapi" "github.com/ava-labs/go-ethereum/log" "github.com/ava-labs/go-ethereum/rlp" "github.com/ava-labs/go-ethereum/rpc" @@ -101,23 +102,27 @@ type txTraceTask struct { // TraceChain returns the structured logs created during the execution of EVM // between two blocks (excluding start) and returns them as a JSON object. -func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error) { +func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end myrpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error) { // Fetch the block interval that we want to trace var from, to *types.Block switch start { - case rpc.PendingBlockNumber: + case myrpc.PendingBlockNumber: from = api.eth.miner.PendingBlock() - case rpc.LatestBlockNumber: + case myrpc.LatestBlockNumber: from = api.eth.blockchain.CurrentBlock() + case myrpc.AcceptedBlockNumber: + from = api.eth.AcceptedBlock() default: from = api.eth.blockchain.GetBlockByNumber(uint64(start)) } switch end { - case rpc.PendingBlockNumber: + case myrpc.PendingBlockNumber: to = api.eth.miner.PendingBlock() - case rpc.LatestBlockNumber: + case myrpc.LatestBlockNumber: to = api.eth.blockchain.CurrentBlock() + case myrpc.AcceptedBlockNumber: + from = api.eth.AcceptedBlock() default: to = api.eth.blockchain.GetBlockByNumber(uint64(end)) } @@ -352,15 +357,17 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl // TraceBlockByNumber returns the structured logs created during the execution of // EVM and returns them as a JSON object. -func (api *PrivateDebugAPI) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error) { +func (api *PrivateDebugAPI) TraceBlockByNumber(ctx context.Context, number myrpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error) { // Fetch the block that we want to trace var block *types.Block switch number { - case rpc.PendingBlockNumber: + case myrpc.PendingBlockNumber: block = api.eth.miner.PendingBlock() - case rpc.LatestBlockNumber: + case myrpc.LatestBlockNumber: block = api.eth.blockchain.CurrentBlock() + case myrpc.AcceptedBlockNumber: + block = api.eth.AcceptedBlock() default: block = api.eth.blockchain.GetBlockByNumber(uint64(number)) } |