diff options
| author | Wladimir J. van der Laan <[email protected]> | 2015-03-09 11:30:25 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2015-03-09 11:32:39 +0100 |
| commit | f50120ab4d244f52efbe37996dbc086ee698ee6b (patch) | |
| tree | 7534aee2b8a461e0ff470b9ad2ff95909ff26df4 /src/qt/clientmodel.cpp | |
| parent | Merge pull request #5858 (diff) | |
| parent | [Qt] rework setNumBlocks to have blockDate as parameter (diff) | |
| download | discoin-f50120ab4d244f52efbe37996dbc086ee698ee6b.tar.xz discoin-f50120ab4d244f52efbe37996dbc086ee698ee6b.zip | |
Merge pull request #5776
8517e97 [Qt] rework setNumBlocks to have blockDate as parameter (Philip Kaufmann)
Diffstat (limited to 'src/qt/clientmodel.cpp')
| -rw-r--r-- | src/qt/clientmodel.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 729eb84a1..dc32f8157 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -18,7 +18,6 @@ #include <stdint.h> -#include <QDateTime> #include <QDebug> #include <QTimer> @@ -29,6 +28,7 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : optionsModel(optionsModel), peerTableModel(0), cachedNumBlocks(0), + cachedBlockDate(QDateTime()), cachedReindexing(0), cachedImporting(0), pollTimer(0) @@ -79,10 +79,11 @@ quint64 ClientModel::getTotalBytesSent() const QDateTime ClientModel::getLastBlockDate() const { LOCK(cs_main); + if (chainActive.Tip()) return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime()); - else - return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network + + return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network } double ClientModel::getVerificationProgress() const @@ -97,21 +98,26 @@ void ClientModel::updateTimer() // periodical polls if the core is holding the locks for a longer time - // for example, during a wallet rescan. TRY_LOCK(cs_main, lockMain); - if(!lockMain) + if (!lockMain) return; + // Some quantities (such as number of blocks) change so fast that we don't want to be notified for each change. // Periodically check and update with a timer. int newNumBlocks = getNumBlocks(); + QDateTime newBlockDate = getLastBlockDate(); // check for changed number of blocks we have, number of blocks peers claim to have, reindexing state and importing state if (cachedNumBlocks != newNumBlocks || - cachedReindexing != fReindex || cachedImporting != fImporting) + cachedBlockDate != newBlockDate || + cachedReindexing != fReindex || + cachedImporting != fImporting) { cachedNumBlocks = newNumBlocks; + cachedBlockDate = newBlockDate; cachedReindexing = fReindex; cachedImporting = fImporting; - emit numBlocksChanged(newNumBlocks); + emit numBlocksChanged(newNumBlocks, newBlockDate); } emit bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); |