mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Merge ba89df28da into f95811e65b
This commit is contained in:
commit
bd55c91179
1 changed files with 15 additions and 3 deletions
|
|
@ -50,6 +50,8 @@ var (
|
||||||
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
|
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
|
||||||
|
|
||||||
ErrNoGenesis = errors.New("Genesis not found in chain")
|
ErrNoGenesis = errors.New("Genesis not found in chain")
|
||||||
|
errGenesisStateIncomplete = errors.New("genesis state is incomplete")
|
||||||
|
errMissingBlock = errors.New("missing block")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -437,8 +439,18 @@ func (bc *BlockChain) repair(head **types.Block) error {
|
||||||
log.Info("Rewound blockchain to past state", "number", (*head).Number(), "hash", (*head).Hash())
|
log.Info("Rewound blockchain to past state", "number", (*head).Number(), "hash", (*head).Hash())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Otherwise rewind one block and recheck state availability there
|
// Abort if the genesis block's state is still incomplete.
|
||||||
(*head) = bc.GetBlock((*head).ParentHash(), (*head).NumberU64()-1)
|
if (*head).NumberU64() == 0 {
|
||||||
|
log.Info("The state of genesis block is incomplete")
|
||||||
|
return errGenesisStateIncomplete
|
||||||
|
}
|
||||||
|
// Rewind one block and recheck state availability there
|
||||||
|
block := bc.GetBlock((*head).ParentHash(), (*head).NumberU64()-1)
|
||||||
|
if block == nil {
|
||||||
|
log.Info("Rewound to a missing block", "number", (*head).NumberU64()-1)
|
||||||
|
return errMissingBlock
|
||||||
|
}
|
||||||
|
*head = block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue