Skip to content

Commit 12a910c

Browse files
committed
Merge #15091: GUI: fix model overlay header sync
e8db6b8 Qt: Fix update headers-count (Jonas Schnelli) 7bb45e4 Qt: update header count regardless of update delay (Jonas Schnelli) Pull request description: Update the block and header tip is constraint to have a minimal distance of 250ms between updates... which can lead to miss the last header update. The modal overlay then assumes we are still in header sync and the view get stuck in "syncing headers,..." (while it's actually syncing blocks). This removes the 250ms minimal delta for header updates as well as it fixes the correct display of how header updates should update the labels. Tree-SHA512: 57608dac822b135cd604fc6ba1c80f25c0202a6e20bb140362026615d4bf243ef4fcc254a11bad36419c554a222a2f4947438d4ce44aa14041d1874751643d68
2 parents ddae781 + e8db6b8 commit 12a910c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/qt/clientmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, int heig
237237
clientmodel->cachedBestHeaderHeight = height;
238238
clientmodel->cachedBestHeaderTime = blockTime;
239239
}
240-
// if we are in-sync, update the UI regardless of last update time
241-
if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
240+
// if we are in-sync or if we notify a header update, update the UI regardless of last update time
241+
if (fHeader || !initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
242242
//pass an async signal to the UI thread
243243
QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
244244
Q_ARG(int, height),

src/qt/modaloverlay.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ void ModalOverlay::setKnownBestHeight(int count, const QDateTime& blockDate)
7171
if (count > bestHeaderHeight) {
7272
bestHeaderHeight = count;
7373
bestHeaderDate = blockDate;
74+
UpdateHeaderSyncLabel();
7475
}
7576
}
7677

@@ -136,11 +137,16 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
136137
if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) {
137138
ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count));
138139
} else {
139-
ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1)...").arg(bestHeaderHeight));
140+
UpdateHeaderSyncLabel();
140141
ui->expectedTimeLeft->setText(tr("Unknown..."));
141142
}
142143
}
143144

145+
void ModalOverlay::UpdateHeaderSyncLabel() {
146+
int est_headers_left = bestHeaderDate.secsTo(QDateTime::currentDateTime()) / Params().GetConsensus().nPowTargetSpacing;
147+
ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1, %2%)...").arg(bestHeaderHeight).arg(QString::number(100.0 / (bestHeaderHeight + est_headers_left) * bestHeaderHeight, 'f', 1)));
148+
}
149+
144150
void ModalOverlay::toggleVisibility()
145151
{
146152
showHide(layerIsVisible, true);

src/qt/modaloverlay.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public Q_SLOTS:
4545
QVector<QPair<qint64, double> > blockProcessTime;
4646
bool layerIsVisible;
4747
bool userClosed;
48+
void UpdateHeaderSyncLabel();
4849
};
4950

5051
#endif // BITCOIN_QT_MODALOVERLAY_H

0 commit comments

Comments
 (0)