mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-11 21:22:47 +01:00
Report reindexing progress in GUI
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
class CBlockIndex;
|
||||
|
||||
static const int64_t nClientStartupTime = GetTime();
|
||||
static int64_t nLastHeaderTipUpdateNotification = 0;
|
||||
static int64_t nLastBlockTipUpdateNotification = 0;
|
||||
|
||||
ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
|
||||
@@ -226,7 +227,7 @@ static void BannedListChanged(ClientModel *clientmodel)
|
||||
QMetaObject::invokeMethod(clientmodel, "updateBanlist", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CBlockIndex *pIndex)
|
||||
static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CBlockIndex *pIndex, bool fHeader)
|
||||
{
|
||||
// lock free async UI updates in case we have a new block tip
|
||||
// during initial sync, only update the UI if the last update
|
||||
@@ -235,14 +236,17 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB
|
||||
if (initialSync)
|
||||
now = GetTimeMillis();
|
||||
|
||||
int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
|
||||
|
||||
// if we are in-sync, update the UI regardless of last update time
|
||||
if (!initialSync || now - nLastBlockTipUpdateNotification > MODEL_UPDATE_DELAY) {
|
||||
if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
|
||||
//pass a async signal to the UI thread
|
||||
QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
|
||||
Q_ARG(int, pIndex->nHeight),
|
||||
Q_ARG(QDateTime, QDateTime::fromTime_t(pIndex->GetBlockTime())),
|
||||
Q_ARG(double, clientmodel->getVerificationProgress(pIndex)));
|
||||
nLastBlockTipUpdateNotification = now;
|
||||
Q_ARG(double, clientmodel->getVerificationProgress(pIndex)),
|
||||
Q_ARG(bool, fHeader));
|
||||
nLastUpdateNotification = now;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +257,8 @@ void ClientModel::subscribeToCoreSignals()
|
||||
uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1));
|
||||
uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this));
|
||||
uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this));
|
||||
uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2));
|
||||
uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2, false));
|
||||
uiInterface.NotifyHeaderTip.connect(boost::bind(BlockTipChanged, this, _1, _2, true));
|
||||
}
|
||||
|
||||
void ClientModel::unsubscribeFromCoreSignals()
|
||||
@@ -263,5 +268,6 @@ void ClientModel::unsubscribeFromCoreSignals()
|
||||
uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1));
|
||||
uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this));
|
||||
uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this));
|
||||
uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2));
|
||||
uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, false));
|
||||
uiInterface.NotifyHeaderTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user