Skip to content

Commit e491174

Browse files
author
MarcoFalke
committed
Merge bitcoin-core#226: Add "Last Block" and "Last Tx" rows to peer details area
70d3c5d gui: add "Last Block" (CNodeStats::nLastBlockTime) to peer details (Jon Atack) a21be7c gui: add "Last Tx" (CNodeStats::nLastTXTime) to peer details (Jon Atack) 4dc2fd6 qt: add RPCConsole::TimeDurationField helper, call systime only once (Jon Atack) Pull request description: - add `RPCConsole::TimeDurationField` helper to replace repeated code and call system time only once in `RPCConsole::updateDetailWidget` - add "Last Tx" (`CNodeStats::nLastTXTime`) field to peer details - add "Last Block" (`CNodeStats::nLastBlockTime`) field to peer details ACKs for top commit: hebasto: re-ACK 70d3c5d Tree-SHA512: 2611b71fd358ba9ffb6a6206275c08ecb5e683b6f87d022faaaba9802a15030430113afdb434814a9ae2681d04429aa733164bc110b64337ceaae12a0420f4f1
2 parents c0e44ee + 70d3c5d commit e491174

File tree

3 files changed

+82
-22
lines changed

3 files changed

+82
-22
lines changed

src/qt/forms/debugwindow.ui

Lines changed: 71 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@
10791079
<item row="1" column="0">
10801080
<widget class="QLabel" name="peerConnectionTypeLabel">
10811081
<property name="toolTip">
1082-
<string>The direction and type of peer connection: %1</string>
1082+
<string>The direction and type of peer connection: %1</string>
10831083
</property>
10841084
<property name="text">
10851085
<string>Direction/Type</string>
@@ -1342,13 +1342,65 @@
13421342
</widget>
13431343
</item>
13441344
<item row="12" column="0">
1345+
<widget class="QLabel" name="peerLastBlockLabel">
1346+
<property name="toolTip">
1347+
<string>Elapsed time since a novel block passing initial validity checks was received from this peer.</string>
1348+
</property>
1349+
<property name="text">
1350+
<string>Last Block</string>
1351+
</property>
1352+
</widget>
1353+
</item>
1354+
<item row="12" column="1">
1355+
<widget class="QLabel" name="peerLastBlock">
1356+
<property name="cursor">
1357+
<cursorShape>IBeamCursor</cursorShape>
1358+
</property>
1359+
<property name="text">
1360+
<string>N/A</string>
1361+
</property>
1362+
<property name="textFormat">
1363+
<enum>Qt::PlainText</enum>
1364+
</property>
1365+
<property name="textInteractionFlags">
1366+
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
1367+
</property>
1368+
</widget>
1369+
</item>
1370+
<item row="13" column="0">
1371+
<widget class="QLabel" name="peerLastTxLabel">
1372+
<property name="toolTip">
1373+
<string>Elapsed time since a novel transaction accepted into our mempool was received from this peer.</string>
1374+
</property>
1375+
<property name="text">
1376+
<string>Last Tx</string>
1377+
</property>
1378+
</widget>
1379+
</item>
1380+
<item row="13" column="1">
1381+
<widget class="QLabel" name="peerLastTx">
1382+
<property name="cursor">
1383+
<cursorShape>IBeamCursor</cursorShape>
1384+
</property>
1385+
<property name="text">
1386+
<string>N/A</string>
1387+
</property>
1388+
<property name="textFormat">
1389+
<enum>Qt::PlainText</enum>
1390+
</property>
1391+
<property name="textInteractionFlags">
1392+
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
1393+
</property>
1394+
</widget>
1395+
</item>
1396+
<item row="14" column="0">
13451397
<widget class="QLabel" name="label_15">
13461398
<property name="text">
13471399
<string>Last Send</string>
13481400
</property>
13491401
</widget>
13501402
</item>
1351-
<item row="12" column="1">
1403+
<item row="14" column="1">
13521404
<widget class="QLabel" name="peerLastSend">
13531405
<property name="cursor">
13541406
<cursorShape>IBeamCursor</cursorShape>
@@ -1364,14 +1416,14 @@
13641416
</property>
13651417
</widget>
13661418
</item>
1367-
<item row="13" column="0">
1419+
<item row="15" column="0">
13681420
<widget class="QLabel" name="label_19">
13691421
<property name="text">
13701422
<string>Last Receive</string>
13711423
</property>
13721424
</widget>
13731425
</item>
1374-
<item row="13" column="1">
1426+
<item row="15" column="1">
13751427
<widget class="QLabel" name="peerLastRecv">
13761428
<property name="cursor">
13771429
<cursorShape>IBeamCursor</cursorShape>
@@ -1387,14 +1439,14 @@
13871439
</property>
13881440
</widget>
13891441
</item>
1390-
<item row="14" column="0">
1442+
<item row="16" column="0">
13911443
<widget class="QLabel" name="label_18">
13921444
<property name="text">
13931445
<string>Sent</string>
13941446
</property>
13951447
</widget>
13961448
</item>
1397-
<item row="14" column="1">
1449+
<item row="16" column="1">
13981450
<widget class="QLabel" name="peerBytesSent">
13991451
<property name="cursor">
14001452
<cursorShape>IBeamCursor</cursorShape>
@@ -1410,14 +1462,14 @@
14101462
</property>
14111463
</widget>
14121464
</item>
1413-
<item row="15" column="0">
1465+
<item row="17" column="0">
14141466
<widget class="QLabel" name="label_20">
14151467
<property name="text">
14161468
<string>Received</string>
14171469
</property>
14181470
</widget>
14191471
</item>
1420-
<item row="15" column="1">
1472+
<item row="17" column="1">
14211473
<widget class="QLabel" name="peerBytesRecv">
14221474
<property name="cursor">
14231475
<cursorShape>IBeamCursor</cursorShape>
@@ -1433,14 +1485,14 @@
14331485
</property>
14341486
</widget>
14351487
</item>
1436-
<item row="16" column="0">
1488+
<item row="18" column="0">
14371489
<widget class="QLabel" name="label_26">
14381490
<property name="text">
14391491
<string>Ping Time</string>
14401492
</property>
14411493
</widget>
14421494
</item>
1443-
<item row="16" column="1">
1495+
<item row="18" column="1">
14441496
<widget class="QLabel" name="peerPingTime">
14451497
<property name="cursor">
14461498
<cursorShape>IBeamCursor</cursorShape>
@@ -1456,7 +1508,7 @@
14561508
</property>
14571509
</widget>
14581510
</item>
1459-
<item row="17" column="0">
1511+
<item row="19" column="0">
14601512
<widget class="QLabel" name="peerPingWaitLabel">
14611513
<property name="toolTip">
14621514
<string>The duration of a currently outstanding ping.</string>
@@ -1466,7 +1518,7 @@
14661518
</property>
14671519
</widget>
14681520
</item>
1469-
<item row="17" column="1">
1521+
<item row="19" column="1">
14701522
<widget class="QLabel" name="peerPingWait">
14711523
<property name="cursor">
14721524
<cursorShape>IBeamCursor</cursorShape>
@@ -1482,14 +1534,14 @@
14821534
</property>
14831535
</widget>
14841536
</item>
1485-
<item row="18" column="0">
1537+
<item row="20" column="0">
14861538
<widget class="QLabel" name="peerMinPingLabel">
14871539
<property name="text">
14881540
<string>Min Ping</string>
14891541
</property>
14901542
</widget>
14911543
</item>
1492-
<item row="18" column="1">
1544+
<item row="20" column="1">
14931545
<widget class="QLabel" name="peerMinPing">
14941546
<property name="cursor">
14951547
<cursorShape>IBeamCursor</cursorShape>
@@ -1505,14 +1557,14 @@
15051557
</property>
15061558
</widget>
15071559
</item>
1508-
<item row="19" column="0">
1560+
<item row="21" column="0">
15091561
<widget class="QLabel" name="label_timeoffset">
15101562
<property name="text">
15111563
<string>Time Offset</string>
15121564
</property>
15131565
</widget>
15141566
</item>
1515-
<item row="19" column="1">
1567+
<item row="21" column="1">
15161568
<widget class="QLabel" name="timeoffset">
15171569
<property name="cursor">
15181570
<cursorShape>IBeamCursor</cursorShape>
@@ -1528,7 +1580,7 @@
15281580
</property>
15291581
</widget>
15301582
</item>
1531-
<item row="20" column="0">
1583+
<item row="22" column="0">
15321584
<widget class="QLabel" name="peerMappedASLabel">
15331585
<property name="toolTip">
15341586
<string>The mapped Autonomous System used for diversifying peer selection.</string>
@@ -1538,7 +1590,7 @@
15381590
</property>
15391591
</widget>
15401592
</item>
1541-
<item row="20" column="1">
1593+
<item row="22" column="1">
15421594
<widget class="QLabel" name="peerMappedAS">
15431595
<property name="cursor">
15441596
<cursorShape>IBeamCursor</cursorShape>
@@ -1554,7 +1606,7 @@
15541606
</property>
15551607
</widget>
15561608
</item>
1557-
<item row="21" column="0">
1609+
<item row="23" column="0">
15581610
<spacer name="verticalSpacer_3">
15591611
<property name="orientation">
15601612
<enum>Qt::Vertical</enum>

