core: polish code

This commit is contained in:
Gary Rong 2024-03-11 18:32:18 +08:00
parent 60fb704da4
commit b5df29c693

View file

@ -700,8 +700,8 @@ func (bc *BlockChain) rewindPathHead(root common.Hash) (*types.Header, uint64) {
pivot = rawdb.ReadLastPivotNumber(bc.db) // Associated block number of pivot block pivot = rawdb.ReadLastPivotNumber(bc.db) // Associated block number of pivot block
rootNumber uint64 // Associated block number of requested root rootNumber uint64 // Associated block number of requested root
// BeyondRoot represents whether the requested root is already crossed. // BeyondRoot represents whether the requested root is already
// The flag value is set to true if the root is empty. // crossed. The flag value is set to true if the root is empty.
beyondRoot = root == common.Hash{} beyondRoot = root == common.Hash{}
start = time.Now() // Timestamp the rewinding is restarted start = time.Now() // Timestamp the rewinding is restarted
@ -721,10 +721,11 @@ func (bc *BlockChain) rewindPathHead(root common.Hash) (*types.Header, uint64) {
beyondRoot, rootNumber = true, head.Number.Uint64() beyondRoot, rootNumber = true, head.Number.Uint64()
} }
// If the root threshold hasn't been crossed but the available // If the root threshold hasn't been crossed but the available
// state is found, disable root searching if it's regarded // state is reached, quickly determine if the target state is
// impossible to reach. // possible to be reached or not.
if !beyondRoot && bc.HasState(head.Root) { if !beyondRoot && bc.HasState(head.Root) {
beyondRoot = !bc.HasState(root) && !bc.stateRecoverable(root) beyondRoot = !bc.HasState(root) && !bc.stateRecoverable(root)
log.Info("Disable the search for unattainable state", "root", root)
} }
// 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.