aboutsummaryrefslogtreecommitdiff
path: root/src/qt/clientmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/clientmodel.cpp')
-rw-r--r--src/qt/clientmodel.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 5cf4dd8111..212fa6974a 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -13,6 +13,7 @@
#include <QDateTime>
#include <QTimer>
+#include <QDebug>
static const int64 nClientStartupTime = GetTime();
@@ -23,9 +24,8 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
numBlocksAtStartup(-1), pollTimer(0)
{
pollTimer = new QTimer(this);
- pollTimer->setInterval(MODEL_UPDATE_DELAY);
- pollTimer->start();
connect(pollTimer, SIGNAL(timeout()), this, SLOT(updateTimer()));
+ pollTimer->start(MODEL_UPDATE_DELAY);
subscribeToCoreSignals();
}
@@ -42,7 +42,7 @@ int ClientModel::getNumConnections() const
int ClientModel::getNumBlocks() const
{
- return nBestHeight;
+ return chainActive.Height();
}
int ClientModel::getNumBlocksAtStartup()
@@ -51,19 +51,27 @@ int ClientModel::getNumBlocksAtStartup()
return numBlocksAtStartup;
}
+quint64 ClientModel::getTotalBytesRecv() const
+{
+ return CNode::GetTotalBytesRecv();
+}
+
+quint64 ClientModel::getTotalBytesSent() const
+{
+ return CNode::GetTotalBytesSent();
+}
+
QDateTime ClientModel::getLastBlockDate() const
{
- if (pindexBest)
- return QDateTime::fromTime_t(pindexBest->GetBlockTime());
- else if(!isTestNet())
- return QDateTime::fromTime_t(1231006505); // Genesis block's time
+ if (chainActive.Tip())
+ return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime());
else
- return QDateTime::fromTime_t(1296688602); // Genesis block's time (testnet)
+ return QDateTime::fromTime_t(Params().GenesisBlock().nTime); // Genesis block's time of current network
}
double ClientModel::getVerificationProgress() const
{
- return Checkpoints::GuessVerificationProgress(pindexBest);
+ return Checkpoints::GuessVerificationProgress(chainActive.Tip());
}
void ClientModel::updateTimer()
@@ -85,6 +93,8 @@ void ClientModel::updateTimer()
// ensure we return the maximum of newNumBlocksOfPeers and newNumBlocks to not create weird displays in the GUI
emit numBlocksChanged(newNumBlocks, std::max(newNumBlocksOfPeers, newNumBlocks));
}
+
+ emit bytesChanged(getTotalBytesRecv(), getTotalBytesSent());
}
void ClientModel::updateNumConnections(int numConnections)
@@ -180,14 +190,14 @@ static void NotifyBlocksChanged(ClientModel *clientmodel)
static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections)
{
- // Too noisy: OutputDebugStringF("NotifyNumConnectionsChanged %i\n", newNumConnections);
+ // Too noisy: qDebug() << "NotifyNumConnectionsChanged : " + QString::number(newNumConnections);
QMetaObject::invokeMethod(clientmodel, "updateNumConnections", Qt::QueuedConnection,
Q_ARG(int, newNumConnections));
}
static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, ChangeType status)
{
- OutputDebugStringF("NotifyAlertChanged %s status=%i\n", hash.GetHex().c_str(), status);
+ qDebug() << "NotifyAlertChanged : " + QString::fromStdString(hash.GetHex()) + " status=" + QString::number(status);
QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(hash.GetHex())),
Q_ARG(int, status));