Skip to content

Commit

Permalink
[Qt] Add blockhash + datadir to information tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrs-X committed Jun 20, 2019
1 parent 7e8855d commit 7c9859f
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 35 deletions.
15 changes: 15 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "bantablemodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "peertablemodel.h"

#include "alert.h"
Expand Down Expand Up @@ -112,6 +113,15 @@ 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());
else
return QString::fromStdString(Params().GenesisBlock().GetHash().ToString()); // Genesis block's hash of current network
}

double ClientModel::getVerificationProgress() const
{
LOCK(cs_main);
Expand Down Expand Up @@ -248,6 +258,11 @@ QString ClientModel::formatClientStartupTime() const
return QDateTime::fromTime_t(nClientStartupTime).toString();
}

QString ClientModel::dataDir() const
{
return GUIUtil::boostPathToQString(GetDataDir());
}

void ClientModel::updateBanlist()
{
banTableModel->refresh();
Expand Down
4 changes: 4 additions & 0 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef BITCOIN_QT_CLIENTMODEL_H
#define BITCOIN_QT_CLIENTMODEL_H

#include "uint256.h"
#include <QObject>
#include <QDateTime>

Expand Down Expand Up @@ -62,6 +63,8 @@ class ClientModel : public QObject
double getVerificationProgress() const;
QDateTime getLastBlockDate() const;

QString getLastBlockHash() const;

//! Return true if core is doing initial block download
bool inInitialBlockDownload() const;
//! Return true if core is importing blocks
Expand All @@ -74,6 +77,7 @@ class ClientModel : public QObject
bool isReleaseVersion() const;
QString clientName() const;
QString formatClientStartupTime() const;
QString dataDir() const;

bool getTorInfo(std::string& ip_port) const;

Expand Down
96 changes: 62 additions & 34 deletions src/qt/forms/rpcconsole.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>769</width>
<height>485</height>
<height>516</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -27,6 +27,13 @@
<property name="horizontalSpacing">
<number>12</number>
</property>
<item row="7" column="1">
<widget class="QLabel" name="dataDir">
<property name="text">
<string>N/A</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="generalHeader">
<property name="font">
Expand Down Expand Up @@ -184,7 +191,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="networkHeader">
<property name="font">
<font>
Expand All @@ -197,14 +204,14 @@
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="networkNameLabel">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QLabel" name="networkName">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -220,14 +227,14 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="numberOfConnectionsLabel">
<property name="text">
<string>Number of connections</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QLabel" name="numberOfConnections">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -243,14 +250,14 @@
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="masternodeCountLabel">
<property name="text">
<string>Number of Masternodes</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QLabel" name="masternodeCount">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -266,7 +273,7 @@
</property>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QLabel" name="blockchainHeader">
<property name="font">
<font>
Expand All @@ -279,14 +286,14 @@
</property>
</widget>
</item>
<item row="12" column="0">
<item row="13" column="0">
<widget class="QLabel" name="numberOfBlocksLabel">
<property name="text">
<string>Current number of blocks</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QLabel" name="numberOfBlocks">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -302,14 +309,14 @@
</property>
</widget>
</item>
<item row="13" column="0">
<item row="14" column="0">
<widget class="QLabel" name="lastBlockTimeLabel">
<property name="text">
<string>Last block time</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<widget class="QLabel" name="lastBlockTime">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -325,7 +332,7 @@
</property>
</widget>
</item>
<item row="14" column="0">
<item row="16" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -338,7 +345,7 @@
</property>
</spacer>
</item>
<item row="15" column="0">
<item row="17" column="0">
<widget class="QLabel" name="debugLogFileHeader">
<property name="font">
<font>
Expand All @@ -351,7 +358,7 @@
</property>
</widget>
</item>
<item row="16" column="0">
<item row="18" column="0">
<widget class="QPushButton" name="openDebugLogfileButton">
<property name="toolTip">
<string>Open the PIVX debug log file from the current data directory. This can take a few seconds for large log files.</string>
Expand All @@ -364,6 +371,27 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="dataDirLabel">
<property name="text">
<string>Data Directory</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="lastBlockHashLabel">
<property name="text">
<string>Last block hash</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLabel" name="lastBlockHash">
<property name="text">
<string>N/A</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_console">
Expand Down Expand Up @@ -1298,19 +1326,22 @@
</item>
<item row="3" column="0">
<widget class="QLabel" name="wallet_custombackuppath_label">
<property name="text">
<string>Custom Backup Path:</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>Custom Backup Path:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QLabel" name="wallet_custombackuppath">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>N/A</string>
</property>
Expand All @@ -1320,26 +1351,26 @@
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="wallet_customzpivbackuppath_label">
<property name="text">
<string>Custom zPIV Backup Path:</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>Custom zPIV Backup Path:</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QLabel" name="wallet_customzpivbackuppath">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>N/A</string>
</property>
Expand All @@ -1349,26 +1380,26 @@
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="wallet_custombackupthreshold_label">
<property name="text">
<string>Custom Backups Threshold:</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>Custom Backups Threshold:</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="3">
<widget class="QLabel" name="wallet_custombackupthreshold">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>N/A</string>
</property>
Expand All @@ -1378,9 +1409,6 @@
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="0">
Expand Down
5 changes: 4 additions & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ void RPCConsole::setClientModel(ClientModel* model)
ui->clientVersion->setText(model->formatFullVersion());
ui->clientName->setText(model->clientName());
ui->buildDate->setText(model->formatBuildDate());
ui->dataDir->setText(model->dataDir());
ui->startupTime->setText(model->formatClientStartupTime());
ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));

Expand Down Expand Up @@ -686,8 +687,10 @@ void RPCConsole::setNumConnections(int count)
void RPCConsole::setNumBlocks(int count)
{
ui->numberOfBlocks->setText(QString::number(count));
if (clientModel)
if (clientModel) {
ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString());
ui->lastBlockHash->setText(clientModel->getLastBlockHash());
}
}

void RPCConsole::setMasternodeCount(const QString& strMasternodes)
Expand Down

0 comments on commit 7c9859f

Please sign in to comment.