Skip to content

Commit

Permalink
[Qt] Improve progress display during headers-sync and peer-finding
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli committed Jan 19, 2017
1 parent 03e1d6c commit 40ec7c7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,15 @@ void BitcoinGUI::setNetworkActive(bool networkActive)
updateNetworkState();
}

void BitcoinGUI::updateHeadersSyncProgressLabel()
{
int64_t headersTipTime = clientModel->getHeaderTipTime();
int headersTipHeight = clientModel->getHeaderTipHeight();
int estHeadersLeft = (GetTime() - headersTipTime)/600;
if (estHeadersLeft > REQ_HEADER_HEIGHT_DELTA_SYNC)
progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
}

void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
{
if (modalOverlay)
Expand All @@ -768,9 +777,11 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
switch (blockSource) {
case BLOCK_SOURCE_NETWORK:
if (header) {
updateHeadersSyncProgressLabel();
return;
}
progressBarLabel->setText(tr("Synchronizing with network..."));
updateHeadersSyncProgressLabel();
break;
case BLOCK_SOURCE_DISK:
if (header) {
Expand All @@ -786,8 +797,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
if (header) {
return;
}
// Case: not Importing, not Reindexing and no network connection
progressBarLabel->setText(tr("No block source available..."));
progressBarLabel->setText(tr("Connecting to peers..."));
break;
}

Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class BitcoinGUI : public QMainWindow
/** Update UI with latest network info from model. */
void updateNetworkState();

void updateHeadersSyncProgressLabel();

Q_SIGNALS:
/** Signal raised when a URI was entered or dragged to the GUI */
void receivedURI(const QString &uri);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ClientModel : public QObject

//! Return true if core is doing initial block download
bool inInitialBlockDownload() const;
//! Return true if core is importing blocks
//! Returns enum BlockSource of the current importing/syncing state
enum BlockSource getBlockSource() const;
//! Return true if network activity in core is enabled
bool getNetworkActive() const;
Expand Down
3 changes: 3 additions & 0 deletions src/qt/modaloverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <QDateTime>
#include <QWidget>

//! The required delta of headers to the estimated number of available headers until we show the IBD progress
static const int REQ_HEADER_HEIGHT_DELTA_SYNC = 24;

namespace Ui {
class ModalOverlay;
}
Expand Down

0 comments on commit 40ec7c7

Please sign in to comment.