Skip to content

Commit b250686

Browse files
committed
Merge #9461: [Qt] Improve progress display during headers-sync and peer-finding
40ec7c7 [Qt] Improve progress display during headers-sync and peer-finding (Jonas Schnelli)
2 parents 2ef52d3 + 40ec7c7 commit b250686

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/qt/bitcoingui.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,15 @@ void BitcoinGUI::setNetworkActive(bool networkActive)
748748
updateNetworkState();
749749
}
750750

751+
void BitcoinGUI::updateHeadersSyncProgressLabel()
752+
{
753+
int64_t headersTipTime = clientModel->getHeaderTipTime();
754+
int headersTipHeight = clientModel->getHeaderTipHeight();
755+
int estHeadersLeft = (GetTime() - headersTipTime)/600;
756+
if (estHeadersLeft > REQ_HEADER_HEIGHT_DELTA_SYNC)
757+
progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
758+
}
759+
751760
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
752761
{
753762
if (modalOverlay)
@@ -768,9 +777,11 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
768777
switch (blockSource) {
769778
case BLOCK_SOURCE_NETWORK:
770779
if (header) {
780+
updateHeadersSyncProgressLabel();
771781
return;
772782
}
773783
progressBarLabel->setText(tr("Synchronizing with network..."));
784+
updateHeadersSyncProgressLabel();
774785
break;
775786
case BLOCK_SOURCE_DISK:
776787
if (header) {
@@ -786,8 +797,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
786797
if (header) {
787798
return;
788799
}
789-
// Case: not Importing, not Reindexing and no network connection
790-
progressBarLabel->setText(tr("No block source available..."));
800+
progressBarLabel->setText(tr("Connecting to peers..."));
791801
break;
792802
}
793803

src/qt/bitcoingui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class BitcoinGUI : public QMainWindow
149149
/** Update UI with latest network info from model. */
150150
void updateNetworkState();
151151

152+
void updateHeadersSyncProgressLabel();
153+
152154
Q_SIGNALS:
153155
/** Signal raised when a URI was entered or dragged to the GUI */
154156
void receivedURI(const QString &uri);

src/qt/clientmodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ClientModel : public QObject
6666

6767
//! Return true if core is doing initial block download
6868
bool inInitialBlockDownload() const;
69-
//! Return true if core is importing blocks
69+
//! Returns enum BlockSource of the current importing/syncing state
7070
enum BlockSource getBlockSource() const;
7171
//! Return true if network activity in core is enabled
7272
bool getNetworkActive() const;

src/qt/modaloverlay.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#include <QDateTime>
99
#include <QWidget>
1010

11+
//! The required delta of headers to the estimated number of available headers until we show the IBD progress
12+
static const int REQ_HEADER_HEIGHT_DELTA_SYNC = 24;
13+
1114
namespace Ui {
1215
class ModalOverlay;
1316
}

0 commit comments

Comments
 (0)