Report reindexing progress in GUI
This commit is contained in:
@@ -487,8 +487,8 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
|
||||
setNumConnections(clientModel->getNumConnections());
|
||||
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
|
||||
|
||||
setNumBlocks(clientModel->getNumBlocks(), clientModel->getLastBlockDate(), clientModel->getVerificationProgress(NULL));
|
||||
connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double)), this, SLOT(setNumBlocks(int,QDateTime,double)));
|
||||
setNumBlocks(clientModel->getNumBlocks(), clientModel->getLastBlockDate(), clientModel->getVerificationProgress(NULL), false);
|
||||
connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool)));
|
||||
|
||||
// Receive and report messages from client model
|
||||
connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
|
||||
@@ -727,7 +727,7 @@ void BitcoinGUI::setNumConnections(int count)
|
||||
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count));
|
||||
}
|
||||
|
||||
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress)
|
||||
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
|
||||
{
|
||||
if(!clientModel)
|
||||
return;
|
||||
@@ -739,15 +739,25 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
|
||||
enum BlockSource blockSource = clientModel->getBlockSource();
|
||||
switch (blockSource) {
|
||||
case BLOCK_SOURCE_NETWORK:
|
||||
if (header) {
|
||||
return;
|
||||
}
|
||||
progressBarLabel->setText(tr("Synchronizing with network..."));
|
||||
break;
|
||||
case BLOCK_SOURCE_DISK:
|
||||
progressBarLabel->setText(tr("Importing blocks from disk..."));
|
||||
if (header) {
|
||||
progressBarLabel->setText(tr("Indexing blocks on disk..."));
|
||||
} else {
|
||||
progressBarLabel->setText(tr("Processing blocks on disk..."));
|
||||
}
|
||||
break;
|
||||
case BLOCK_SOURCE_REINDEX:
|
||||
progressBarLabel->setText(tr("Reindexing blocks on disk..."));
|
||||
break;
|
||||
case BLOCK_SOURCE_NONE:
|
||||
if (header) {
|
||||
return;
|
||||
}
|
||||
// Case: not Importing, not Reindexing and no network connection
|
||||
progressBarLabel->setText(tr("No block source available..."));
|
||||
break;
|
||||
|
||||
@@ -157,7 +157,7 @@ public Q_SLOTS:
|
||||
/** Set number of connections shown in the UI */
|
||||
void setNumConnections(int count);
|
||||
/** Set number of blocks and last block date shown in the UI */
|
||||
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress);
|
||||
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
|
||||
|
||||
/** Notify the user of an event from the core network or transaction handling code.
|
||||
@param[in] title the message box / notification title
|
||||
|
||||
@@ -26,6 +26,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) :
|
||||
@@ -237,7 +238,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
|
||||
@@ -246,14 +247,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +268,8 @@ void ClientModel::subscribeToCoreSignals()
|
||||
uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1));
|
||||
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.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2, false));
|
||||
uiInterface.NotifyHeaderTip.connect(boost::bind(BlockTipChanged, this, _1, _2, true));
|
||||
}
|
||||
|
||||
void ClientModel::unsubscribeFromCoreSignals()
|
||||
@@ -274,5 +279,6 @@ void ClientModel::unsubscribeFromCoreSignals()
|
||||
uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1));
|
||||
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.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, false));
|
||||
uiInterface.NotifyHeaderTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, true));
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
|
||||
Q_SIGNALS:
|
||||
void numConnectionsChanged(int count);
|
||||
void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress);
|
||||
void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header);
|
||||
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
|
||||
void alertsChanged(const QString &warnings);
|
||||
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
|
||||
|
||||
@@ -355,8 +355,8 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||
setNumConnections(model->getNumConnections());
|
||||
connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
|
||||
|
||||
setNumBlocks(model->getNumBlocks(), model->getLastBlockDate(), model->getVerificationProgress(NULL));
|
||||
connect(model, SIGNAL(numBlocksChanged(int,QDateTime,double)), this, SLOT(setNumBlocks(int,QDateTime,double)));
|
||||
setNumBlocks(model->getNumBlocks(), model->getLastBlockDate(), model->getVerificationProgress(NULL), false);
|
||||
connect(model, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool)));
|
||||
|
||||
updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent());
|
||||
connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64)));
|
||||
@@ -584,10 +584,12 @@ void RPCConsole::setNumConnections(int count)
|
||||
ui->numberOfConnections->setText(connections);
|
||||
}
|
||||
|
||||
void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress)
|
||||
void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers)
|
||||
{
|
||||
ui->numberOfBlocks->setText(QString::number(count));
|
||||
ui->lastBlockTime->setText(blockDate.toString());
|
||||
if (!headers) {
|
||||
ui->numberOfBlocks->setText(QString::number(count));
|
||||
ui->lastBlockTime->setText(blockDate.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage)
|
||||
|
||||
@@ -87,7 +87,7 @@ public Q_SLOTS:
|
||||
/** Set number of connections shown in the UI */
|
||||
void setNumConnections(int count);
|
||||
/** Set number of blocks and last block date shown in the UI */
|
||||
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress);
|
||||
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
|
||||
/** Set size (number of transactions and memory usage) of the mempool in the UI */
|
||||
void setMempoolSize(long numberOfTxs, size_t dynUsage);
|
||||
/** Go forward or back in history */
|
||||
|
||||
@@ -124,7 +124,7 @@ void SendCoinsDialog::setClientModel(ClientModel *clientModel)
|
||||
this->clientModel = clientModel;
|
||||
|
||||
if (clientModel) {
|
||||
connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double)), this, SLOT(updateSmartFeeLabel()));
|
||||
connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(updateSmartFeeLabel()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user