mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
triedb: re init indexer after snap synced
Signed-off-by: Delweng <delweng@gmail.com>
This commit is contained in:
parent
6bc13d8004
commit
537b173506
1 changed files with 11 additions and 0 deletions
|
|
@ -520,6 +520,17 @@ func (db *Database) Enable(root common.Hash) error {
|
|||
// Re-construct a new disk layer backed by persistent state
|
||||
// and schedule the state snapshot generation if it's permitted.
|
||||
db.tree.init(generateSnapshot(db, root, db.isVerkle || db.config.SnapshotNoBuild))
|
||||
|
||||
// After snap sync, the state of the database may have changed completely.
|
||||
// To ensure the history indexer always matches the current state, we must:
|
||||
// 1. Close any existing indexer
|
||||
// 2. Re-initialize the indexer so it starts indexing from the new state root.
|
||||
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("Rebuilt trie database", "root", root)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue