From 7bb45e4b7a71e0ff0e2bbeba5367022758efa5d4 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 3 Jan 2019 11:34:38 -1000 Subject: Qt: update header count regardless of update delay --- src/qt/clientmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 217326f818..1b411f518d 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -237,8 +237,8 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, int heig clientmodel->cachedBestHeaderHeight = height; clientmodel->cachedBestHeaderTime = blockTime; } - // if we are in-sync, update the UI regardless of last update time - if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { + // if we are in-sync or if we notify a header update, update the UI regardless of last update time + if (fHeader || !initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { //pass an async signal to the UI thread QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection, Q_ARG(int, height), -- cgit v1.2.3 From e8db6b8044424a6fbb4b0a80acffc8c7fbf6be8b Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 3 Jan 2019 11:37:18 -1000 Subject: Qt: Fix update headers-count --- src/qt/modaloverlay.cpp | 8 +++++++- src/qt/modaloverlay.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp index c5bedf007a..8ecc33da84 100644 --- a/src/qt/modaloverlay.cpp +++ b/src/qt/modaloverlay.cpp @@ -71,6 +71,7 @@ void ModalOverlay::setKnownBestHeight(int count, const QDateTime& blockDate) if (count > bestHeaderHeight) { bestHeaderHeight = count; bestHeaderDate = blockDate; + UpdateHeaderSyncLabel(); } } @@ -136,11 +137,16 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) { ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count)); } else { - ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1)...").arg(bestHeaderHeight)); + UpdateHeaderSyncLabel(); ui->expectedTimeLeft->setText(tr("Unknown...")); } } +void ModalOverlay::UpdateHeaderSyncLabel() { + int est_headers_left = bestHeaderDate.secsTo(QDateTime::currentDateTime()) / Params().GetConsensus().nPowTargetSpacing; + ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1, %2%)...").arg(bestHeaderHeight).arg(QString::number(100.0 / (bestHeaderHeight + est_headers_left) * bestHeaderHeight, 'f', 1))); +} + void ModalOverlay::toggleVisibility() { showHide(layerIsVisible, true); diff --git a/src/qt/modaloverlay.h b/src/qt/modaloverlay.h index 66a6ad1e02..cf8b53f2b3 100644 --- a/src/qt/modaloverlay.h +++ b/src/qt/modaloverlay.h @@ -45,6 +45,7 @@ private: QVector > blockProcessTime; bool layerIsVisible; bool userClosed; + void UpdateHeaderSyncLabel(); }; #endif // BITCOIN_QT_MODALOVERLAY_H -- cgit v1.2.3