From 7ffe83e4f1d2158c300a20f7b2a7ac583bb17feb Mon Sep 17 00:00:00 2001 From: msutton Date: Mon, 14 Mar 2022 13:16:13 +0200 Subject: [PATCH] Add the percentage report fix to v4 as well --- app/protocol/flows/v4/blockrelay/ibd_progress_reporter.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/protocol/flows/v4/blockrelay/ibd_progress_reporter.go b/app/protocol/flows/v4/blockrelay/ibd_progress_reporter.go index acb8d8209..3ecc57636 100644 --- a/app/protocol/flows/v4/blockrelay/ibd_progress_reporter.go +++ b/app/protocol/flows/v4/blockrelay/ibd_progress_reporter.go @@ -22,7 +22,12 @@ func newIBDProgressReporter(lowDAAScore uint64, highDAAScore uint64, objectName func (ipr *ibdProgressReporter) reportProgress(processedDelta int, highestProcessedDAAScore uint64) { ipr.processed += processedDelta - + + // Avoid exploding numbers in the percentage report, since the original `highDAAScore` might have been only a hint + if highestProcessedDAAScore > ipr.highDAAScore { + ipr.highDAAScore = highestProcessedDAAScore + 1 // + 1 for keeping it at 99% + ipr.totalDAAScoreDifference = ipr.highDAAScore - ipr.lowDAAScore + } relativeDAAScore := highestProcessedDAAScore - ipr.lowDAAScore progressPercent := int((float64(relativeDAAScore) / float64(ipr.totalDAAScoreDifference)) * 100) if progressPercent > ipr.lastReportedProgressPercent {