Browse Source

[Qt] call GuessVerificationProgress synchronous during core signal, pass double over UI signal

0.13
Jonas Schnelli 9 years ago
parent
commit
4082e46603
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
  1. 3
      src/main.cpp
  2. 8
      src/qt/bitcoingui.cpp
  3. 3
      src/qt/bitcoingui.h
  4. 13
      src/qt/clientmodel.cpp
  5. 2
      src/qt/clientmodel.h
  6. 6
      src/qt/rpcconsole.cpp
  7. 2
      src/qt/rpcconsole.h
  8. 2
      src/qt/sendcoinsdialog.cpp

3
src/main.cpp

@ -2638,9 +2638,8 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
GetMainSignals().UpdatedBlockTip(pindexNewTip); GetMainSignals().UpdatedBlockTip(pindexNewTip);
} }
} }
if (!vHashes.empty()) { // Always notify the UI if a new block tip was connected
uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip); uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip);
}
} while(pindexMostWork != chainActive.Tip()); } while(pindexMostWork != chainActive.Tip());
CheckBlockIndex(chainparams.GetConsensus()); CheckBlockIndex(chainparams.GetConsensus());

8
src/qt/bitcoingui.cpp

@ -443,8 +443,8 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
setNumConnections(clientModel->getNumConnections()); setNumConnections(clientModel->getNumConnections());
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
setNumBlocks(clientModel->getNumBlocks(), clientModel->getLastBlockDate(), NULL); setNumBlocks(clientModel->getNumBlocks(), clientModel->getLastBlockDate(), clientModel->getVerificationProgress(NULL));
connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,const CBlockIndex*)), this, SLOT(setNumBlocks(int,QDateTime,const CBlockIndex*))); connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double)), this, SLOT(setNumBlocks(int,QDateTime,double)));
// Receive and report messages from client model // Receive and report messages from client model
connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int))); connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
@ -672,7 +672,7 @@ void BitcoinGUI::setNumConnections(int count)
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count)); labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count));
} }
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, const CBlockIndex *tip) void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress)
{ {
if(!clientModel) if(!clientModel)
return; return;
@ -749,7 +749,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, const CBloc
progressBarLabel->setVisible(true); progressBarLabel->setVisible(true);
progressBar->setFormat(tr("%1 behind").arg(timeBehindText)); progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
progressBar->setMaximum(1000000000); progressBar->setMaximum(1000000000);
progressBar->setValue(clientModel->getVerificationProgress(tip) * 1000000000.0 + 0.5); progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
progressBar->setVisible(true); progressBar->setVisible(true);
tooltip = tr("Catching up...") + QString("<br>") + tooltip; tooltip = tr("Catching up...") + QString("<br>") + tooltip;

3
src/qt/bitcoingui.h

@ -29,7 +29,6 @@ class UnitDisplayStatusBarControl;
class WalletFrame; class WalletFrame;
class WalletModel; class WalletModel;
class HelpMessageDialog; class HelpMessageDialog;
class CBlockIndex;
class CWallet; class CWallet;
@ -150,7 +149,7 @@ public Q_SLOTS:
/** Set number of connections shown in the UI */ /** Set number of connections shown in the UI */
void setNumConnections(int count); void setNumConnections(int count);
/** Set number of blocks and last block date shown in the UI */ /** Set number of blocks and last block date shown in the UI */
void setNumBlocks(int count, const QDateTime& blockDate, const CBlockIndex* tip); void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress);
/** Notify the user of an event from the core network or transaction handling code. /** Notify the user of an event from the core network or transaction handling code.
@param[in] title the message box / notification title @param[in] title the message box / notification title

13
src/qt/clientmodel.cpp

@ -98,9 +98,15 @@ size_t ClientModel::getMempoolDynamicUsage() const
return mempool.DynamicMemoryUsage(); return mempool.DynamicMemoryUsage();
} }
double ClientModel::getVerificationProgress(const CBlockIndex *tip) const double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const
{ {
return Checkpoints::GuessVerificationProgress(Params().Checkpoints(), (CBlockIndex *)tip); CBlockIndex *tip = const_cast<CBlockIndex *>(tipIn);
if (!tip)
{
LOCK(cs_main);
tip = chainActive.Tip();
}
return Checkpoints::GuessVerificationProgress(Params().Checkpoints(), tip);
} }
void ClientModel::updateTimer() void ClientModel::updateTimer()
@ -247,10 +253,9 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB
// if we are in-sync, update the UI regardless of last update time // if we are in-sync, update the UI regardless of last update time
if (!initialSync || now - nLastBlockTipUpdateNotification > MODEL_UPDATE_DELAY) { if (!initialSync || now - nLastBlockTipUpdateNotification > MODEL_UPDATE_DELAY) {
//pass a async signal to the UI thread //pass a async signal to the UI thread
Q_EMIT clientmodel->numBlocksChanged(pIndex->nHeight, QDateTime::fromTime_t(pIndex->GetBlockTime()), pIndex); Q_EMIT clientmodel->numBlocksChanged(pIndex->nHeight, QDateTime::fromTime_t(pIndex->GetBlockTime()), clientmodel->getVerificationProgress(pIndex));
nLastBlockTipUpdateNotification = now; nLastBlockTipUpdateNotification = now;
} }
} }
void ClientModel::subscribeToCoreSignals() void ClientModel::subscribeToCoreSignals()

2
src/qt/clientmodel.h

@ -89,7 +89,7 @@ private:
Q_SIGNALS: Q_SIGNALS:
void numConnectionsChanged(int count); void numConnectionsChanged(int count);
void numBlocksChanged(int count, const QDateTime& blockDate, const CBlockIndex *tip); void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress);
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes); void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
void alertsChanged(const QString &warnings); void alertsChanged(const QString &warnings);
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut); void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);

6
src/qt/rpcconsole.cpp

@ -343,8 +343,8 @@ void RPCConsole::setClientModel(ClientModel *model)
setNumConnections(model->getNumConnections()); setNumConnections(model->getNumConnections());
connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
setNumBlocks(model->getNumBlocks(), model->getLastBlockDate(), NULL); setNumBlocks(model->getNumBlocks(), model->getLastBlockDate(), model->getVerificationProgress(NULL));
connect(model, SIGNAL(numBlocksChanged(int,QDateTime,const CBlockIndex*)), this, SLOT(setNumBlocks(int,QDateTime,const CBlockIndex*))); connect(model, SIGNAL(numBlocksChanged(int,QDateTime,double)), this, SLOT(setNumBlocks(int,QDateTime,double)));
updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent()); updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent());
connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64))); connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64)));
@ -525,7 +525,7 @@ void RPCConsole::setNumConnections(int count)
ui->numberOfConnections->setText(connections); ui->numberOfConnections->setText(connections);
} }
void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate, const CBlockIndex* tip) void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress)
{ {
ui->numberOfBlocks->setText(QString::number(count)); ui->numberOfBlocks->setText(QString::number(count));
ui->lastBlockTime->setText(blockDate.toString()); ui->lastBlockTime->setText(blockDate.toString());

2
src/qt/rpcconsole.h

@ -83,7 +83,7 @@ public Q_SLOTS:
/** Set number of connections shown in the UI */ /** Set number of connections shown in the UI */
void setNumConnections(int count); void setNumConnections(int count);
/** Set number of blocks and last block date shown in the UI */ /** Set number of blocks and last block date shown in the UI */
void setNumBlocks(int count, const QDateTime& blockDate, const CBlockIndex* tip); void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress);
/** Set size (number of transactions and memory usage) of the mempool in the UI */ /** Set size (number of transactions and memory usage) of the mempool in the UI */
void setMempoolSize(long numberOfTxs, size_t dynUsage); void setMempoolSize(long numberOfTxs, size_t dynUsage);
/** Go forward or back in history */ /** Go forward or back in history */

2
src/qt/sendcoinsdialog.cpp

@ -124,7 +124,7 @@ void SendCoinsDialog::setClientModel(ClientModel *clientModel)
this->clientModel = clientModel; this->clientModel = clientModel;
if (clientModel) { if (clientModel) {
connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,const CBlockIndex*)), this, SLOT(updateSmartFeeLabel())); connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double)), this, SLOT(updateSmartFeeLabel()));
} }
} }

Loading…
Cancel
Save