From e7b318e803aa3a5368c4196b7d111be4fcb17e0a Mon Sep 17 00:00:00 2001 From: sc-9310 Date: Mon, 24 Aug 2020 11:19:53 +0200 Subject: [PATCH 1/3] [QT] Add last block hash to debug ui Trivial addition to display last block hash next to last block time --- src/qt/clientmodel.cpp | 11 +++++++++++ src/qt/clientmodel.h | 3 ++- src/qt/forms/debugwindow.ui | 28 +++++++++++++++++++++------- src/qt/rpcconsole.cpp | 7 ++++--- src/qt/rpcconsole.h | 4 ++-- 5 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index f8d5b1e36274..53af195c9521 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -153,6 +153,16 @@ QDateTime ClientModel::getLastBlockDate() const return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network } +QString ClientModel::getLastBlockHash() const +{ + LOCK(cs_main); + + if (chainActive.Tip()) + return QString::fromStdString(chainActive.Tip()->GetBlockHash().ToString()); + + return QString::fromStdString(Params().GenesisBlock().GetHash().ToString()); // Genesis block's hash of current network +} + long ClientModel::getMempoolSize() const { return mempool.size(); @@ -344,6 +354,7 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection, Q_ARG(int, pIndex->nHeight), Q_ARG(QDateTime, QDateTime::fromTime_t(pIndex->GetBlockTime())), + Q_ARG(QString, clientmodel->getLastBlockHash()), Q_ARG(double, clientmodel->getVerificationProgress(pIndex)), Q_ARG(bool, fHeader)); nLastUpdateNotification = now; diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index ab7e31dc36e1..fe8b733e5247 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -72,6 +72,7 @@ class ClientModel : public QObject double getVerificationProgress(const CBlockIndex *tip) const; QDateTime getLastBlockDate() const; + QString getLastBlockHash() const; //! Return true if core is doing initial block download bool inInitialBlockDownload() const; @@ -113,7 +114,7 @@ class ClientModel : public QObject Q_SIGNALS: void numConnectionsChanged(int count); void masternodeListChanged() const; - void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header); + void numBlocksChanged(int count, const QDateTime& blockDate, const QString& blockHash, double nVerificationProgress, bool header); void additionalDataSyncProgressChanged(double nSyncProgress); void mempoolSizeChanged(long count, size_t mempoolSizeInBytes); void islockCountChanged(size_t count); diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index e7992fdd3f3a..1d9eaeb549f4 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -351,20 +351,34 @@ + + + Last block hash + + + + + + + N/A + + + + Memory Pool - + Current number of transactions - + IBeamCursor @@ -380,14 +394,14 @@ - + Memory usage - + IBeamCursor @@ -443,7 +457,7 @@ - + Qt::Vertical @@ -456,14 +470,14 @@ - + InstantSend locks - + IBeamCursor diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 8b37a391b681..832bec12946c 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -602,8 +602,8 @@ void RPCConsole::setClientModel(ClientModel *model) setNumConnections(model->getNumConnections()); connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); - setNumBlocks(model->getNumBlocks(), model->getLastBlockDate(), model->getVerificationProgress(nullptr), false); - connect(model, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool))); + setNumBlocks(model->getNumBlocks(), model->getLastBlockDate(), model->getLastBlockHash(), model->getVerificationProgress(nullptr), false); + connect(model, SIGNAL(numBlocksChanged(int,QDateTime,QString,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,QString,double,bool))); updateNetworkState(); connect(model, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool))); @@ -958,11 +958,12 @@ void RPCConsole::setNetworkActive(bool networkActive) updateNetworkState(); } -void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers) +void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate, const QString& blockHash, double nVerificationProgress, bool headers) { if (!headers) { ui->numberOfBlocks->setText(QString::number(count)); ui->lastBlockTime->setText(blockDate.toString()); + ui->lastBlockHash->setText(blockHash); } } diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 3f7aea19d5d1..419147d9cdac 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -112,8 +112,8 @@ public Q_SLOTS: void setNetworkActive(bool networkActive); /** Update number of masternodes shown in the UI */ void updateMasternodeCount(); - /** Set number of blocks and last block date shown in the UI */ - void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers); + /** Set number of blocks, last block date and last block hash shown in the UI */ + void setNumBlocks(int count, const QDateTime& blockDate, const QString& blockHash, double nVerificationProgress, bool headers); /** Set size (number of transactions and memory usage) of the mempool in the UI */ void setMempoolSize(long numberOfTxs, size_t dynUsage); /** Set number of InstantSend locks */ From 536909d4e28235f23ed502ffaadb2a62d5ba1915 Mon Sep 17 00:00:00 2001 From: sc-9310 Date: Tue, 25 Aug 2020 09:37:12 +0200 Subject: [PATCH 2/3] [QT] Make last block hash selectable ... and linter happy Switch QMetaObject to get last hash from pIndex instead of clientmodel --- src/qt/clientmodel.cpp | 6 +++--- src/qt/forms/debugwindow.ui | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 53af195c9521..15ca2f4b1c17 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -156,10 +156,10 @@ QDateTime ClientModel::getLastBlockDate() const QString ClientModel::getLastBlockHash() const { LOCK(cs_main); - + if (chainActive.Tip()) return QString::fromStdString(chainActive.Tip()->GetBlockHash().ToString()); - + return QString::fromStdString(Params().GenesisBlock().GetHash().ToString()); // Genesis block's hash of current network } @@ -354,7 +354,7 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection, Q_ARG(int, pIndex->nHeight), Q_ARG(QDateTime, QDateTime::fromTime_t(pIndex->GetBlockTime())), - Q_ARG(QString, clientmodel->getLastBlockHash()), + Q_ARG(QString, QString::fromStdString(pIndex->GetBlockHash().ToString())), Q_ARG(double, clientmodel->getVerificationProgress(pIndex)), Q_ARG(bool, fHeader)); nLastUpdateNotification = now; diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 1d9eaeb549f4..442bf94328b5 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -358,10 +358,19 @@ - + + + IBeamCursor + N/A + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + From aca76ad1eca80ed39032f179cf7c7fc87d5b979f Mon Sep 17 00:00:00 2001 From: sc-9310 Date: Tue, 25 Aug 2020 11:16:25 +0200 Subject: [PATCH 3/3] [Trivial] Fix trailing whitespaces --- src/qt/forms/debugwindow.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 442bf94328b5..80d8c0bd2921 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -358,7 +358,7 @@ - + IBeamCursor