mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
triedb/pathdb: persist the zero indexing tracker
This commit is contained in:
parent
537b173506
commit
3b50a5e27e
2 changed files with 13 additions and 3 deletions
|
|
@ -528,9 +528,8 @@ func (db *Database) Enable(root common.Hash) error {
|
|||
if db.indexer != nil && db.freezer != nil && db.config.EnableStateIndexing {
|
||||
db.indexer.close()
|
||||
db.indexer = newHistoryIndexer(db.diskdb, db.freezer, db.tree.bottom().stateID())
|
||||
log.Info("Enabled state history indexing (after snap sync)")
|
||||
log.Info("Re-enabled state history indexing")
|
||||
}
|
||||
|
||||
log.Info("Rebuilt trie database", "root", root)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -494,7 +494,18 @@ func (i *indexIniter) index(done chan struct{}, interrupt *atomic.Int32, lastID
|
|||
// when the state is reverted manually (chain.SetHead) or the deep reorg is
|
||||
// encountered. In such cases, no indexing should be scheduled.
|
||||
if beginID > lastID {
|
||||
log.Debug("State history is fully indexed", "last", lastID)
|
||||
if lastID == 0 && beginID == 1 {
|
||||
// Initialize the indexing flag if the state history is empty by
|
||||
// using zero as the disk layer ID. This is a common case that
|
||||
// can occur after snap sync.
|
||||
//
|
||||
// This step is essential to avoid spinning up indexing thread
|
||||
// endlessly until a history object is produced.
|
||||
storeIndexMetadata(i.disk, 0)
|
||||
log.Info("Initialized history indexing flag")
|
||||
} else {
|
||||
log.Debug("State history is fully indexed", "last", lastID)
|
||||
}
|
||||
return
|
||||
}
|
||||
log.Info("Start history indexing", "beginID", beginID, "lastID", lastID)
|
||||
|
|
|
|||
Loading…
Reference in a new issue