mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
core/filtermaps: add database version, enforce log index reset
This commit is contained in:
parent
756a6f8261
commit
11e654e4d5
2 changed files with 6 additions and 2 deletions
|
|
@ -50,6 +50,7 @@ var (
|
|||
)
|
||||
|
||||
const (
|
||||
databaseVersion = 1 // reindexed if database version does not match
|
||||
cachedLastBlocks = 1000 // last block of map pointers
|
||||
cachedLvPointers = 1000 // first log value pointer of block pointers
|
||||
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.
|
||||
func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, historyCutoff, finalBlock uint64, params Params, config Config) *FilterMaps {
|
||||
rs, initialized, err := rawdb.ReadFilterMapsRange(db)
|
||||
if err != nil {
|
||||
log.Error("Error reading log index range", "error", err)
|
||||
if err != nil || rs.Version != databaseVersion {
|
||||
rs, initialized = rawdb.FilterMapsRange{}, false
|
||||
log.Warn("Invalid log index database version; resetting log index")
|
||||
}
|
||||
params.deriveFields()
|
||||
f := &FilterMaps{
|
||||
|
|
@ -440,6 +442,7 @@ func (f *FilterMaps) setRange(batch ethdb.KeyValueWriter, newView *ChainView, ne
|
|||
f.updateMatchersValidRange()
|
||||
if newRange.initialized {
|
||||
rs := rawdb.FilterMapsRange{
|
||||
Version: databaseVersion,
|
||||
HeadIndexed: newRange.headIndexed,
|
||||
HeadDelimiter: newRange.headDelimiter,
|
||||
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
|
||||
// filter maps structure and the corresponting log value index range.
|
||||
type FilterMapsRange struct {
|
||||
Version uint32
|
||||
HeadIndexed bool
|
||||
HeadDelimiter uint64
|
||||
BlocksFirst, BlocksAfterLast uint64
|
||||
|
|
|
|||
Loading…
Reference in a new issue