src/qt/rpcconsole.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,11 +1120,14 @@ void RPCConsole::updateDetailWidget()
11201120
if (stats->nodeStats.m_bip152_highbandwidth_from) bip152_hb_settings += (bip152_hb_settings == "" ? "From" : "/From");
11211121
if (bip152_hb_settings == "") bip152_hb_settings = "No";
11221122
ui->peerHighBandwidth->setText(bip152_hb_settings);
1123-
ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastSend) : tr("never"));
1124-
ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastRecv) : tr("never"));
1123+
const int64_t time_now{GetSystemTimeInSeconds()};
1124+
ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - stats->nodeStats.nTimeConnected));
1125+
ui->peerLastBlock->setText(TimeDurationField(time_now, stats->nodeStats.nLastBlockTime));
1126+
ui->peerLastTx->setText(TimeDurationField(time_now, stats->nodeStats.nLastTXTime));
1127+
ui->peerLastSend->setText(TimeDurationField(time_now, stats->nodeStats.nLastSend));
1128+
ui->peerLastRecv->setText(TimeDurationField(time_now, stats->nodeStats.nLastRecv));
11251129
ui->peerBytesSent->setText(GUIUtil::formatBytes(stats->nodeStats.nSendBytes));
11261130
ui->peerBytesRecv->setText(GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
1127-
ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nTimeConnected));
11281131
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.m_ping_usec));
11291132
ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.m_min_ping_usec));
11301133
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));

src/qt/rpcconsole.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ public Q_SLOTS:
168168
/** Update UI with latest network info from model. */
169169
void updateNetworkState();
170170

171+
/** Helper for the output of a time duration field. Inputs are UNIX epoch times. */
172+
QString TimeDurationField(uint64_t time_now, uint64_t time_at_event) const {
173+
return time_at_event ? GUIUtil::formatDurationStr(time_now - time_at_event) : tr("Never");
174+
}
175+
171176
private Q_SLOTS:
172177
void updateAlerts(const QString& warnings);
173178
};

0 commit comments

Comments
 (0)