eth/filters: fixed errors after rebase

This commit is contained in:
Zsolt Felfoldi 2025-03-14 11:00:34 +01:00
parent c27586d55a
commit 0ca476b13f
3 changed files with 20 additions and 14 deletions

View file

@ -248,7 +248,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
return nil, err
}
eth.bloomIndexer.Start(eth.blockchain)
eth.filterMaps = filtermaps.NewFilterMaps(chainDb, eth.newChainView(eth.blockchain.CurrentBlock()), filtermaps.DefaultParams, config.LogHistory, 1000, config.LogNoHistory, config.LogExportCheckpoints)
fmConfig := filtermaps.Config{History: config.LogHistory, Disabled: config.LogNoHistory, ExportFileName: config.LogExportCheckpoints}
chainView := eth.newChainView(eth.blockchain.CurrentBlock())
eth.filterMaps = filtermaps.NewFilterMaps(chainDb, chainView, 0, 0, filtermaps.DefaultParams, fmConfig)
eth.closeFilterMaps = make(chan chan struct{})
if config.BlobPool.Datadir != "" {
@ -436,25 +438,23 @@ func (s *Ethereum) updateFilterMapsHeads() {
}
}()
head := s.blockchain.CurrentBlock()
s.filterMaps.SetTargetView(s.newChainView(head))
var lastFinalBlock uint64
var head *types.Header
setHead := func(newHead *types.Header) {
if newHead == nil {
return
}
if head == nil || newHead.Hash() != head.Hash() {
head = newHead
s.filterMaps.SetTargetView(s.newChainView(head))
}
chainView := s.newChainView(head)
historyCutoff := s.blockchain.HistoryPruningCutoff()
var finalBlock uint64
if fb := s.blockchain.CurrentFinalBlock(); fb != nil {
if finalBlock := fb.Number.Uint64(); finalBlock != lastFinalBlock {
s.filterMaps.SetFinalBlock(finalBlock)
lastFinalBlock = finalBlock
}
finalBlock = fb.Number.Uint64()
}
s.filterMaps.SetTarget(chainView, historyCutoff, finalBlock)
}
}
setHead(s.blockchain.CurrentBlock())
for {
select {

View file

@ -158,9 +158,15 @@ func (b *testBackend) NewMatcherBackend() filtermaps.MatcherBackend {
return b.fm.NewMatcherBackend()
}
func (b *testBackend) startFilterMaps(history uint64, noHistory bool, params filtermaps.Params) {
func (b *testBackend) startFilterMaps(history uint64, disabled bool, params filtermaps.Params) {
head := b.CurrentBlock()
b.fm = filtermaps.NewFilterMaps(b.db, filtermaps.NewChainView(b, head.Number.Uint64(), head.Hash()), params, history, 1, noHistory, "")
chainView := filtermaps.NewChainView(b, head.Number.Uint64(), head.Hash())
config := filtermaps.Config{
History: history,
Disabled: disabled,
ExportFileName: "",
}
b.fm = filtermaps.NewFilterMaps(b.db, chainView, 0, 0, params, config)
b.fm.Start()
b.fm.WaitIdle()
}

View file

@ -476,7 +476,7 @@ func TestRangeLogs(t *testing.T) {
updateHead := func() {
head := bc.CurrentBlock()
backend.fm.SetTargetView(filtermaps.NewChainView(backend, head.Number.Uint64(), head.Hash()))
backend.fm.SetTarget(filtermaps.NewChainView(backend, head.Number.Uint64(), head.Hash()), 0, 0)
backend.fm.WaitIdle()
}