|
|
|
@ -18,7 +18,6 @@
@@ -18,7 +18,6 @@
|
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
#include <QDateTime> |
|
|
|
|
#include <QDebug> |
|
|
|
|
#include <QTimer> |
|
|
|
|
|
|
|
|
@ -29,6 +28,7 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
@@ -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,9 +79,10 @@ quint64 ClientModel::getTotalBytesSent() const
@@ -79,9 +79,10 @@ 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
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -99,19 +100,24 @@ void ClientModel::updateTimer()
@@ -99,19 +100,24 @@ void ClientModel::updateTimer()
|
|
|
|
|
TRY_LOCK(cs_main, 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()); |
|
|
|
|