core/filtermaps: use rawdb.ReadRawReceipts

pull/30370/head
Zsolt Felfoldi 2 months ago
parent 3e36b4d56a
commit 9a63c31fd2
  1. 6
      core/filtermaps/filtermaps.go
  2. 6
      core/filtermaps/indexer.go

@ -36,7 +36,7 @@ const (
// https://eips.ethereum.org/EIPS/eip-7745 // https://eips.ethereum.org/EIPS/eip-7745
type FilterMaps struct { type FilterMaps struct {
lock sync.RWMutex lock sync.RWMutex
db ethdb.KeyValueStore db ethdb.Database
closeCh chan chan struct{} closeCh chan chan struct{}
filterMapsRange filterMapsRange
@ -86,7 +86,7 @@ type filterMapsRange struct {
// NewFilterMaps creates a new FilterMaps and starts the indexer in order to keep // NewFilterMaps creates a new FilterMaps and starts the indexer in order to keep
// the structure in sync with the given blockchain. // 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) rs, err := rawdb.ReadFilterMapsRange(db)
if err != nil { if err != nil {
log.Error("Error reading log index range", "error", err) 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 // get block receipts
hash := f.chain.GetCanonicalHash(firstBlockNumber) 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 { if receipts == nil {
return nil, errors.New("receipts not found") return nil, errors.New("receipts not found")
} }

@ -107,7 +107,7 @@ func (f *FilterMaps) getRange() filterMapsRange {
// tryInit attempts to initialize the log index structure. // tryInit attempts to initialize the log index structure.
func (f *FilterMaps) tryInit(head *types.Header) { 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 { if receipts == nil {
log.Error("Could not retrieve block receipts for init block", "number", head.Number, "hash", head.Hash()) log.Error("Could not retrieve block receipts for init block", "number", head.Number, "hash", head.Hash())
return return
@ -176,7 +176,7 @@ func (f *FilterMaps) tryUpdateHead(newHead *types.Header) {
update := f.newUpdateBatch() update := f.newUpdateBatch()
for i := len(newHeaders) - 1; i >= 0; i-- { for i := len(newHeaders) - 1; i >= 0; i-- {
newHeader := newHeaders[i] newHeader := newHeaders[i]
receipts := f.chain.GetReceiptsByHash(newHeader.Hash()) receipts := rawdb.ReadRawReceipts(f.db, newHeader.Hash(), newHeader.Number.Uint64())
if receipts == nil { if receipts == nil {
log.Error("Could not retrieve block receipts for new block", "number", newHeader.Number, "hash", newHeader.Hash()) log.Error("Could not retrieve block receipts for new block", "number", newHeader.Number, "hash", newHeader.Hash())
break break
@ -218,7 +218,7 @@ func (f *FilterMaps) tryExtendTail(stopFn func() bool) {
log.Error("Tail header not found", "number", number-1, "hash", parentHash) log.Error("Tail header not found", "number", number-1, "hash", parentHash)
break break
} }
receipts := f.chain.GetReceiptsByHash(newTail.Hash()) receipts := rawdb.ReadRawReceipts(f.db, newTail.Hash(), newTail.Number.Uint64())
if receipts == nil { if receipts == nil {
log.Error("Could not retrieve block receipts for tail block", "number", newTail.Number, "hash", newTail.Hash()) log.Error("Could not retrieve block receipts for tail block", "number", newTail.Number, "hash", newTail.Hash())
break break

Loading…
Cancel
Save