blockchain,triedb: avoid checking recoverable twice

This commit is contained in:
weiihann 2025-04-29 17:25:21 +08:00
parent a511553e44
commit 5632a7adde
2 changed files with 3 additions and 4 deletions

View file

@ -867,6 +867,9 @@ func (bc *BlockChain) rewindPathHead(head *types.Header, root common.Hash) (*typ
}
// Recover if the target state if it's not available yet.
if !bc.HasState(head.Root) {
if !bc.stateRecoverable(head.Root) {
log.Crit("State is unrecoverable, failed to rollback")
}
if err := bc.triedb.Recover(head.Root); err != nil {
log.Crit("Failed to rollback state", "err", err)
}

View file

@ -430,10 +430,6 @@ func (db *Database) Recover(root common.Hash) error {
if db.freezer == nil {
return errors.New("state rollback is non-supported")
}
// Short circuit if the target state is not recoverable
if !db.Recoverable(root) {
return errStateUnrecoverable
}
// Apply the state histories upon the disk layer in order
var (
start = time.Now()