aboutsummaryrefslogtreecommitdiffstats
path: root/eth/api_backend.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-11-09 10:09:05 +0800
committerGitHub <noreply@github.com>2016-11-09 10:09:05 +0800
commit355f4b0c15fadec683877b5de1361bd678fee28e (patch)
treeef1c3a915af7f07c049c08318fe450b2ecf46654 /eth/api_backend.go
parent8b1df1a259fe6dc4c15e391e9c0762c9621d9d72 (diff)
parentbbb5e5d56a51d9430aec934c76a0bd02f1f2427d (diff)
downloaddexon-355f4b0c15fadec683877b5de1361bd678fee28e.tar
dexon-355f4b0c15fadec683877b5de1361bd678fee28e.tar.gz
dexon-355f4b0c15fadec683877b5de1361bd678fee28e.tar.bz2
dexon-355f4b0c15fadec683877b5de1361bd678fee28e.tar.lz
dexon-355f4b0c15fadec683877b5de1361bd678fee28e.tar.xz
dexon-355f4b0c15fadec683877b5de1361bd678fee28e.tar.zst
dexon-355f4b0c15fadec683877b5de1361bd678fee28e.zip
Merge pull request #3232 from zsfelfoldi/light-topic3
Diffstat (limited to 'eth/api_backend.go')
-rw-r--r--eth/api_backend.go30
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