mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
fix SetHead func to call repair func
This commit is contained in:
parent
b566cfdffd
commit
934749ecbe
1 changed files with 6 additions and 5 deletions
|
|
@ -400,8 +400,9 @@ func (bc *BlockChain) SetHead(head uint64) error {
|
|||
if newHeadBlock == nil {
|
||||
newHeadBlock = bc.genesisBlock
|
||||
} else {
|
||||
if _, err := state.New(newHeadBlock.Root(), bc.stateCache); err != nil {
|
||||
// Rewound state missing, rolled back to before pivot, reset to genesis
|
||||
err := bc.repair(&newHeadBlock)
|
||||
if err != nil {
|
||||
// Rewound block missing, rolled back to genesis
|
||||
newHeadBlock = bc.genesisBlock
|
||||
}
|
||||
}
|
||||
|
|
@ -868,7 +869,7 @@ func (bc *BlockChain) procFutureBlocks() {
|
|||
type WriteStatus byte
|
||||
|
||||
const (
|
||||
NonStatTy WriteStatus = iota
|
||||
NonStatTy WriteStatus = iota
|
||||
CanonStatTy
|
||||
SideStatTy
|
||||
)
|
||||
|
|
@ -1538,7 +1539,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
|
|||
log.Debug("Pruned ancestor, inserting as sidechain", "number", block.Number(), "hash", block.Hash())
|
||||
return bc.insertSideChain(block, it)
|
||||
|
||||
// First block is future, shove it (and all children) to the future queue (unknown ancestor)
|
||||
// First block is future, shove it (and all children) to the future queue (unknown ancestor)
|
||||
case err == consensus.ErrFutureBlock || (err == consensus.ErrUnknownAncestor && bc.futureBlocks.Contains(it.first().ParentHash())):
|
||||
for block != nil && (it.index == 0 || err == consensus.ErrUnknownAncestor) {
|
||||
log.Debug("Future block, postponing import", "number", block.Number(), "hash", block.Hash())
|
||||
|
|
@ -1553,7 +1554,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
|
|||
// If there are any still remaining, mark as ignored
|
||||
return it.index, events, coalescedLogs, err
|
||||
|
||||
// Some other error occurred, abort
|
||||
// Some other error occurred, abort
|
||||
case err != nil:
|
||||
bc.futureBlocks.Remove(block.Hash())
|
||||
stats.ignored += len(it.chain)
|
||||
|
|
|
|||
Loading…
Reference in a new issue