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_backend.go | |
parent | 841b2b7225a9318718c3c856a9debdf01bc4f061 (diff) |
support "accepted" as block number in JSON-RPC
Diffstat (limited to 'eth/api_backend.go')
-rw-r--r-- | eth/api_backend.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/eth/api_backend.go b/eth/api_backend.go index f4c0101..99556c9 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -21,6 +21,8 @@ import ( "errors" "math/big" + "github.com/ava-labs/coreth/eth/gasprice" + "github.com/ava-labs/coreth/rpc" "github.com/ava-labs/go-ethereum/accounts" "github.com/ava-labs/go-ethereum/common" "github.com/ava-labs/go-ethereum/common/math" @@ -31,11 +33,9 @@ import ( "github.com/ava-labs/go-ethereum/core/types" "github.com/ava-labs/go-ethereum/core/vm" "github.com/ava-labs/go-ethereum/eth/downloader" - "github.com/ava-labs/go-ethereum/eth/gasprice" "github.com/ava-labs/go-ethereum/ethdb" "github.com/ava-labs/go-ethereum/event" "github.com/ava-labs/go-ethereum/params" - "github.com/ava-labs/go-ethereum/rpc" ) // EthAPIBackend implements ethapi.Backend for full nodes @@ -54,6 +54,10 @@ func (b *EthAPIBackend) CurrentBlock() *types.Block { return b.eth.blockchain.CurrentBlock() } +func (b *EthAPIBackend) AcceptedBlock() *types.Block { + return b.eth.AcceptedBlock() +} + func (b *EthAPIBackend) SetHead(number uint64) { b.eth.protocolManager.downloader.Cancel() b.eth.blockchain.SetHead(number) @@ -69,6 +73,9 @@ func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumb if number == rpc.LatestBlockNumber { return b.eth.blockchain.CurrentBlock().Header(), nil } + if number == rpc.AcceptedBlockNumber { + return b.eth.AcceptedBlock().Header(), nil + } return b.eth.blockchain.GetHeaderByNumber(uint64(number)), nil } @@ -86,6 +93,9 @@ func (b *EthAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumbe if number == rpc.LatestBlockNumber { return b.eth.blockchain.CurrentBlock(), nil } + if number == rpc.AcceptedBlockNumber { + return b.eth.AcceptedBlock(), nil + } return b.eth.blockchain.GetBlockByNumber(uint64(number)), nil } |