mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 12:16:44 +00:00
core: export stateRecoverable
This commit is contained in:
parent
f78f04a604
commit
593b9d82bb
2 changed files with 7 additions and 13 deletions
|
|
@ -913,7 +913,7 @@ func (bc *BlockChain) rewindPathHead(head *types.Header, root common.Hash) (*typ
|
||||||
|
|
||||||
// noState represents if the target state requested for search
|
// noState represents if the target state requested for search
|
||||||
// is unavailable and impossible to be recovered.
|
// is unavailable and impossible to be recovered.
|
||||||
noState = !bc.HasState(root) && !bc.stateRecoverable(root)
|
noState = !bc.HasState(root) && !bc.StateRecoverable(root)
|
||||||
|
|
||||||
start = time.Now() // Timestamp the rewinding is restarted
|
start = time.Now() // Timestamp the rewinding is restarted
|
||||||
logged = time.Now() // Timestamp last progress log was printed
|
logged = time.Now() // Timestamp last progress log was printed
|
||||||
|
|
@ -940,7 +940,7 @@ func (bc *BlockChain) rewindPathHead(head *types.Header, root common.Hash) (*typ
|
||||||
}
|
}
|
||||||
// Check if the associated state is available or recoverable if
|
// Check if the associated state is available or recoverable if
|
||||||
// the requested root has already been crossed.
|
// the requested root has already been crossed.
|
||||||
if beyondRoot && (bc.HasState(head.Root) || bc.stateRecoverable(head.Root)) {
|
if beyondRoot && (bc.HasState(head.Root) || bc.StateRecoverable(head.Root)) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// If pivot block is reached, return the genesis block as the
|
// If pivot block is reached, return the genesis block as the
|
||||||
|
|
@ -1109,7 +1109,7 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, time uint64, root common.Ha
|
||||||
// rewinding a large number of blocks.
|
// rewinding a large number of blocks.
|
||||||
if newHeadBlock := bc.CurrentBlock(); !bc.HasState(newHeadBlock.Root) {
|
if newHeadBlock := bc.CurrentBlock(); !bc.HasState(newHeadBlock.Root) {
|
||||||
switch {
|
switch {
|
||||||
case bc.stateRecoverable(newHeadBlock.Root):
|
case bc.StateRecoverable(newHeadBlock.Root):
|
||||||
if err := bc.triedb.Recover(newHeadBlock.Root); err != nil {
|
if err := bc.triedb.Recover(newHeadBlock.Root); err != nil {
|
||||||
// The state was confirmed recoverable just above, so a failure here
|
// The state was confirmed recoverable just above, so a failure here
|
||||||
// can only stem from an unexpected I/O error. There is no safe way to
|
// can only stem from an unexpected I/O error. There is no safe way to
|
||||||
|
|
@ -2416,7 +2416,7 @@ func (bc *BlockChain) insertSideChain(ctx context.Context, block *types.Block, i
|
||||||
)
|
)
|
||||||
parent := it.previous()
|
parent := it.previous()
|
||||||
for parent != nil && !bc.HasState(parent.Root) {
|
for parent != nil && !bc.HasState(parent.Root) {
|
||||||
if bc.stateRecoverable(parent.Root) {
|
if bc.StateRecoverable(parent.Root) {
|
||||||
if err := bc.triedb.Recover(parent.Root); err != nil {
|
if err := bc.triedb.Recover(parent.Root); err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
|
@ -2478,7 +2478,7 @@ func (bc *BlockChain) recoverAncestors(ctx context.Context, block *types.Block,
|
||||||
parent = block
|
parent = block
|
||||||
)
|
)
|
||||||
for parent != nil && !bc.HasState(parent.Root()) {
|
for parent != nil && !bc.HasState(parent.Root()) {
|
||||||
if bc.stateRecoverable(parent.Root()) {
|
if bc.StateRecoverable(parent.Root()) {
|
||||||
if err := bc.triedb.Recover(parent.Root()); err != nil {
|
if err := bc.triedb.Recover(parent.Root()); err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -395,11 +395,11 @@ func (bc *BlockChain) HasBlockAndState(hash common.Hash, number uint64) bool {
|
||||||
return bc.HasState(block.Root())
|
return bc.HasState(block.Root())
|
||||||
}
|
}
|
||||||
|
|
||||||
// stateRecoverable checks if the specified state is recoverable.
|
// StateRecoverable checks if the specified state is recoverable.
|
||||||
// Note, this function assumes the state is not present, because
|
// Note, this function assumes the state is not present, because
|
||||||
// state is not treated as recoverable if it's available, thus
|
// state is not treated as recoverable if it's available, thus
|
||||||
// false will be returned in this case.
|
// false will be returned in this case.
|
||||||
func (bc *BlockChain) stateRecoverable(root common.Hash) bool {
|
func (bc *BlockChain) StateRecoverable(root common.Hash) bool {
|
||||||
if bc.triedb.Scheme() == rawdb.HashScheme {
|
if bc.triedb.Scheme() == rawdb.HashScheme {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -407,12 +407,6 @@ func (bc *BlockChain) stateRecoverable(root common.Hash) bool {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// StateRecoverable checks if the specified state is recoverable by applying
|
|
||||||
// state histories on top of the persistent state.
|
|
||||||
func (bc *BlockChain) StateRecoverable(root common.Hash) bool {
|
|
||||||
return bc.stateRecoverable(root)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContractCodeWithPrefix retrieves a blob of data associated with a contract
|
// ContractCodeWithPrefix retrieves a blob of data associated with a contract
|
||||||
// hash either from ephemeral in-memory cache, or from persistent storage.
|
// hash either from ephemeral in-memory cache, or from persistent storage.
|
||||||
func (bc *BlockChain) ContractCodeWithPrefix(hash common.Hash) []byte {
|
func (bc *BlockChain) ContractCodeWithPrefix(hash common.Hash) []byte {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue