mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
core/filtermaps: fix log value search range
This commit is contained in:
parent
7612872761
commit
17676e5ff9
2 changed files with 16 additions and 7 deletions
|
|
@ -662,15 +662,11 @@ func (f *FilterMaps) mapRowIndex(mapIndex, rowIndex uint32) uint64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// getBlockLvPointer returns the starting log value index where the log values
|
// getBlockLvPointer returns the starting log value index where the log values
|
||||||
// generated by the given block are located. If blockNumber is beyond the current
|
// generated by the given block are located.
|
||||||
// head then the first unoccupied log value index is returned.
|
|
||||||
//
|
//
|
||||||
// Note that this function assumes that the indexer read lock is being held when
|
// Note that this function assumes that the indexer read lock is being held when
|
||||||
// called from outside the indexerLoop goroutine.
|
// called from outside the indexerLoop goroutine.
|
||||||
func (f *FilterMaps) getBlockLvPointer(blockNumber uint64) (uint64, error) {
|
func (f *FilterMaps) getBlockLvPointer(blockNumber uint64) (uint64, error) {
|
||||||
if blockNumber >= f.indexedRange.blocks.AfterLast() && f.indexedRange.headIndexed {
|
|
||||||
return f.indexedRange.headDelimiter + 1, nil
|
|
||||||
}
|
|
||||||
if lvPointer, ok := f.lvPointerCache.Get(blockNumber); ok {
|
if lvPointer, ok := f.lvPointerCache.Get(blockNumber); ok {
|
||||||
return lvPointer, nil
|
return lvPointer, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,13 +82,26 @@ func (fm *FilterMapsMatcherBackend) GetFilterMapRow(ctx context.Context, mapInde
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockLvPointer returns the starting log value index where the log values
|
// GetBlockLvPointer returns the starting log value index where the log values
|
||||||
// generated by the given block are located. If blockNumber is beyond the current
|
// generated by the given block are located. If blockNumber is beyond the last
|
||||||
// head then the first unoccupied log value index is returned.
|
// indexed block then the pointer will point right after this block, ensuring
|
||||||
|
// that the matcher does not fail and can return a set of results where the
|
||||||
|
// valid range is correct.
|
||||||
// GetBlockLvPointer implements MatcherBackend.
|
// GetBlockLvPointer implements MatcherBackend.
|
||||||
func (fm *FilterMapsMatcherBackend) GetBlockLvPointer(ctx context.Context, blockNumber uint64) (uint64, error) {
|
func (fm *FilterMapsMatcherBackend) GetBlockLvPointer(ctx context.Context, blockNumber uint64) (uint64, error) {
|
||||||
fm.f.indexLock.RLock()
|
fm.f.indexLock.RLock()
|
||||||
defer fm.f.indexLock.RUnlock()
|
defer fm.f.indexLock.RUnlock()
|
||||||
|
|
||||||
|
if blockNumber >= fm.f.indexedRange.blocks.AfterLast() {
|
||||||
|
if fm.f.indexedRange.headIndexed {
|
||||||
|
// return index after head block
|
||||||
|
return fm.f.indexedRange.headDelimiter + 1, nil
|
||||||
|
}
|
||||||
|
if fm.f.indexedRange.blocks.Count() > 0 {
|
||||||
|
// return index at the beginning of the last, partially indexed
|
||||||
|
// block (after the last fully indexed one)
|
||||||
|
blockNumber = fm.f.indexedRange.blocks.Last()
|
||||||
|
}
|
||||||
|
}
|
||||||
return fm.f.getBlockLvPointer(blockNumber)
|
return fm.f.getBlockLvPointer(blockNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue