Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Comment on lines +160 to +161
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (chainActive.Tip())
return QString::fromStdString(chainActive.Tip()->GetBlockHash().ToString());
if (chainActive.Tip()) return QString::fromStdString(chainActive.Tip()->GetBlockHash().ToString());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's ok-ish since it's kind of a copy-paste like thing of the function above.


return QString::fromStdString(Params().GenesisBlock().GetHash().ToString()); // Genesis block's hash of current network
}

long ClientModel::getMempoolSize() const
{
return mempool.size();
Expand Down Expand Up @@ -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, QString::fromStdString(pIndex->GetBlockHash().ToString())),
Q_ARG(double, clientmodel->getVerificationProgress(pIndex)),
Q_ARG(bool, fHeader));
nLastUpdateNotification = now;
Expand Down
3 changes: 2 additions & 1 deletion src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
37 changes: 30 additions & 7 deletions src/qt/forms/debugwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -351,20 +351,43 @@
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="lastBlockHashLabel">
<property name="text">
<string>Last block hash</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLabel" name="lastBlockHash">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string>N/A</string>
</property>
Comment thread
UdjinM6 marked this conversation as resolved.
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="labelMempoolTitle">
<property name="text">
<string>Memory Pool</string>
</property>
</widget>
</item>
<item row="14" column="0">
<item row="15" column="0">
<widget class="QLabel" name="labelNumberOfTransactions">
<property name="text">
<string>Current number of transactions</string>
</property>
</widget>
</item>
<item row="14" column="1">
<item row="15" column="1">
<widget class="QLabel" name="mempoolNumberTxs">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -380,14 +403,14 @@
</property>
</widget>
</item>
<item row="15" column="0">
<item row="16" column="0">
<widget class="QLabel" name="labelMemoryUsage">
<property name="text">
<string>Memory usage</string>
</property>
</widget>
</item>
<item row="15" column="1">
<item row="16" column="1">
<widget class="QLabel" name="mempoolSize">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand Down Expand Up @@ -443,7 +466,7 @@
</item>
</layout>
</item>
<item row="17" column="0">
<item row="18" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -456,14 +479,14 @@
</property>
</spacer>
</item>
<item row="16" column="0">
<item row="17" column="0">
<widget class="QLabel" name="labelInstantSendLockCount">
<property name="text">
<string>InstantSend locks</string>
</property>
</widget>
</item>
<item row="16" column="1">
<item row="17" column="1">
<widget class="QLabel" name="instantSendLockCount">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand Down
7 changes: 4 additions & 3 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down