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)
This commit is contained in:
Jonas Schnelli 2017-01-19 20:09:44 +01:00
commit b25068697f
No known key found for this signature in database
GPG key ID: 29D4BCB6416F53EC
4 changed files with 18 additions and 3 deletions

View file

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

View file

@ -149,6 +149,8 @@ private:
/** Update UI with latest network info from model. */ /** Update UI with latest network info from model. */
void updateNetworkState(); void updateNetworkState();
void updateHeadersSyncProgressLabel();
Q_SIGNALS: Q_SIGNALS:
/** Signal raised when a URI was entered or dragged to the GUI */ /** Signal raised when a URI was entered or dragged to the GUI */
void receivedURI(const QString &uri); void receivedURI(const QString &uri);

View file

@ -66,7 +66,7 @@ public:
//! Return true if core is doing initial block download //! Return true if core is doing initial block download
bool inInitialBlockDownload() const; bool inInitialBlockDownload() const;
//! Return true if core is importing blocks //! Returns enum BlockSource of the current importing/syncing state
enum BlockSource getBlockSource() const; enum BlockSource getBlockSource() const;
//! Return true if network activity in core is enabled //! Return true if network activity in core is enabled
bool getNetworkActive() const; bool getNetworkActive() const;

View file

@ -8,6 +8,9 @@
#include <QDateTime> #include <QDateTime>
#include <QWidget> #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 { namespace Ui {
class ModalOverlay; class ModalOverlay;
} }