diff options
author | Pieter Wuille <pieter@wuille.net> | 2022-08-13 16:27:50 -0400 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2022-08-29 08:10:35 -0400 |
commit | 3add23454624c4c79c9eebc060b6fbed4e3131a7 (patch) | |
tree | 26c6c99be030698ef856a30601f081b3127dfb0a /src/qt/modaloverlay.cpp | |
parent | 738421c50f2dbd7395b50a5dbdf6168b07435e62 (diff) | |
download | bitcoin-3add23454624c4c79c9eebc060b6fbed4e3131a7.tar.xz |
ui: show header pre-synchronization progress
Diffstat (limited to 'src/qt/modaloverlay.cpp')
-rw-r--r-- | src/qt/modaloverlay.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp index 97ee75a31f..dfa33764f6 100644 --- a/src/qt/modaloverlay.cpp +++ b/src/qt/modaloverlay.cpp @@ -78,13 +78,16 @@ bool ModalOverlay::event(QEvent* ev) { return QWidget::event(ev); } -void ModalOverlay::setKnownBestHeight(int count, const QDateTime& blockDate) +void ModalOverlay::setKnownBestHeight(int count, const QDateTime& blockDate, bool presync) { - if (count > bestHeaderHeight) { + if (!presync && count > bestHeaderHeight) { bestHeaderHeight = count; bestHeaderDate = blockDate; UpdateHeaderSyncLabel(); } + if (presync) { + UpdateHeaderPresyncLabel(count, blockDate); + } } void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVerificationProgress) @@ -158,6 +161,11 @@ void ModalOverlay::UpdateHeaderSyncLabel() { 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::UpdateHeaderPresyncLabel(int height, const QDateTime& blockDate) { + int est_headers_left = blockDate.secsTo(QDateTime::currentDateTime()) / Params().GetConsensus().nPowTargetSpacing; + ui->numberOfBlocksLeft->setText(tr("Unknown. Pre-syncing Headers (%1, %2%)…").arg(height).arg(QString::number(100.0 / (height + est_headers_left) * height, 'f', 1))); +} + void ModalOverlay::toggleVisibility() { showHide(layerIsVisible, true); |