Fix for goerli resync (#5269)

* Fix for goerli resync

* Fix

* Fix lint

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
ledgerwatch 2022-09-04 14:51:36 +01:00 committed by GitHub
parent c9ae7310e9
commit da90c9752e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -412,10 +412,10 @@ func (cs *MultiClient) blockHeaders(ctx context.Context, pkt eth.BlockHeadersPac
if cs.Hd.POSSync() {
sort.Sort(headerdownload.HeadersReverseSort(csHeaders)) // Sorting by reverse order of block heights
tx, err := cs.db.BeginRo(ctx)
defer tx.Rollback()
if err != nil {
return err
}
defer tx.Rollback()
penalties, err := cs.Hd.ProcessHeadersPOS(csHeaders, tx, ConvertH512ToPeerID(peerID))
if err != nil {
return err

View File

@ -968,10 +968,16 @@ func (br *BlockRetire) Result() *BlockRetireResult {
return r
}
func CanRetire(curBlockNum uint64, snapshots *RoSnapshots) (blockFrom, blockTo uint64, can bool) {
if curBlockNum <= params.FullImmutabilityThreshold {
return
}
blockFrom = snapshots.BlocksAvailable() + 1
return canRetire(blockFrom, curBlockNum-params.FullImmutabilityThreshold)
}
func canRetire(from, to uint64) (blockFrom, blockTo uint64, can bool) {
if to <= from {
return
}
blockFrom = (from / 1_000) * 1_000
roundedTo1K := (to / 1_000) * 1_000
var maxJump uint64 = 1_000