mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
blockchain,triedb: avoid checking recoverable twice
This commit is contained in:
parent
a511553e44
commit
5632a7adde
2 changed files with 3 additions and 4 deletions
|
|
@ -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.
|
// Recover if the target state if it's not available yet.
|
||||||
if !bc.HasState(head.Root) {
|
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 {
|
if err := bc.triedb.Recover(head.Root); err != nil {
|
||||||
log.Crit("Failed to rollback state", "err", err)
|
log.Crit("Failed to rollback state", "err", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -430,10 +430,6 @@ func (db *Database) Recover(root common.Hash) error {
|
||||||
if db.freezer == nil {
|
if db.freezer == nil {
|
||||||
return errors.New("state rollback is non-supported")
|
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
|
// Apply the state histories upon the disk layer in order
|
||||||
var (
|
var (
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue