From 1c41fbad50f9a110195a84c5c8619aa801865728 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Mon, 5 Jul 2021 17:14:16 +0200 Subject: [PATCH] eth: use new readlogs accessor when filtering logs --- eth/api_backend.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/eth/api_backend.go b/eth/api_backend.go index 49de70e21069e..02b8ac897d42d 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -181,13 +181,14 @@ func (b *EthAPIBackend) GetReceipts(ctx context.Context, hash common.Hash) (type } func (b *EthAPIBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) { - receipts := b.eth.blockchain.GetReceiptsByHash(hash) - if receipts == nil { - return nil, nil + db := b.eth.ChainDb() + number := rawdb.ReadHeaderNumber(db, hash) + if number == nil { + return nil, errors.New("failed to get block number from hash") } - logs := make([][]*types.Log, len(receipts)) - for i, receipt := range receipts { - logs[i] = receipt.Logs + logs := rawdb.ReadLogs(db, hash, *number) + if logs == nil { + return nil, errors.New("failed to get logs for block") } return logs, nil }