Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-08-05 10:46:20 +08:00
parent ca764d706f
commit d5585fe579

View file

@ -337,11 +337,13 @@ func (db *Database) repairHistory() error {
}
if pruned != 0 {
log.Warn("Truncated extra state histories", "number", pruned)
// Reset the state history index metadata to current state id.
if meta := loadIndexMetadata(db.diskdb); meta != nil {
oldID := meta.Last
log.Warn("Reset state history index metadata after truncation", "oldID", oldID, "newID", id)
storeIndexMetadata(db.diskdb, id)
// Reset the state history index metadata to current state id
// if it's out of boundry.
if old := meta.Last; old > id {
log.Warn("Reset state history index metadata after truncation", "oldID", old, "newID", id)
storeIndexMetadata(db.diskdb, id)
}
}
}
return nil