mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core/filtermaps: add Config struct
This commit is contained in:
parent
274ca31038
commit
e01d8094dd
2 changed files with 20 additions and 6 deletions
|
|
@ -166,8 +166,18 @@ type lastBlockOfMap struct {
|
||||||
id common.Hash
|
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.
|
// 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)
|
rs, initialized, 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)
|
||||||
|
|
@ -180,10 +190,9 @@ func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, params Params, h
|
||||||
targetViewCh: make(chan *ChainView, 1),
|
targetViewCh: make(chan *ChainView, 1),
|
||||||
finalBlockCh: make(chan uint64, 1),
|
finalBlockCh: make(chan uint64, 1),
|
||||||
blockProcessingCh: make(chan bool, 1),
|
blockProcessingCh: make(chan bool, 1),
|
||||||
history: history,
|
history: config.History,
|
||||||
noHistory: noHistory,
|
noHistory: config.NoHistory,
|
||||||
unindexLimit: unindexLimit,
|
exportFileName: config.ExportFileName,
|
||||||
exportFileName: exportFileName,
|
|
||||||
Params: params,
|
Params: params,
|
||||||
indexedRange: filterMapsRange{
|
indexedRange: filterMapsRange{
|
||||||
initialized: initialized,
|
initialized: initialized,
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,12 @@ func (ts *testSetup) setHistory(history uint64, noHistory bool) {
|
||||||
ts.fm.Stop()
|
ts.fm.Stop()
|
||||||
}
|
}
|
||||||
head := ts.chain.CurrentBlock()
|
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.testDisableSnapshots = ts.testDisableSnapshots
|
||||||
ts.fm.Start()
|
ts.fm.Start()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue