aboutsummaryrefslogtreecommitdiffstats
path: root/les/api_backend.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-05-07 19:35:06 +0800
committerGitHub <noreply@github.com>2018-05-07 19:35:06 +0800
commit6cf0ab38bd0af77d81aad4c104979cebee9e3e63 (patch)
tree142d6f965c44dcf9e2182da67b7bbc978c573448 /les/api_backend.go
parent5463ed99968bf71685a2a8ee9dbf8705912f00cb (diff)
downloadgo-tangerine-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar
go-tangerine-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.gz
go-tangerine-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.bz2
go-tangerine-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.lz
go-tangerine-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.xz
go-tangerine-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.zst
go-tangerine-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.zip
core/rawdb: separate raw database access to own package (#16666)
Diffstat (limited to 'les/api_backend.go')
-rw-r--r--les/api_backend.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/les/api_backend.go b/les/api_backend.go
index 3fc5c33a4..1d3c99513 100644
--- a/les/api_backend.go
+++ b/les/api_backend.go
@@ -25,6 +25,7 @@ import (
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/bloombits"
+ "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
@@ -83,16 +84,22 @@ func (b *LesApiBackend) GetBlock(ctx context.Context, blockHash common.Hash) (*t
return b.eth.blockchain.GetBlockByHash(ctx, blockHash)
}
-func (b *LesApiBackend) GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error) {
- return light.GetBlockReceipts(ctx, b.eth.odr, blockHash, core.GetBlockNumber(b.eth.chainDb, blockHash))
+func (b *LesApiBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
+ if number := rawdb.ReadHeaderNumber(b.eth.chainDb, hash); number != nil {
+ return light.GetBlockReceipts(ctx, b.eth.odr, hash, *number)
+ }
+ return nil, nil
}
-func (b *LesApiBackend) GetLogs(ctx context.Context, blockHash common.Hash) ([][]*types.Log, error) {
- return light.GetBlockLogs(ctx, b.eth.odr, blockHash, core.GetBlockNumber(b.eth.chainDb, blockHash))
+func (b *LesApiBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
+ if number := rawdb.ReadHeaderNumber(b.eth.chainDb, hash); number != nil {
+ return light.GetBlockLogs(ctx, b.eth.odr, hash, *number)
+ }
+ return nil, nil
}
-func (b *LesApiBackend) GetTd(blockHash common.Hash) *big.Int {
- return b.eth.blockchain.GetTdByHash(blockHash)
+func (b *LesApiBackend) GetTd(hash common.Hash) *big.Int {
+ return b.eth.blockchain.GetTdByHash(hash)
}
func (b *LesApiBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error) {