diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp
index 08ba1c0d01..a07a6571a2 100644
--- a/src/masternode-sync.cpp
+++ b/src/masternode-sync.cpp
@@ -149,6 +149,7 @@ void CMasternodeSync::GetNextAsset()
case(MASTERNODE_SYNC_BUDGET):
LogPrintf("CMasternodeSync::GetNextAsset - Sync has finished\n");
RequestedMasternodeAssets = MASTERNODE_SYNC_FINISHED;
+ uiInterface.NotifyAdditionalDataSyncProgressChanged(1);
break;
}
RequestedMasternodeAttempt = 0;
@@ -251,7 +252,9 @@ void CMasternodeSync::Process()
if(fDebug) LogPrintf("CMasternodeSync::Process() - tick %d RequestedMasternodeAssets %d\n", tick, RequestedMasternodeAssets);
}
- //printf("CMasternodeSync::Process() TICK - %d %d \n", tick, RequestedMasternodeAssets);
+ double nSyncProgress = double(RequestedMasternodeAttempt + (RequestedMasternodeAssets - 1) * 8) / (8*4);
+ LogPrintf("CMasternodeSync::Process() - tick %d RequestedMasternodeAttempt %d RequestedMasternodeAssets %d nSyncProgress %f\n", tick, RequestedMasternodeAttempt, RequestedMasternodeAssets, nSyncProgress);
+ uiInterface.NotifyAdditionalDataSyncProgressChanged(nSyncProgress);
if(RequestedMasternodeAssets == MASTERNODE_SYNC_INITIAL) GetNextAsset();
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index f33edcfc12..bef0515ac9 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -546,6 +546,8 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
setNumBlocks(clientModel->getNumBlocks(), clientModel->getLastBlockDate(), clientModel->getVerificationProgress(NULL));
connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double)), this, SLOT(setNumBlocks(int,QDateTime,double)));
+ connect(clientModel, SIGNAL(additionalDataSyncProgressChanged(double)), this, SLOT(setAdditionalDataSyncProgress(double)));
+
// Receive and report messages from client model
connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
@@ -856,44 +858,8 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
// Set icon state: spinning if catching up, tick otherwise
QString theme = GUIUtil::getThemeName();
- // if(secs < 25*60) // 90*60 for bitcoin but we are 4x times faster
- if(masternodeSync.IsBlockchainSynced())
- {
- QString strSyncStatus;
- tooltip = tr("Up to date") + QString(".
") + tooltip;
- if(masternodeSync.IsSynced()) {
- progressBarLabel->setVisible(false);
- progressBar->setVisible(false);
- labelBlocksIcon->setPixmap(QIcon(":/icons/" + theme + "/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
- } else {
-
- int nAttempt;
- int progress = 0;
-
- labelBlocksIcon->setPixmap(QIcon(QString(
- ":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
- .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
- spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
-
-#ifdef ENABLE_WALLET
- if(walletFrame)
- walletFrame->showOutOfSyncWarning(false);
-#endif // ENABLE_WALLET
-
- nAttempt = masternodeSync.RequestedMasternodeAttempt < 8 ?
- masternodeSync.RequestedMasternodeAttempt + 1 : 8;
- progress = nAttempt + (masternodeSync.RequestedMasternodeAssets - 1) * 8;
- progressBar->setMaximum(4 * 8);
- progressBar->setFormat(tr("Synchronizing additional data: %p%"));
- progressBar->setValue(progress);
- }
-
- strSyncStatus = QString(masternodeSync.GetSyncStatus().c_str());
- progressBarLabel->setText(strSyncStatus);
- tooltip = strSyncStatus + QString("
") + tooltip;
- }
- else
+ if(!masternodeSync.IsBlockchainSynced())
{
// Represent time from last generated block in human readable text
QString timeBehindText;
@@ -955,6 +921,58 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
progressBar->setToolTip(tooltip);
}
+void BitcoinGUI::setAdditionalDataSyncProgress(double nSyncProgress)
+{
+ if(!clientModel)
+ return;
+
+ // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
+ statusBar()->clearMessage();
+
+ QString tooltip;
+
+ // Set icon state: spinning if catching up, tick otherwise
+ QString theme = GUIUtil::getThemeName();
+
+ if(masternodeSync.IsBlockchainSynced())
+ {
+ QString strSyncStatus;
+ tooltip = tr("Up to date") + QString(".
") + tooltip;
+
+ if(masternodeSync.IsSynced()) {
+ progressBarLabel->setVisible(false);
+ progressBar->setVisible(false);
+ labelBlocksIcon->setPixmap(QIcon(":/icons/" + theme + "/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
+ } else {
+
+ labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
+ ":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
+ .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
+ spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
+
+#ifdef ENABLE_WALLET
+ if(walletFrame)
+ walletFrame->showOutOfSyncWarning(false);
+#endif // ENABLE_WALLET
+
+ progressBar->setFormat(tr("Synchronizing additional data: %p%"));
+ progressBar->setMaximum(1000000000);
+ progressBar->setValue(nSyncProgress * 1000000000.0 + 0.5);
+ }
+
+ strSyncStatus = QString(masternodeSync.GetSyncStatus().c_str());
+ progressBarLabel->setText(strSyncStatus);
+ tooltip = strSyncStatus + QString("
") + tooltip;
+ }
+
+ // Don't word-wrap this (fixed-width) tooltip
+ tooltip = QString("") + tooltip + QString("");
+
+ labelBlocksIcon->setToolTip(tooltip);
+ progressBarLabel->setToolTip(tooltip);
+ progressBar->setToolTip(tooltip);
+}
+
void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
{
QString strTitle = tr("Dash Core"); // default title
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 098de5b252..fcbb8f4d3f 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -165,6 +165,8 @@ public Q_SLOTS:
void handleRestart(QStringList args);
/** Set number of blocks and last block date shown in the UI */
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress);
+ /** Set additional data sync status shown in the UI */
+ void setAdditionalDataSyncProgress(double nSyncProgress);
/** Notify the user of an event from the core network or transaction handling code.
@param[in] title the message box / notification title
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index d85db2c10d..2c7424c02b 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -131,17 +131,10 @@ void ClientModel::updateTimer()
// the following calls will aquire the required lock
Q_EMIT mempoolSizeChanged(getMempoolSize(), getMempoolDynamicUsage());
Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent());
-// TODO: masternodeSync.RequestedMasternodeAttempt != prevAttempt || masternodeSync.RequestedMasternodeAssets != prevAssets)
}
void ClientModel::updateMnTimer()
{
- // Get required lock upfront. This avoids the GUI from getting stuck on
- // periodical polls if the core is holding the locks for a longer time -
- // for example, during a wallet rescan.
- TRY_LOCK(cs_main, lockMain); // TODO: refactor the same way as ClientModel::updateTimer()
- if(!lockMain)
- return;
QString newMasternodeCountString = getMasternodeCountString();
if (cachedMasternodeCountString != newMasternodeCountString)
@@ -296,6 +289,12 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB
}
}
+static void NotifyAdditionalDataSyncProgressChanged(ClientModel *clientmodel, double nSyncProgress)
+{
+ QMetaObject::invokeMethod(clientmodel, "additionalDataSyncProgressChanged", Qt::QueuedConnection,
+ Q_ARG(double, nSyncProgress));
+}
+
void ClientModel::subscribeToCoreSignals()
{
// Connect signals to client
@@ -304,6 +303,7 @@ void ClientModel::subscribeToCoreSignals()
uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2));
uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this));
uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2));
+ uiInterface.NotifyAdditionalDataSyncProgressChanged.connect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1));
}
void ClientModel::unsubscribeFromCoreSignals()
@@ -314,4 +314,5 @@ void ClientModel::unsubscribeFromCoreSignals()
uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2));
uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this));
uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2));
+ uiInterface.NotifyAdditionalDataSyncProgressChanged.disconnect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1));
}
diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h
index ab78928f6f..3d980f3b08 100644
--- a/src/qt/clientmodel.h
+++ b/src/qt/clientmodel.h
@@ -95,6 +95,7 @@ Q_SIGNALS:
void numConnectionsChanged(int count);
void strMasternodesChanged(const QString &strMasternodes);
void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress);
+ void additionalDataSyncProgressChanged(double nSyncProgress);
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
void alertsChanged(const QString &warnings);
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
diff --git a/src/ui_interface.h b/src/ui_interface.h
index 967d243270..121f0c7af4 100644
--- a/src/ui_interface.h
+++ b/src/ui_interface.h
@@ -82,6 +82,9 @@ public:
/** Number of network connections changed. */
boost::signals2::signal NotifyNumConnectionsChanged;
+ /** Number of masternodes changed. */
+ boost::signals2::signal NotifyStrMasternodeCountChanged;
+
/**
* New, updated or cancelled alert.
* @note called with lock cs_mapAlerts held.
@@ -97,6 +100,9 @@ public:
/** New block has been accepted */
boost::signals2::signal NotifyBlockTip;
+ /** Additional data sync progress changed */
+ boost::signals2::signal NotifyAdditionalDataSyncProgressChanged;
+
/** Banlist did change. */
boost::signals2::signal BannedListChanged;
};