mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core/filtermaps: remove nil checks for targetView
It can never be nil.
This commit is contained in:
parent
e01d8094dd
commit
608056a34a
3 changed files with 8 additions and 11 deletions
|
|
@ -212,6 +212,8 @@ func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, params Params, c
|
|||
baseRowsCache: lru.NewCache[uint64, [][]uint32](cachedBaseRows),
|
||||
renderSnapshots: lru.NewCache[uint64, *renderedMap](cachedRenderSnapshots),
|
||||
}
|
||||
|
||||
// Set initial indexer target.
|
||||
f.targetView = initView
|
||||
if f.indexedRange.initialized {
|
||||
f.indexedView = f.initChainView(f.targetView)
|
||||
|
|
@ -314,7 +316,7 @@ func (f *FilterMaps) init() error {
|
|||
}
|
||||
}
|
||||
batch := f.db.NewBatch()
|
||||
for epoch := 0; epoch < bestLen; epoch++ {
|
||||
for epoch := range bestLen {
|
||||
cp := checkpoints[bestIdx][epoch]
|
||||
f.storeLastBlockOfMap(batch, (uint32(epoch+1)<<f.logMapsPerEpoch)-1, cp.BlockNumber, cp.BlockId)
|
||||
f.storeBlockLvPointer(batch, cp.BlockNumber, cp.FirstIndex)
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ func (f *FilterMaps) indexerLoop() {
|
|||
// SetTargetView sets a new target chain view for the indexer to render.
|
||||
// Note that SetTargetView never blocks.
|
||||
func (f *FilterMaps) SetTargetView(targetView *ChainView) {
|
||||
if targetView == nil {
|
||||
panic("nil targetView")
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-f.targetViewCh:
|
||||
|
|
@ -175,18 +178,12 @@ func (f *FilterMaps) processSingleEvent(blocking bool) bool {
|
|||
|
||||
// setTargetView updates the target chain view of the iterator.
|
||||
func (f *FilterMaps) setTargetView(targetView *ChainView) {
|
||||
if equalViews(f.targetView, targetView) {
|
||||
return
|
||||
}
|
||||
f.targetView = targetView
|
||||
}
|
||||
|
||||
// tryIndexHead tries to render head maps according to the current targetView
|
||||
// and returns true if successful.
|
||||
func (f *FilterMaps) tryIndexHead() bool {
|
||||
if f.targetView == nil {
|
||||
return false
|
||||
}
|
||||
headRenderer, err := f.renderMapsBefore(math.MaxUint32)
|
||||
if err != nil {
|
||||
log.Error("Error creating log index head renderer", "error", err)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package filtermaps
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
|
@ -26,6 +25,7 @@ import (
|
|||
// FilterMapsMatcherBackend implements MatcherBackend.
|
||||
type FilterMapsMatcherBackend struct {
|
||||
f *FilterMaps
|
||||
|
||||
// these fields should be accessed under f.matchersLock mutex.
|
||||
valid bool
|
||||
firstValid, lastValid uint64
|
||||
|
|
@ -156,11 +156,9 @@ func (fm *FilterMapsMatcherBackend) synced() {
|
|||
// chain since the previous SyncLogIndex or the creation of the matcher backend.
|
||||
func (fm *FilterMapsMatcherBackend) SyncLogIndex(ctx context.Context) (SyncRange, error) {
|
||||
if fm.f.noHistory {
|
||||
if fm.f.targetView == nil {
|
||||
return SyncRange{}, errors.New("canonical chain head not available")
|
||||
}
|
||||
return SyncRange{HeadNumber: fm.f.targetView.headNumber}, nil
|
||||
}
|
||||
|
||||
syncCh := make(chan SyncRange, 1)
|
||||
fm.f.matchersLock.Lock()
|
||||
fm.syncCh = syncCh
|
||||
|
|
|
|||
Loading…
Reference in a new issue