core/filtermaps: add Config struct

This commit is contained in:
Felix Lange 2025-03-13 13:06:15 +01:00
parent 274ca31038
commit e01d8094dd
2 changed files with 20 additions and 6 deletions

View file

@ -166,8 +166,18 @@ type lastBlockOfMap struct {
id common.Hash
}
// Config contains the configuration options for NewFilterMaps.
type Config struct {
History uint64 // number of historical blocks to index
NoHistory bool // disables indexing completely
// This option enables the checkpoint JSON file generator.
// If set, the given file will be updated with checkpoint information.
ExportFileName string
}
// NewFilterMaps creates a new FilterMaps and starts the indexer.
func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, params Params, history, unindexLimit uint64, noHistory bool, exportFileName string) *FilterMaps {
func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, params Params, config Config) *FilterMaps {
rs, initialized, err := rawdb.ReadFilterMapsRange(db)
if err != nil {
log.Error("Error reading log index range", "error", err)
@ -180,10 +190,9 @@ func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, params Params, h
targetViewCh: make(chan *ChainView, 1),
finalBlockCh: make(chan uint64, 1),
blockProcessingCh: make(chan bool, 1),
history: history,
noHistory: noHistory,
unindexLimit: unindexLimit,
exportFileName: exportFileName,
history: config.History,
noHistory: config.NoHistory,
exportFileName: config.ExportFileName,
Params: params,
indexedRange: filterMapsRange{
initialized: initialized,

View file

@ -230,7 +230,12 @@ func (ts *testSetup) setHistory(history uint64, noHistory bool) {
ts.fm.Stop()
}
head := ts.chain.CurrentBlock()
ts.fm = NewFilterMaps(ts.db, NewChainView(ts.chain, head.Number.Uint64(), head.Hash()), ts.params, history, 1, noHistory, "")
view := NewChainView(ts.chain, head.Number.Uint64(), head.Hash())
config := Config{
History: history,
NoHistory: noHistory,
}
ts.fm = NewFilterMaps(ts.db, view, ts.params, config)
ts.fm.testDisableSnapshots = ts.testDisableSnapshots
ts.fm.Start()
}