Skip to content

Commit b82b409

Browse files
committed
eth: use new readlogs accessor when filtering logs
1 parent f02bfcf commit b82b409

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

eth/api_backend.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,14 @@ func (b *EthAPIBackend) GetReceipts(ctx context.Context, hash common.Hash) (type
181181
}
182182

183183
func (b *EthAPIBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
184-
receipts := b.eth.blockchain.GetReceiptsByHash(hash)
185-
if receipts == nil {
186-
return nil, nil
184+
db := b.eth.ChainDb()
185+
number := rawdb.ReadHeaderNumber(db, hash)
186+
if number == nil {
187+
return nil, errors.New("failed to get block number from hash")
187188
}
188-
logs := make([][]*types.Log, len(receipts))
189-
for i, receipt := range receipts {
190-
logs[i] = receipt.Logs
189+
logs := rawdb.ReadLogs(db, hash, *number)
190+
if logs == nil {
191+
return nil, errors.New("failed to get logs for block")
191192
}
192193
return logs, nil
193194
}

0 commit comments

Comments
 (0)