bugfix: truncate header sync percentage#935
Open
arejula27 wants to merge 1 commit into
Open
Conversation
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process. |
luke-jr
reviewed
Apr 10, 2026
Comment on lines
+168
to
+171
| double pct = 100.0 * bestHeaderHeight / (bestHeaderHeight + est_headers_left); | ||
| // Truncate to one decimal place to avoid displaying 100.0% when headers are still missing | ||
| pct = std::floor(pct * 10.0) / 10.0; | ||
| ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1, %2%)…").arg(bestHeaderHeight).arg(QString::number(pct, 'f', 1))); |
Member
There was a problem hiding this comment.
Suggested change
| double pct = 100.0 * bestHeaderHeight / (bestHeaderHeight + est_headers_left); | |
| // Truncate to one decimal place to avoid displaying 100.0% when headers are still missing | |
| pct = std::floor(pct * 10.0) / 10.0; | |
| ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1, %2%)…").arg(bestHeaderHeight).arg(QString::number(pct, 'f', 1))); | |
| const int pct = bestHeaderHeight ? static_cast<int>(1000LL * bestHeaderHeight / (bestHeaderHeight + est_headers_left)) : 0; | |
| ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1, %2%)…").arg(bestHeaderHeight).arg(QStringLiteral("%1.%2").arg(pct / 10).arg(pct % 10))); |
Author
There was a problem hiding this comment.
Good one, i guess it is more efficient as we do not work with floats, right?
luke-jr
added a commit
to bitcoinknots/bitcoin
that referenced
this pull request
Apr 13, 2026
…e stale Github-Pull: bitcoin-core/gui#935 Rewritten-From: 13b1c9dc4cf5d3e297ee5487dba5f587af8583d3 (plus logged percentages)
13b1c9d to
a3dac13
Compare
Member
|
@hebasto can you add a bug label to this PR and other bug fixes? That makes it easier to track them (e.g. with RSS feed). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
During IBD, if
LoadingBlocks()is true (e.g. during a chainstate rebuild after a crash), the node rejects incoming headers from peers. The GUI has headers loaded from the block index on disk, butbestHeaderDatebecomes stale over time.After ~4 hours (
HEADER_HEIGHT_DELTA_SYNC * nPowTargetSpacing), the time-based heuristic inmodaloverlay.cppconsiders headers as "not synced" and falls into theelsebranch, displaying "Unknown" for both blocks remaining and estimated time. Meanwhile,UpdateHeaderSyncLabel()computes a percentage that rounds up to 100.0%, creating a contradictory display:"Unknown. Syncing Headers (942188, 100.0%)". Please read issue #65 for more context.This patch truncates the percentage to one decimal place instead of rounding, so it only shows 100.0% when headers are truly up to date. The same fix is applied to
UpdateHeaderPresyncLabel()for consistency.Fixes #65 .