mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
triedb: manually truncate ancient db
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
cbf0b5bc92
commit
f5183eb1db
2 changed files with 17 additions and 4 deletions
|
|
@ -280,6 +280,17 @@ func (db *Database) Recover(target common.Hash) error {
|
||||||
return pdb.Recover(target)
|
return pdb.Recover(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TruncateHead truncates all state histories in the freezer above the bottom state layer.
|
||||||
|
// This operation is only supported by path-based database It's typically used during
|
||||||
|
// state recovery to align the state histories with the current state.
|
||||||
|
func (db *Database) TruncateHead() error {
|
||||||
|
pdb, ok := db.backend.(*pathdb.Database)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not supported")
|
||||||
|
}
|
||||||
|
return pdb.TruncateHead()
|
||||||
|
}
|
||||||
|
|
||||||
// Recoverable returns the indicator if the specified state is enabled to be
|
// Recoverable returns the indicator if the specified state is enabled to be
|
||||||
// recovered. It's only supported by path-based database and will return an
|
// recovered. It's only supported by path-based database and will return an
|
||||||
// error for others.
|
// error for others.
|
||||||
|
|
|
||||||
|
|
@ -502,14 +502,16 @@ func (db *Database) Recover(root common.Hash) error {
|
||||||
if err := db.diskdb.SyncKeyValue(); err != nil {
|
if err := db.diskdb.SyncKeyValue(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err := truncateFromHead(db.stateFreezer, dl.stateID())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Debug("Recovered state", "root", root, "elapsed", common.PrettyDuration(time.Since(start)))
|
log.Debug("Recovered state", "root", root, "elapsed", common.PrettyDuration(time.Since(start)))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TruncateHead truncates all state histories in the freezer above the bottom state layer.
|
||||||
|
func (db *Database) TruncateHead() error {
|
||||||
|
_, err := truncateFromHead(db.stateFreezer, db.tree.bottom().stateID())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Recoverable returns the indicator if the specified state is recoverable.
|
// Recoverable returns the indicator if the specified state is recoverable.
|
||||||
//
|
//
|
||||||
// The supplied root must be a valid trie hash value.
|
// The supplied root must be a valid trie hash value.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue