core/filtermaps: use rawdb.ReadRawReceipts

This commit is contained in:
Zsolt Felfoldi 2024-09-17 09:55:55 +02:00
parent 3e36b4d56a
commit 9a63c31fd2
2 changed files with 6 additions and 6 deletions

View File

@ -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")
}

View File

@ -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