From 950de72ed3c11da954179fc694fc52858fe77526 Mon Sep 17 00:00:00 2001 From: Zsolt Felfoldi Date: Tue, 17 Sep 2024 09:55:55 +0200 Subject: [PATCH] core/filtermaps: use rawdb.ReadRawReceipts --- core/filtermaps/filtermaps.go | 6 +++--- core/filtermaps/indexer.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/filtermaps/filtermaps.go b/core/filtermaps/filtermaps.go index a265696041..87fec8a0a3 100644 --- a/core/filtermaps/filtermaps.go +++ b/core/filtermaps/filtermaps.go @@ -36,7 +36,7 @@ const ( // https://eips.ethereum.org/EIPS/eip-7745 type FilterMaps struct { lock sync.RWMutex - db ethdb.KeyValueStore + db ethdb.Database closeCh chan chan struct{} filterMapsRange @@ -86,7 +86,7 @@ type filterMapsRange struct { // NewFilterMaps creates a new FilterMaps and starts the indexer in order to keep // the structure in sync with the given blockchain. -func NewFilterMaps(db ethdb.KeyValueStore, chain *core.BlockChain) *FilterMaps { +func NewFilterMaps(db ethdb.Database, chain *core.BlockChain) *FilterMaps { rs, err := rawdb.ReadFilterMapsRange(db) if err != nil { log.Error("Error reading log index range", "error", err) @@ -298,7 +298,7 @@ func (f *FilterMaps) getLogByLvIndex(lvIndex uint64) (*types.Log, error) { } // get block receipts hash := f.chain.GetCanonicalHash(firstBlockNumber) - receipts := f.chain.GetReceiptsByHash(hash) //TODO small cache + receipts := rawdb.ReadRawReceipts(f.db, hash, firstBlockNumber) //TODO small cache if receipts == nil { return nil, errors.New("receipts not found") } diff --git a/core/filtermaps/indexer.go b/core/filtermaps/indexer.go index 789bf4c400..0d050923ee 100644 --- a/core/filtermaps/indexer.go +++ b/core/filtermaps/indexer.go @@ -107,7 +107,7 @@ func (f *FilterMaps) getRange() filterMapsRange { // tryInit attempts to initialize the log index structure. func (f *FilterMaps) tryInit(head *types.Header) { - receipts := f.chain.GetReceiptsByHash(head.Hash()) + receipts := rawdb.ReadRawReceipts(f.db, head.Hash(), head.Number.Uint64()) if receipts == nil { log.Error("Could not retrieve block receipts for init block", "number", head.Number, "hash", head.Hash()) return @@ -176,7 +176,7 @@ func (f *FilterMaps) tryUpdateHead(newHead *types.Header) { update := f.newUpdateBatch() for i := len(newHeaders) - 1; i >= 0; i-- { newHeader := newHeaders[i] - receipts := f.chain.GetReceiptsByHash(newHeader.Hash()) + receipts := rawdb.ReadRawReceipts(f.db, newHeader.Hash(), newHeader.Number.Uint64()) if receipts == nil { log.Error("Could not retrieve block receipts for new block", "number", newHeader.Number, "hash", newHeader.Hash()) break @@ -218,7 +218,7 @@ func (f *FilterMaps) tryExtendTail(stopFn func() bool) { log.Error("Tail header not found", "number", number-1, "hash", parentHash) break } - receipts := f.chain.GetReceiptsByHash(newTail.Hash()) + receipts := rawdb.ReadRawReceipts(f.db, newTail.Hash(), newTail.Number.Uint64()) if receipts == nil { log.Error("Could not retrieve block receipts for tail block", "number", newTail.Number, "hash", newTail.Hash()) break