diff options
Diffstat (limited to 'eth/api_backend.go')
-rw-r--r-- | eth/api_backend.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/eth/api_backend.go b/eth/api_backend.go index 42b84bf9b..efe9a7a01 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -1,18 +1,18 @@ // Copyright 2015 The go-ethereum Authors -// This file is part of go-ethereum. +// This file is part of the go-ethereum library. // -// go-ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // -// go-ethereum is distributed in the hope that it will be useful, +// The go-ethereum library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. +// GNU Lesser General Public License for more details. // -// You should have received a copy of the GNU General Public License -// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. package eth @@ -44,17 +44,17 @@ func (b *EthApiBackend) SetHead(number uint64) { b.eth.blockchain.SetHead(number) } -func (b *EthApiBackend) HeaderByNumber(blockNr rpc.BlockNumber) *types.Header { +func (b *EthApiBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) { // Pending block is only known by the miner if blockNr == rpc.PendingBlockNumber { block, _ := b.eth.miner.Pending() - return block.Header() + return block.Header(), nil } // Otherwise resolve and return the block if blockNr == rpc.LatestBlockNumber { - return b.eth.blockchain.CurrentBlock().Header() + return b.eth.blockchain.CurrentBlock().Header(), nil } - return b.eth.blockchain.GetHeaderByNumber(uint64(blockNr)) + return b.eth.blockchain.GetHeaderByNumber(uint64(blockNr)), nil } func (b *EthApiBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error) { @@ -70,16 +70,16 @@ func (b *EthApiBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumb return b.eth.blockchain.GetBlockByNumber(uint64(blockNr)), nil } -func (b *EthApiBackend) StateAndHeaderByNumber(blockNr rpc.BlockNumber) (ethapi.State, *types.Header, error) { +func (b *EthApiBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (ethapi.State, *types.Header, error) { // Pending state is only known by the miner if blockNr == rpc.PendingBlockNumber { block, state := b.eth.miner.Pending() return EthApiState{state}, block.Header(), nil } // Otherwise resolve the block number and return its state - header := b.HeaderByNumber(blockNr) - if header == nil { - return nil, nil, nil + header, err := b.HeaderByNumber(ctx, blockNr) + if header == nil || err != nil { + return nil, nil, err } stateDb, err := b.eth.BlockChain().StateAt(header.Root) return EthApiState{stateDb}, header, err |