Skip to content

Commit 7c9859f

Browse files
committed
[Qt] Add blockhash + datadir to information tab
1 parent 7e8855d commit 7c9859f

File tree

4 files changed

+85
-35
lines changed

4 files changed

+85
-35
lines changed

src/qt/clientmodel.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "bantablemodel.h"
1010
#include "guiconstants.h"
11+
#include "guiutil.h"
1112
#include "peertablemodel.h"
1213

1314
#include "alert.h"
@@ -112,6 +113,15 @@ QDateTime ClientModel::getLastBlockDate() const
112113
return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network
113114
}
114115

116+
QString ClientModel::getLastBlockHash() const
117+
{
118+
LOCK(cs_main);
119+
if (chainActive.Tip())
120+
return QString::fromStdString(chainActive.Tip()->GetBlockHash().ToString());
121+
else
122+
return QString::fromStdString(Params().GenesisBlock().GetHash().ToString()); // Genesis block's hash of current network
123+
}
124+
115125
double ClientModel::getVerificationProgress() const
116126
{
117127
LOCK(cs_main);
@@ -248,6 +258,11 @@ QString ClientModel::formatClientStartupTime() const
248258
return QDateTime::fromTime_t(nClientStartupTime).toString();
249259
}
250260

261+
QString ClientModel::dataDir() const
262+
{
263+
return GUIUtil::boostPathToQString(GetDataDir());
264+
}
265+
251266
void ClientModel::updateBanlist()
252267
{
253268
banTableModel->refresh();

src/qt/clientmodel.h

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef BITCOIN_QT_CLIENTMODEL_H
88
#define BITCOIN_QT_CLIENTMODEL_H
99

10+
#include "uint256.h"
1011
#include <QObject>
1112
#include <QDateTime>
1213

@@ -62,6 +63,8 @@ class ClientModel : public QObject
6263
double getVerificationProgress() const;
6364
QDateTime getLastBlockDate() const;
6465

66+
QString getLastBlockHash() const;
67+
6568
//! Return true if core is doing initial block download
6669
bool inInitialBlockDownload() const;
6770
//! Return true if core is importing blocks
@@ -74,6 +77,7 @@ class ClientModel : public QObject
7477
bool isReleaseVersion() const;
7578
QString clientName() const;
7679
QString formatClientStartupTime() const;
80+
QString dataDir() const;
7781

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

src/qt/forms/rpcconsole.ui

+62-34
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>769</width>
10-
<height>485</height>
10+
<height>516</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -27,6 +27,13 @@
2727
<property name="horizontalSpacing">
2828
<number>12</number>
2929
</property>
30+
<item row="7" column="1">
31+
<widget class="QLabel" name="dataDir">
32+
<property name="text">
33+
<string>N/A</string>
34+
</property>
35+
</widget>
36+
</item>
3037
<item row="0" column="0">
3138
<widget class="QLabel" name="generalHeader">
3239
<property name="font">
@@ -184,7 +191,7 @@
184191
</property>
185192
</widget>
186193
</item>
187-
<item row="7" column="0">
194+
<item row="8" column="0">
188195
<widget class="QLabel" name="networkHeader">
189196
<property name="font">
190197
<font>
@@ -197,14 +204,14 @@
197204
</property>
198205
</widget>
199206
</item>
200-
<item row="8" column="0">
207+
<item row="9" column="0">
201208
<widget class="QLabel" name="networkNameLabel">
202209
<property name="text">
203210
<string>Name</string>
204211
</property>
205212
</widget>
206213
</item>
207-
<item row="8" column="1">
214+
<item row="9" column="1">
208215
<widget class="QLabel" name="networkName">
209216
<property name="cursor">
210217
<cursorShape>IBeamCursor</cursorShape>
@@ -220,14 +227,14 @@
220227
</property>
221228
</widget>
222229
</item>
223-
<item row="9" column="0">
230+
<item row="10" column="0">
224231
<widget class="QLabel" name="numberOfConnectionsLabel">
225232
<property name="text">
226233
<string>Number of connections</string>
227234
</property>
228235
</widget>
229236
</item>
230-
<item row="9" column="1">
237+
<item row="10" column="1">
231238
<widget class="QLabel" name="numberOfConnections">
232239
<property name="cursor">
233240
<cursorShape>IBeamCursor</cursorShape>
@@ -243,14 +250,14 @@
243250
</property>
244251
</widget>
245252
</item>
246-
<item row="10" column="0">
253+
<item row="11" column="0">
247254
<widget class="QLabel" name="masternodeCountLabel">
248255
<property name="text">
249256
<string>Number of Masternodes</string>
250257
</property>
251258
</widget>
252259
</item>
253-
<item row="10" column="1">
260+
<item row="11" column="1">
254261
<widget class="QLabel" name="masternodeCount">
255262
<property name="cursor">
256263
<cursorShape>IBeamCursor</cursorShape>
@@ -266,7 +273,7 @@
266273
</property>
267274
</widget>
268275
</item>
269-
<item row="11" column="0">
276+
<item row="12" column="0">
270277
<widget class="QLabel" name="blockchainHeader">
271278
<property name="font">
272279
<font>
@@ -279,14 +286,14 @@
279286
</property>
280287
</widget>
281288
</item>
282-
<item row="12" column="0">
289+
<item row="13" column="0">
283290
<widget class="QLabel" name="numberOfBlocksLabel">
284291
<property name="text">
285292
<string>Current number of blocks</string>
286293
</property>
287294
</widget>
288295
</item>
289-
<item row="12" column="1">
296+
<item row="13" column="1">
290297
<widget class="QLabel" name="numberOfBlocks">
291298
<property name="cursor">
292299
<cursorShape>IBeamCursor</cursorShape>
@@ -302,14 +309,14 @@
302309
</property>
303310
</widget>
304311
</item>
305-
<item row="13" column="0">
312+
<item row="14" column="0">
306313
<widget class="QLabel" name="lastBlockTimeLabel">
307314
<property name="text">
308315
<string>Last block time</string>
309316
</property>
310317
</widget>
311318
</item>
312-
<item row="13" column="1">
319+
<item row="14" column="1">
313320
<widget class="QLabel" name="lastBlockTime">
314321
<property name="cursor">
315322
<cursorShape>IBeamCursor</cursorShape>
@@ -325,7 +332,7 @@
325332
</property>
326333
</widget>
327334
</item>
328-
<item row="14" column="0">
335+
<item row="16" column="0">
329336
<spacer name="verticalSpacer_2">
330337
<property name="orientation">
331338
<enum>Qt::Vertical</enum>
@@ -338,7 +345,7 @@
338345
</property>
339346
</spacer>
340347
</item>
341-
<item row="15" column="0">
348+
<item row="17" column="0">
342349
<widget class="QLabel" name="debugLogFileHeader">
343350
<property name="font">
344351
<font>
@@ -351,7 +358,7 @@
351358
</property>
352359
</widget>
353360
</item>
354-
<item row="16" column="0">
361+
<item row="18" column="0">
355362
<widget class="QPushButton" name="openDebugLogfileButton">
356363
<property name="toolTip">
357364
<string>Open the PIVX debug log file from the current data directory. This can take a few seconds for large log files.</string>
@@ -364,6 +371,27 @@
364371
</property>
365372
</widget>
366373
</item>
374+
<item row="7" column="0">
375+
<widget class="QLabel" name="dataDirLabel">
376+
<property name="text">
377+
<string>Data Directory</string>
378+
</property>
379+
</widget>
380+
</item>
381+
<item row="15" column="0">
382+
<widget class="QLabel" name="lastBlockHashLabel">
383+
<property name="text">
384+
<string>Last block hash</string>
385+
</property>
386+
</widget>
387+
</item>
388+
<item row="15" column="1">
389+
<widget class="QLabel" name="lastBlockHash">
390+
<property name="text">
391+
<string>N/A</string>
392+
</property>
393+
</widget>
394+
</item>
367395
</layout>
368396
</widget>
369397
<widget class="QWidget" name="tab_console">
@@ -1298,19 +1326,22 @@
12981326
</item>
12991327
<item row="3" column="0">
13001328
<widget class="QLabel" name="wallet_custombackuppath_label">
1301-
<property name="text">
1302-
<string>Custom Backup Path:</string>
1303-
</property>
13041329
<property name="visible">
13051330
<bool>false</bool>
13061331
</property>
1332+
<property name="text">
1333+
<string>Custom Backup Path:</string>
1334+
</property>
13071335
</widget>
13081336
</item>
13091337
<item row="3" column="1" colspan="3">
13101338
<widget class="QLabel" name="wallet_custombackuppath">
13111339
<property name="cursor">
13121340
<cursorShape>IBeamCursor</cursorShape>
13131341
</property>
1342+
<property name="visible">
1343+
<bool>false</bool>
1344+
</property>
13141345
<property name="text">
13151346
<string>N/A</string>
13161347
</property>
@@ -1320,26 +1351,26 @@
13201351
<property name="textInteractionFlags">
13211352
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
13221353
</property>
1323-
<property name="visible">
1324-
<bool>false</bool>
1325-
</property>
13261354
</widget>
13271355
</item>
13281356
<item row="4" column="0">
13291357
<widget class="QLabel" name="wallet_customzpivbackuppath_label">
1330-
<property name="text">
1331-
<string>Custom zPIV Backup Path:</string>
1332-
</property>
13331358
<property name="visible">
13341359
<bool>false</bool>
13351360
</property>
1361+
<property name="text">
1362+
<string>Custom zPIV Backup Path:</string>
1363+
</property>
13361364
</widget>
13371365
</item>
13381366
<item row="4" column="1" colspan="3">
13391367
<widget class="QLabel" name="wallet_customzpivbackuppath">
13401368
<property name="cursor">
13411369
<cursorShape>IBeamCursor</cursorShape>
13421370
</property>
1371+
<property name="visible">
1372+
<bool>false</bool>
1373+
</property>
13431374
<property name="text">
13441375
<string>N/A</string>
13451376
</property>
@@ -1349,26 +1380,26 @@
13491380
<property name="textInteractionFlags">
13501381
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
13511382
</property>
1352-
<property name="visible">
1353-
<bool>false</bool>
1354-
</property>
13551383
</widget>
13561384
</item>
13571385
<item row="5" column="0">
13581386
<widget class="QLabel" name="wallet_custombackupthreshold_label">
1359-
<property name="text">
1360-
<string>Custom Backups Threshold:</string>
1361-
</property>
13621387
<property name="visible">
13631388
<bool>false</bool>
13641389
</property>
1390+
<property name="text">
1391+
<string>Custom Backups Threshold:</string>
1392+
</property>
13651393
</widget>
13661394
</item>
13671395
<item row="5" column="1" colspan="3">
13681396
<widget class="QLabel" name="wallet_custombackupthreshold">
13691397
<property name="cursor">
13701398
<cursorShape>IBeamCursor</cursorShape>
13711399
</property>
1400+
<property name="visible">
1401+
<bool>false</bool>
1402+
</property>
13721403
<property name="text">
13731404
<string>N/A</string>
13741405
</property>
@@ -1378,9 +1409,6 @@
13781409
<property name="textInteractionFlags">
13791410
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
13801411
</property>
1381-
<property name="visible">
1382-
<bool>false</bool>
1383-
</property>
13841412
</widget>
13851413
</item>
13861414
<item row="6" column="0">

src/qt/rpcconsole.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ void RPCConsole::setClientModel(ClientModel* model)
491491
ui->clientVersion->setText(model->formatFullVersion());
492492
ui->clientName->setText(model->clientName());
493493
ui->buildDate->setText(model->formatBuildDate());
494+
ui->dataDir->setText(model->dataDir());
494495
ui->startupTime->setText(model->formatClientStartupTime());
495496
ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));
496497

@@ -686,8 +687,10 @@ void RPCConsole::setNumConnections(int count)
686687
void RPCConsole::setNumBlocks(int count)
687688
{
688689
ui->numberOfBlocks->setText(QString::number(count));
689-
if (clientModel)
690+
if (clientModel) {
690691
ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString());
692+
ui->lastBlockHash->setText(clientModel->getLastBlockHash());
693+
}
691694
}
692695

693696
void RPCConsole::setMasternodeCount(const QString& strMasternodes)

0 commit comments

Comments
 (0)