From 78253fcbad69b28f1c0c3cfc7f8dcaecbb68c390 Mon Sep 17 00:00:00 2001 From: Michael Ford Date: Sat, 13 Dec 2014 12:09:33 +0800 Subject: Remove references to X11 licence --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index aedda49071..a121ec5879 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2011-2013 The Bitcoin developers -// Distributed under the MIT/X11 software license, see the accompanying +// Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "clientmodel.h" -- cgit v1.2.3 From f914f1a746d7f91951c1da262a4a749dd3ebfa71 Mon Sep 17 00:00:00 2001 From: sandakersmann Date: Wed, 17 Dec 2014 02:47:57 +0100 Subject: Added "Core" to copyright headers Github-Pull: #5494 Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60 --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index a121ec5879..493cdd6dd2 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2011-2013 The Bitcoin developers +// Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -- cgit v1.2.3 From 5262fde0ecd19f1febbfcd488f2be41c5dffd047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Jan=C3=ADk?= Date: Thu, 8 Jan 2015 11:44:25 +0100 Subject: Remove whitespaces before double colon in errors and logs --- src/qt/clientmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 493cdd6dd2..03d94f2e13 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -212,14 +212,14 @@ static void ShowProgress(ClientModel *clientmodel, const std::string &title, int static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections) { - // Too noisy: qDebug() << "NotifyNumConnectionsChanged : " + QString::number(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) { - qDebug() << "NotifyAlertChanged : " + QString::fromStdString(hash.GetHex()) + " status=" + QString::number(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)); -- cgit v1.2.3 From deda3e156d9d424051758eeca9569a90365d2dd5 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 9 Feb 2015 11:25:23 +0100 Subject: [Qt] remove unused getNumBlocksAtStartup() from ClientModel --- src/qt/clientmodel.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 03d94f2e13..729eb84a18 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -29,8 +29,9 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : optionsModel(optionsModel), peerTableModel(0), cachedNumBlocks(0), - cachedReindexing(0), cachedImporting(0), - numBlocksAtStartup(-1), pollTimer(0) + cachedReindexing(0), + cachedImporting(0), + pollTimer(0) { peerTableModel = new PeerTableModel(this); pollTimer = new QTimer(this); @@ -65,12 +66,6 @@ int ClientModel::getNumBlocks() const return chainActive.Height(); } -int ClientModel::getNumBlocksAtStartup() -{ - if (numBlocksAtStartup == -1) numBlocksAtStartup = getNumBlocks(); - return numBlocksAtStartup; -} - quint64 ClientModel::getTotalBytesRecv() const { return CNode::GetTotalBytesRecv(); -- cgit v1.2.3 From 8517e9709e883ef59603d56b45dd2e06f8b7c7d7 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 9 Feb 2015 11:19:01 +0100 Subject: [Qt] rework setNumBlocks to have blockDate as parameter - reduces some functional overhead and simplifies the code --- src/qt/clientmodel.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 729eb84a18..dc32f81571 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -18,7 +18,6 @@ #include -#include #include #include @@ -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()); -- cgit v1.2.3 From 11982d366df0301b8ceb6e9ec5bdc5a713be9ff0 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 22 Apr 2015 18:19:11 -0400 Subject: checkpoints: Decouple checkpoints from Params Pass checkpoint data in as necessary --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index dc32f81571..8e29cdeb06 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -89,7 +89,7 @@ QDateTime ClientModel::getLastBlockDate() const double ClientModel::getVerificationProgress() const { LOCK(cs_main); - return Checkpoints::GuessVerificationProgress(chainActive.Tip()); + return Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip()); } void ClientModel::updateTimer() -- cgit v1.2.3 From 5e058e74179f0e4ad62841ca82536f61b4673a1d Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 6 Jul 2015 08:11:34 +0200 Subject: [Qt] constify foreach uses where possible - this doesn't replace BOOST_FOREACH, it just makes used arguments const where possible --- src/qt/clientmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 8e29cdeb06..5ac11324d9 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -53,9 +53,9 @@ int ClientModel::getNumConnections(unsigned int flags) const return vNodes.size(); int nNum = 0; - BOOST_FOREACH(CNode* pnode, vNodes) - if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT)) - nNum++; + BOOST_FOREACH(const CNode* pnode, vNodes) + if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT)) + nNum++; return nNum; } -- cgit v1.2.3 From d29ec6c2301e593d577126d1ca85b93307b32bf1 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 14 Jul 2015 13:59:05 +0200 Subject: qt: define QT_NO_KEYWORDS QT_NO_KEYWORDS prevents Qt from defining the `foreach`, `signals`, `slots` and `emit` macros. Avoid overlap between Qt macros and boost - for example #undef hackiness in #6421. --- src/qt/clientmodel.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 5ac11324d9..92a9ef279d 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -117,15 +117,15 @@ void ClientModel::updateTimer() cachedReindexing = fReindex; cachedImporting = fImporting; - emit numBlocksChanged(newNumBlocks, newBlockDate); + Q_EMIT numBlocksChanged(newNumBlocks, newBlockDate); } - emit bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); + Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } void ClientModel::updateNumConnections(int numConnections) { - emit numConnectionsChanged(numConnections); + Q_EMIT numConnectionsChanged(numConnections); } void ClientModel::updateAlert(const QString &hash, int status) @@ -138,11 +138,11 @@ void ClientModel::updateAlert(const QString &hash, int status) CAlert alert = CAlert::getAlertByHash(hash_256); if(!alert.IsNull()) { - emit message(tr("Network Alert"), QString::fromStdString(alert.strStatusBar), CClientUIInterface::ICON_ERROR); + Q_EMIT message(tr("Network Alert"), QString::fromStdString(alert.strStatusBar), CClientUIInterface::ICON_ERROR); } } - emit alertsChanged(getStatusBarWarnings()); + Q_EMIT alertsChanged(getStatusBarWarnings()); } bool ClientModel::inInitialBlockDownload() const -- cgit v1.2.3 From 60c8bac77c6612b84e3496b2227a01058d720ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Sun, 5 Jul 2015 14:30:07 +0200 Subject: Includes: Cleanup around net main and wallet -Move from .h to .cpp: in main, net and wallet -Remove unnecessary #include "main.h" -Cleanup some wallet files includes --- src/qt/clientmodel.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 92a9ef279d..41dc2ea77e 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -11,7 +11,6 @@ #include "chainparams.h" #include "checkpoints.h" #include "clientversion.h" -#include "main.h" #include "net.h" #include "ui_interface.h" #include "util.h" -- cgit v1.2.3 From 54bd28fa758d9753464b3eb07d203521b50de1c6 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Thu, 6 Aug 2015 15:40:50 +0200 Subject: [Qt] show client user agent in debug window --- src/qt/clientmodel.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 41dc2ea77e..97d6711560 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -181,6 +181,11 @@ QString ClientModel::formatFullVersion() const return QString::fromStdString(FormatFullVersion()); } +QString ClientModel::formatSubVersion() const +{ + return QString::fromStdString(strSubVersion); +} + QString ClientModel::formatBuildDate() const { return QString::fromStdString(CLIENT_DATE); -- cgit v1.2.3 From ad204df1a9077327ab1142fbc9bf41369c1a73d1 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 20 Jun 2015 20:27:03 +0200 Subject: [Qt] add banlist table below peers table --- src/qt/clientmodel.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 97d6711560..62c35130f8 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -4,6 +4,7 @@ #include "clientmodel.h" +#include "bantablemodel.h" #include "guiconstants.h" #include "peertablemodel.h" @@ -26,6 +27,7 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : QObject(parent), optionsModel(optionsModel), peerTableModel(0), + banTableModel(0), cachedNumBlocks(0), cachedBlockDate(QDateTime()), cachedReindexing(0), @@ -33,6 +35,7 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : pollTimer(0) { peerTableModel = new PeerTableModel(this); + banTableModel = new BanTableModel(this); pollTimer = new QTimer(this); connect(pollTimer, SIGNAL(timeout()), this, SLOT(updateTimer())); pollTimer->start(MODEL_UPDATE_DELAY); @@ -176,6 +179,11 @@ PeerTableModel *ClientModel::getPeerTableModel() return peerTableModel; } +BanTableModel *ClientModel::getBanTableModel() +{ + return banTableModel; +} + QString ClientModel::formatFullVersion() const { return QString::fromStdString(FormatFullVersion()); @@ -206,6 +214,11 @@ QString ClientModel::formatClientStartupTime() const return QDateTime::fromTime_t(nClientStartupTime).toString(); } +void ClientModel::updateBanlist() +{ + banTableModel->refresh(); +} + // Handlers for core signals static void ShowProgress(ClientModel *clientmodel, const std::string &title, int nProgress) { -- cgit v1.2.3 From 5f421329508d6e86c410282c7de39d7e80b0b289 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 20 Jun 2015 20:27:28 +0200 Subject: [Qt] add ui signal for banlist changes --- src/qt/clientmodel.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 62c35130f8..7f5dea0ef9 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -243,12 +243,19 @@ static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, Ch Q_ARG(int, status)); } +static void BannedListChanged(ClientModel *clientmodel) +{ + qDebug() << "BannedListChanged"; + QMetaObject::invokeMethod(clientmodel, "updateBanlist", Qt::QueuedConnection); +} + void ClientModel::subscribeToCoreSignals() { // Connect signals to client uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2)); uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1)); uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2)); + uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this)); } void ClientModel::unsubscribeFromCoreSignals() @@ -257,4 +264,5 @@ void ClientModel::unsubscribeFromCoreSignals() uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2)); uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1)); uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2)); + uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this)); } -- cgit v1.2.3 From 6135309816208740888b25bc27ea123c1c825a04 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 20 Jun 2015 21:48:10 +0200 Subject: [Qt] banlist, UI optimizing and better signal handling --- src/qt/clientmodel.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 7f5dea0ef9..2af8226c12 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -217,6 +217,7 @@ QString ClientModel::formatClientStartupTime() const void ClientModel::updateBanlist() { banTableModel->refresh(); + emit banListChanged(); } // Handlers for core signals -- cgit v1.2.3 From 9e521c173586257f57764b479beb5923c33ed0eb Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Tue, 23 Jun 2015 21:10:42 +0200 Subject: [Qt] polish ban table --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 2af8226c12..851e9f1867 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -246,7 +246,7 @@ static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, Ch static void BannedListChanged(ClientModel *clientmodel) { - qDebug() << "BannedListChanged"; + qDebug() << QString("%1: Requesting update for peer banlist").arg(__func__); QMetaObject::invokeMethod(clientmodel, "updateBanlist", Qt::QueuedConnection); } -- cgit v1.2.3 From cdd72cd5fbc2b287559f7230d1616339e9ff2d6d Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Fri, 26 Jun 2015 10:23:51 +0200 Subject: [Qt] simplify ban list signal handling - remove banListChanged signal from client model - directly call clientModel->getBanTableModel()->refresh() without the way over clientModel->updateBanlist() - also fix clearing peer detail window, when selecting (clicking) peers in the ban list --- src/qt/clientmodel.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 851e9f1867..0900a35cc4 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -217,7 +217,6 @@ QString ClientModel::formatClientStartupTime() const void ClientModel::updateBanlist() { banTableModel->refresh(); - emit banListChanged(); } // Handlers for core signals -- cgit v1.2.3 From c197798d1b7364e8225beaaa716399441288203e Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Mon, 9 Nov 2015 11:45:07 +0100 Subject: [Qt] simple mempool info in debug window --- src/qt/clientmodel.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 0900a35cc4..566e8fa62d 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -13,6 +13,7 @@ #include "checkpoints.h" #include "clientversion.h" #include "net.h" +#include "txmempool.h" #include "ui_interface.h" #include "util.h" @@ -88,6 +89,16 @@ QDateTime ClientModel::getLastBlockDate() const return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network } +long ClientModel::getMempoolSize() const +{ + return mempool.size(); +} + +size_t ClientModel::getMempoolDynamicUsage() const +{ + return mempool.DynamicMemoryUsage(); +} + double ClientModel::getVerificationProgress() const { LOCK(cs_main); @@ -122,6 +133,7 @@ void ClientModel::updateTimer() Q_EMIT numBlocksChanged(newNumBlocks, newBlockDate); } + Q_EMIT mempoolSizeChanged(getMempoolSize(), getMempoolDynamicUsage()); Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } -- cgit v1.2.3 From e6d50fcdecfdd7281b7aa5e9b573ef1b4e82873f Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 26 Nov 2015 16:39:40 +0100 Subject: [Qt] update block tip (height and date) without locking cs_main, update always (each block) --- src/qt/clientmodel.cpp | 53 ++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 30 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 566e8fa62d..92df336c97 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -23,16 +23,13 @@ #include static const int64_t nClientStartupTime = GetTime(); +static int64_t nLastBlockTipUpdateNotification = 0; ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : QObject(parent), optionsModel(optionsModel), peerTableModel(0), banTableModel(0), - cachedNumBlocks(0), - cachedBlockDate(QDateTime()), - cachedReindexing(0), - cachedImporting(0), pollTimer(0) { peerTableModel = new PeerTableModel(this); @@ -107,32 +104,8 @@ double ClientModel::getVerificationProgress() const void ClientModel::updateTimer() { - // Get required lock upfront. This avoids the GUI from getting stuck on - // 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) - 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 || - cachedBlockDate != newBlockDate || - cachedReindexing != fReindex || - cachedImporting != fImporting) - { - cachedNumBlocks = newNumBlocks; - cachedBlockDate = newBlockDate; - cachedReindexing = fReindex; - cachedImporting = fImporting; - - Q_EMIT numBlocksChanged(newNumBlocks, newBlockDate); - } - + // no locking required at this point + // the following calls will aquire the required lock Q_EMIT mempoolSizeChanged(getMempoolSize(), getMempoolDynamicUsage()); Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } @@ -261,6 +234,24 @@ static void BannedListChanged(ClientModel *clientmodel) QMetaObject::invokeMethod(clientmodel, "updateBanlist", Qt::QueuedConnection); } +static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CBlockIndex *pIndex) +{ + // lock free async UI updates in case we have a new block tip + // during initial sync, only update the UI if the last update + // was > 250ms (MODEL_UPDATE_DELAY) ago + int64_t now = 0; + if (initialSync) + now = GetTimeMillis(); + + // if we are in-sync, update the UI regardless of last update time + if (!initialSync || now - nLastBlockTipUpdateNotification > MODEL_UPDATE_DELAY) { + //pass a async signal to the UI thread + Q_EMIT clientmodel->numBlocksChanged(pIndex->nHeight, QDateTime::fromTime_t(pIndex->GetBlockTime())); + nLastBlockTipUpdateNotification = now; + } + +} + void ClientModel::subscribeToCoreSignals() { // Connect signals to client @@ -268,6 +259,7 @@ void ClientModel::subscribeToCoreSignals() uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1)); uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2)); uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this)); + uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2)); } void ClientModel::unsubscribeFromCoreSignals() @@ -277,4 +269,5 @@ void ClientModel::unsubscribeFromCoreSignals() uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1)); uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2)); uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this)); + uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2)); } -- cgit v1.2.3 From 947d20b84ab271bec5ff08312921961627d1ad80 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 27 Nov 2015 13:20:46 +0100 Subject: [Qt] reduce cs_main in getVerificationProgress() --- src/qt/clientmodel.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 92df336c97..f7d8b71748 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -22,6 +22,8 @@ #include #include +class CBlockIndex; + static const int64_t nClientStartupTime = GetTime(); static int64_t nLastBlockTipUpdateNotification = 0; @@ -96,10 +98,9 @@ size_t ClientModel::getMempoolDynamicUsage() const return mempool.DynamicMemoryUsage(); } -double ClientModel::getVerificationProgress() const +double ClientModel::getVerificationProgress(const CBlockIndex *tip) const { - LOCK(cs_main); - return Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip()); + return Checkpoints::GuessVerificationProgress(Params().Checkpoints(), (CBlockIndex *)tip); } void ClientModel::updateTimer() @@ -246,7 +247,7 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB // if we are in-sync, update the UI regardless of last update time if (!initialSync || now - nLastBlockTipUpdateNotification > MODEL_UPDATE_DELAY) { //pass a async signal to the UI thread - Q_EMIT clientmodel->numBlocksChanged(pIndex->nHeight, QDateTime::fromTime_t(pIndex->GetBlockTime())); + Q_EMIT clientmodel->numBlocksChanged(pIndex->nHeight, QDateTime::fromTime_t(pIndex->GetBlockTime()), pIndex); nLastBlockTipUpdateNotification = now; } -- cgit v1.2.3 From 4082e4660305f7696949c3a13e2e9611210894e8 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 27 Nov 2015 18:22:18 +0100 Subject: [Qt] call GuessVerificationProgress synchronous during core signal, pass double over UI signal --- src/qt/clientmodel.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index f7d8b71748..d36d129c1a 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -98,9 +98,15 @@ size_t ClientModel::getMempoolDynamicUsage() const 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(tipIn); + if (!tip) + { + LOCK(cs_main); + tip = chainActive.Tip(); + } + return Checkpoints::GuessVerificationProgress(Params().Checkpoints(), tip); } 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 (!initialSync || now - nLastBlockTipUpdateNotification > MODEL_UPDATE_DELAY) { //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; } - } void ClientModel::subscribeToCoreSignals() -- cgit v1.2.3 From aabc897801f2513ab5bf5e8ae6e6bcffeb889e94 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 1 Dec 2015 09:47:13 +0100 Subject: rpc: Don't translate warning messages But keep translating them in the GUI. This - necessarily - requires duplication of a few messages. Alternative take on #7134, that keeps the translations from being wiped. Also document GetWarnings() input argument. Fixes #5895. --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index d36d129c1a..a4b028f0d0 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -158,7 +158,7 @@ enum BlockSource ClientModel::getBlockSource() const QString ClientModel::getStatusBarWarnings() const { - return QString::fromStdString(GetWarnings("statusbar")); + return QString::fromStdString(GetWarnings("gui")); } OptionsModel *ClientModel::getOptionsModel() -- cgit v1.2.3 From 6da12dff287ac08c1d8aa847794abb8e582d606c Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 1 Dec 2015 11:45:33 +0100 Subject: qt: use QMetaObject::invokeMethod for cross-thread signaling in clientmodel It's surprising to me that Q_EMIT even worked for this. But it doesn't build in Qt4, so switch back to `QMetaObject::invokeMethod`. Fixes #7138. --- src/qt/clientmodel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index d36d129c1a..8149dfdf5a 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -253,7 +253,10 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB // if we are in-sync, update the UI regardless of last update time if (!initialSync || now - nLastBlockTipUpdateNotification > MODEL_UPDATE_DELAY) { //pass a async signal to the UI thread - Q_EMIT clientmodel->numBlocksChanged(pIndex->nHeight, QDateTime::fromTime_t(pIndex->GetBlockTime()), clientmodel->getVerificationProgress(pIndex)); + QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection, + Q_ARG(int, pIndex->nHeight), + Q_ARG(QDateTime, QDateTime::fromTime_t(pIndex->GetBlockTime())), + Q_ARG(double, clientmodel->getVerificationProgress(pIndex))); nLastBlockTipUpdateNotification = now; } } -- cgit v1.2.3 From fa24439ff3d8ab5b9efaf66ef4dae6713b88cb35 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 13 Dec 2015 17:58:29 +0100 Subject: Bump copyright headers to 2015 --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 1271187420..b4ac696393 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2011-2013 The Bitcoin Core developers +// Copyright (c) 2011-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -- cgit v1.2.3 From 9d263bd17c2bdd5ba9e31bd5fb110c332eb80691 Mon Sep 17 00:00:00 2001 From: Chris Wheeler Date: Sun, 17 Jan 2016 11:03:56 +0000 Subject: Typo fixes in comments --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index b4ac696393..fb502b3c81 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -112,7 +112,7 @@ double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const void ClientModel::updateTimer() { // no locking required at this point - // the following calls will aquire the required lock + // the following calls will acquire the required lock Q_EMIT mempoolSizeChanged(getMempoolSize(), getMempoolDynamicUsage()); Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } -- cgit v1.2.3 From bbb9d1d1231099122a5b0ad5dd86f3f93ce22724 Mon Sep 17 00:00:00 2001 From: BtcDrak Date: Mon, 7 Mar 2016 19:44:09 +0000 Subject: Remove p2p alert handling --- src/qt/clientmodel.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index fb502b3c81..71a12c27fd 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -8,7 +8,6 @@ #include "guiconstants.h" #include "peertablemodel.h" -#include "alert.h" #include "chainparams.h" #include "checkpoints.h" #include "clientversion.h" -- cgit v1.2.3 From 92066344fdc3eb3071cb6fc0ce6a41d79c2dda53 Mon Sep 17 00:00:00 2001 From: BtcDrak Date: Sun, 6 Mar 2016 10:07:25 +0000 Subject: Update alert notification and GUI --- src/qt/clientmodel.cpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 71a12c27fd..d3edfedff2 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -121,20 +121,8 @@ void ClientModel::updateNumConnections(int numConnections) Q_EMIT numConnectionsChanged(numConnections); } -void ClientModel::updateAlert(const QString &hash, int status) +void ClientModel::updateAlert() { - // Show error message notification for new alert - if(status == CT_NEW) - { - uint256 hash_256; - hash_256.SetHex(hash.toStdString()); - CAlert alert = CAlert::getAlertByHash(hash_256); - if(!alert.IsNull()) - { - Q_EMIT message(tr("Network Alert"), QString::fromStdString(alert.strStatusBar), CClientUIInterface::ICON_ERROR); - } - } - Q_EMIT alertsChanged(getStatusBarWarnings()); } @@ -226,12 +214,10 @@ static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConn Q_ARG(int, newNumConnections)); } -static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, ChangeType status) +static void NotifyAlertChanged(ClientModel *clientmodel) { - 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)); + qDebug() << "NotifyAlertChanged"; + QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection); } static void BannedListChanged(ClientModel *clientmodel) @@ -265,7 +251,7 @@ void ClientModel::subscribeToCoreSignals() // Connect signals to client uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2)); uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1)); - uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2)); + uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this)); uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this)); uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2)); } @@ -275,7 +261,7 @@ void ClientModel::unsubscribeFromCoreSignals() // Disconnect signals from client uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2)); uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1)); - uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2)); + uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this)); uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this)); uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2)); } -- cgit v1.2.3 From 4856f1d6712cdb2eac8712e379fd1e351583d78f Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Tue, 22 Mar 2016 08:40:10 +0100 Subject: [Qt] Debug window: replace "Build date" with "Datadir" The build date does only makes sense for custom/self-compiled bitcoin-core versions because we are using static build-dates for our deterministic release builds. Having a quick option to get the current datadir is much more valuable for debug purposes. --- src/qt/clientmodel.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index d3edfedff2..65637cd61f 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -193,6 +193,11 @@ QString ClientModel::formatClientStartupTime() const return QDateTime::fromTime_t(nClientStartupTime).toString(); } +QString ClientModel::dataDir() const +{ + return QString::fromStdString(GetDataDir().string()); +} + void ClientModel::updateBanlist() { banTableModel->refresh(); -- cgit v1.2.3 From fc737d127fb53dbfd31d3d677e157b27f17d5b09 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 24 Mar 2016 21:48:45 +0100 Subject: [Qt] remove unused formatBuildDate method --- src/qt/clientmodel.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 65637cd61f..697736cc88 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -173,11 +173,6 @@ QString ClientModel::formatSubVersion() const return QString::fromStdString(strSubVersion); } -QString ClientModel::formatBuildDate() const -{ - return QString::fromStdString(CLIENT_DATE); -} - bool ClientModel::isReleaseVersion() const { return CLIENT_VERSION_IS_RELEASE; -- cgit v1.2.3 From b4d24e142e25a21c78ab74146c3520f2259fd7c2 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 28 Apr 2016 16:18:45 +0200 Subject: Report reindexing progress in GUI --- src/qt/clientmodel.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 697736cc88..108500654b 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -24,6 +24,7 @@ class CBlockIndex; static const int64_t nClientStartupTime = GetTime(); +static int64_t nLastHeaderTipUpdateNotification = 0; static int64_t nLastBlockTipUpdateNotification = 0; ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : @@ -226,7 +227,7 @@ static void BannedListChanged(ClientModel *clientmodel) QMetaObject::invokeMethod(clientmodel, "updateBanlist", Qt::QueuedConnection); } -static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CBlockIndex *pIndex) +static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CBlockIndex *pIndex, bool fHeader) { // lock free async UI updates in case we have a new block tip // during initial sync, only update the UI if the last update @@ -235,14 +236,17 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB if (initialSync) now = GetTimeMillis(); + int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification; + // if we are in-sync, update the UI regardless of last update time - if (!initialSync || now - nLastBlockTipUpdateNotification > MODEL_UPDATE_DELAY) { + if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { //pass a async signal to the UI thread QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection, Q_ARG(int, pIndex->nHeight), Q_ARG(QDateTime, QDateTime::fromTime_t(pIndex->GetBlockTime())), - Q_ARG(double, clientmodel->getVerificationProgress(pIndex))); - nLastBlockTipUpdateNotification = now; + Q_ARG(double, clientmodel->getVerificationProgress(pIndex)), + Q_ARG(bool, fHeader)); + nLastUpdateNotification = now; } } @@ -253,7 +257,8 @@ void ClientModel::subscribeToCoreSignals() uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1)); uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this)); uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this)); - uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2)); + uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2, false)); + uiInterface.NotifyHeaderTip.connect(boost::bind(BlockTipChanged, this, _1, _2, true)); } void ClientModel::unsubscribeFromCoreSignals() @@ -263,5 +268,6 @@ void ClientModel::unsubscribeFromCoreSignals() uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1)); uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this)); uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this)); - uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2)); + uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, false)); + uiInterface.NotifyHeaderTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, true)); } -- cgit v1.2.3 From a7897c02f790cd487874f09bc7b4ec31c17968ee Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 28 Jun 2016 18:27:49 +0200 Subject: qt: Remove client name from debug window Remove the client name from the debug window in the GUI. It is already part of the user agent, so adding it separately doesn't add anything. --- src/qt/clientmodel.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/qt/clientmodel.cpp') diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 108500654b..14661b857a 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -179,11 +179,6 @@ bool ClientModel::isReleaseVersion() const return CLIENT_VERSION_IS_RELEASE; } -QString ClientModel::clientName() const -{ - return QString::fromStdString(CLIENT_NAME); -} - QString ClientModel::formatClientStartupTime() const { return QDateTime::fromTime_t(nClientStartupTime).toString(); -- cgit v1.2.3