core/filtermaps: use rawdb.ReadRawReceipts

pull/30370/head
Zsolt Felfoldi 3 days ago
parent 9ad34e5c69
commit 950de72ed3
  1. 6
      core/filtermaps/filtermaps.go
  2. 6
      core/filtermaps/indexer.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")
}

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

Loading…
Cancel
Save