|
|
@ -18,7 +18,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
|
|
#include <QDateTime> |
|
|
|
|
|
|
|
#include <QDebug> |
|
|
|
#include <QDebug> |
|
|
|
#include <QTimer> |
|
|
|
#include <QTimer> |
|
|
|
|
|
|
|
|
|
|
@ -29,6 +28,7 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : |
|
|
|
optionsModel(optionsModel), |
|
|
|
optionsModel(optionsModel), |
|
|
|
peerTableModel(0), |
|
|
|
peerTableModel(0), |
|
|
|
cachedNumBlocks(0), |
|
|
|
cachedNumBlocks(0), |
|
|
|
|
|
|
|
cachedBlockDate(QDateTime()), |
|
|
|
cachedReindexing(0), |
|
|
|
cachedReindexing(0), |
|
|
|
cachedImporting(0), |
|
|
|
cachedImporting(0), |
|
|
|
pollTimer(0) |
|
|
|
pollTimer(0) |
|
|
@ -79,9 +79,10 @@ quint64 ClientModel::getTotalBytesSent() const |
|
|
|
QDateTime ClientModel::getLastBlockDate() const |
|
|
|
QDateTime ClientModel::getLastBlockDate() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_main); |
|
|
|
LOCK(cs_main); |
|
|
|
|
|
|
|
|
|
|
|
if (chainActive.Tip()) |
|
|
|
if (chainActive.Tip()) |
|
|
|
return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime()); |
|
|
|
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
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -97,21 +98,26 @@ void ClientModel::updateTimer() |
|
|
|
// periodical polls if the core is holding the locks for a longer time -
|
|
|
|
// periodical polls if the core is holding the locks for a longer time -
|
|
|
|
// for example, during a wallet rescan.
|
|
|
|
// for example, during a wallet rescan.
|
|
|
|
TRY_LOCK(cs_main, lockMain); |
|
|
|
TRY_LOCK(cs_main, lockMain); |
|
|
|
if(!lockMain) |
|
|
|
if (!lockMain) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// Some quantities (such as number of blocks) change so fast that we don't want to be notified for each change.
|
|
|
|
// 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.
|
|
|
|
// Periodically check and update with a timer.
|
|
|
|
int newNumBlocks = getNumBlocks(); |
|
|
|
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
|
|
|
|
// check for changed number of blocks we have, number of blocks peers claim to have, reindexing state and importing state
|
|
|
|
if (cachedNumBlocks != newNumBlocks || |
|
|
|
if (cachedNumBlocks != newNumBlocks || |
|
|
|
cachedReindexing != fReindex || cachedImporting != fImporting) |
|
|
|
cachedBlockDate != newBlockDate || |
|
|
|
|
|
|
|
cachedReindexing != fReindex || |
|
|
|
|
|
|
|
cachedImporting != fImporting) |
|
|
|
{ |
|
|
|
{ |
|
|
|
cachedNumBlocks = newNumBlocks; |
|
|
|
cachedNumBlocks = newNumBlocks; |
|
|
|
|
|
|
|
cachedBlockDate = newBlockDate; |
|
|
|
cachedReindexing = fReindex; |
|
|
|
cachedReindexing = fReindex; |
|
|
|
cachedImporting = fImporting; |
|
|
|
cachedImporting = fImporting; |
|
|
|
|
|
|
|
|
|
|
|
emit numBlocksChanged(newNumBlocks); |
|
|
|
emit numBlocksChanged(newNumBlocks, newBlockDate); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
emit bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); |
|
|
|
emit bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); |
|
|
|