mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
core/filtermaps: add database version, enforce log index reset
This commit is contained in:
parent
0663bd7048
commit
eebc7c7fbf
2 changed files with 6 additions and 2 deletions
|
|
@ -50,6 +50,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
databaseVersion = 1 // reindexed if database version does not match
|
||||||
cachedLastBlocks = 1000 // last block of map pointers
|
cachedLastBlocks = 1000 // last block of map pointers
|
||||||
cachedLvPointers = 1000 // first log value pointer of block pointers
|
cachedLvPointers = 1000 // first log value pointer of block pointers
|
||||||
cachedBaseRows = 100 // groups of base layer filter row data
|
cachedBaseRows = 100 // groups of base layer filter row data
|
||||||
|
|
@ -210,8 +211,9 @@ type Config struct {
|
||||||
// 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, historyCutoff, finalBlock uint64, params Params, config Config) *FilterMaps {
|
func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, historyCutoff, finalBlock uint64, params Params, config Config) *FilterMaps {
|
||||||
rs, initialized, err := rawdb.ReadFilterMapsRange(db)
|
rs, initialized, err := rawdb.ReadFilterMapsRange(db)
|
||||||
if err != nil {
|
if err != nil || rs.Version != databaseVersion {
|
||||||
log.Error("Error reading log index range", "error", err)
|
rs, initialized = rawdb.FilterMapsRange{}, false
|
||||||
|
log.Warn("Invalid log index database version; resetting log index")
|
||||||
}
|
}
|
||||||
params.deriveFields()
|
params.deriveFields()
|
||||||
f := &FilterMaps{
|
f := &FilterMaps{
|
||||||
|
|
@ -440,6 +442,7 @@ func (f *FilterMaps) setRange(batch ethdb.KeyValueWriter, newView *ChainView, ne
|
||||||
f.updateMatchersValidRange()
|
f.updateMatchersValidRange()
|
||||||
if newRange.initialized {
|
if newRange.initialized {
|
||||||
rs := rawdb.FilterMapsRange{
|
rs := rawdb.FilterMapsRange{
|
||||||
|
Version: databaseVersion,
|
||||||
HeadIndexed: newRange.headIndexed,
|
HeadIndexed: newRange.headIndexed,
|
||||||
HeadDelimiter: newRange.headDelimiter,
|
HeadDelimiter: newRange.headDelimiter,
|
||||||
BlocksFirst: newRange.blocks.First(),
|
BlocksFirst: newRange.blocks.First(),
|
||||||
|
|
|
||||||
|
|
@ -434,6 +434,7 @@ func DeleteBlockLvPointers(db ethdb.KeyValueStore, blocks common.Range[uint64],
|
||||||
// FilterMapsRange is a storage representation of the block range covered by the
|
// FilterMapsRange is a storage representation of the block range covered by the
|
||||||
// filter maps structure and the corresponting log value index range.
|
// filter maps structure and the corresponting log value index range.
|
||||||
type FilterMapsRange struct {
|
type FilterMapsRange struct {
|
||||||
|
Version uint32
|
||||||
HeadIndexed bool
|
HeadIndexed bool
|
||||||
HeadDelimiter uint64
|
HeadDelimiter uint64
|
||||||
BlocksFirst, BlocksAfterLast uint64
|
BlocksFirst, BlocksAfterLast uint64
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue