|
|
@ -1501,18 +1501,20 @@ func (d *Downloader) processHeaders(origin uint64, pivot uint64, td *big.Int) er |
|
|
|
rollbackErr = err |
|
|
|
rollbackErr = err |
|
|
|
|
|
|
|
|
|
|
|
// If some headers were inserted, track them as uncertain
|
|
|
|
// If some headers were inserted, track them as uncertain
|
|
|
|
if n > 0 && rollback == 0 { |
|
|
|
if (mode == FastSync || frequency > 1) && n > 0 && rollback == 0 { |
|
|
|
rollback = chunk[0].Number.Uint64() |
|
|
|
rollback = chunk[0].Number.Uint64() |
|
|
|
} |
|
|
|
} |
|
|
|
log.Debug("Invalid header encountered", "number", chunk[n].Number, "hash", chunk[n].Hash(), "parent", chunk[n].ParentHash, "err", err) |
|
|
|
log.Warn("Invalid header encountered", "number", chunk[n].Number, "hash", chunk[n].Hash(), "parent", chunk[n].ParentHash, "err", err) |
|
|
|
return fmt.Errorf("%w: %v", errInvalidChain, err) |
|
|
|
return fmt.Errorf("%w: %v", errInvalidChain, err) |
|
|
|
} |
|
|
|
} |
|
|
|
// All verifications passed, track all headers within the alloted limits
|
|
|
|
// All verifications passed, track all headers within the alloted limits
|
|
|
|
head := chunk[len(chunk)-1].Number.Uint64() |
|
|
|
if mode == FastSync { |
|
|
|
if head-rollback > uint64(fsHeaderSafetyNet) { |
|
|
|
head := chunk[len(chunk)-1].Number.Uint64() |
|
|
|
rollback = head - uint64(fsHeaderSafetyNet) |
|
|
|
if head-rollback > uint64(fsHeaderSafetyNet) { |
|
|
|
} else { |
|
|
|
rollback = head - uint64(fsHeaderSafetyNet) |
|
|
|
rollback = 1 |
|
|
|
} else { |
|
|
|
|
|
|
|
rollback = 1 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Unless we're doing light chains, schedule the headers for associated content retrieval
|
|
|
|
// Unless we're doing light chains, schedule the headers for associated content retrieval
|
|
|
|