Skip to content

Commit

Permalink
Add "Last Block" and "Last Tx" rows to peer details area
Browse files Browse the repository at this point in the history
Summary:
> qt: add RPCConsole::TimeDurationField helper, call systime only once

> gui: add "Last Tx" (CNodeStats::nLastTXTime) to peer details

> gui: add "Last Block" (CNodeStats::nLastBlockTime) to peer details

This is a backport of [[bitcoin-core/gui#226 | core-gui#226]]
Depends on D10963

Test Plan:
`ninja && src/qt/bitcoin-qt`

Select a peer in the "peers" view, check the new "Last Block/Tx" fields. Wait for a while to see it change from "Never" to a duration.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10964
  • Loading branch information
jonatack authored and PiRK committed Feb 3, 2022
1 parent 3681ffe commit 85e5bdc
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 28 deletions.
88 changes: 70 additions & 18 deletions src/qt/forms/debugwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1371,13 +1371,65 @@
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="peerLastBlockLabel">
<property name="toolTip">
<string>Elapsed time since a novel block passing initial validity checks was received from this peer.</string>
</property>
<property name="text">
<string>Last Block</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QLabel" name="peerLastBlock">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string>N/A</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="peerLastTxLabel">
<property name="toolTip">
<string>Elapsed time since a novel transaction accepted into our mempool was received from this peer.</string>
</property>
<property name="text">
<string>Last Tx</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLabel" name="peerLastTx">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string>N/A</string>
</property>
<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="label_15">
<property name="text">
<string>Last Send</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="14" column="1">
<widget class="QLabel" name="peerLastSend">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -1393,14 +1445,14 @@
</property>
</widget>
</item>
<item row="13" column="0">
<item row="15" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Last Receive</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="15" column="1">
<widget class="QLabel" name="peerLastRecv">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -1416,14 +1468,14 @@
</property>
</widget>
</item>
<item row="14" column="0">
<item row="16" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Sent</string>
</property>
</widget>
</item>
<item row="14" column="1">
<item row="16" column="1">
<widget class="QLabel" name="peerBytesSent">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -1439,14 +1491,14 @@
</property>
</widget>
</item>
<item row="15" column="0">
<item row="17" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Received</string>
</property>
</widget>
</item>
<item row="15" column="1">
<item row="17" column="1">
<widget class="QLabel" name="peerBytesRecv">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -1462,14 +1514,14 @@
</property>
</widget>
</item>
<item row="16" column="0">
<item row="18" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Ping Time</string>
</property>
</widget>
</item>
<item row="16" column="1">
<item row="18" column="1">
<widget class="QLabel" name="peerPingTime">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -1485,7 +1537,7 @@
</property>
</widget>
</item>
<item row="17" column="0">
<item row="19" column="0">
<widget class="QLabel" name="peerPingWaitLabel">
<property name="toolTip">
<string>The duration of a currently outstanding ping.</string>
Expand All @@ -1495,7 +1547,7 @@
</property>
</widget>
</item>
<item row="17" column="1">
<item row="19" column="1">
<widget class="QLabel" name="peerPingWait">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -1511,14 +1563,14 @@
</property>
</widget>
</item>
<item row="18" column="0">
<item row="20" column="0">
<widget class="QLabel" name="peerMinPingLabel">
<property name="text">
<string>Min Ping</string>
</property>
</widget>
</item>
<item row="18" column="1">
<item row="20" column="1">
<widget class="QLabel" name="peerMinPing">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -1534,14 +1586,14 @@
</property>
</widget>
</item>
<item row="19" column="0">
<item row="21" column="0">
<widget class="QLabel" name="label_timeoffset">
<property name="text">
<string>Time Offset</string>
</property>
</widget>
</item>
<item row="19" column="1">
<item row="21" column="1">
<widget class="QLabel" name="timeoffset">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -1557,7 +1609,7 @@
</property>
</widget>
</item>
<item row="20" column="0">
<item row="22" column="0">
<widget class="QLabel" name="peerMappedASLabel">
<property name="toolTip">
<string>The mapped Autonomous System used for diversifying peer selection.</string>
Expand All @@ -1567,7 +1619,7 @@
</property>
</widget>
</item>
<item row="20" column="1">
<item row="22" column="1">
<widget class="QLabel" name="peerMappedAS">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -1583,7 +1635,7 @@
</property>
</widget>
</item>
<item row="21" column="0">
<item row="23" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down
19 changes: 9 additions & 10 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,22 +1283,21 @@ void RPCConsole::updateDetailWidget() {
bip152_hb_settings = "No";
}
ui->peerHighBandwidth->setText(bip152_hb_settings);
const int64_t time_now{GetTimeSeconds()};
ui->peerConnTime->setText(
GUIUtil::formatDurationStr(time_now - stats->nodeStats.nTimeConnected));
ui->peerLastBlock->setText(
TimeDurationField(time_now, stats->nodeStats.nLastBlockTime));
ui->peerLastTx->setText(
TimeDurationField(time_now, stats->nodeStats.nLastTXTime));
ui->peerLastSend->setText(
stats->nodeStats.m_last_send
? GUIUtil::formatDurationStr(GetTimeSeconds() -
stats->nodeStats.m_last_send)
: tr("never"));
TimeDurationField(time_now, stats->nodeStats.m_last_send));
ui->peerLastRecv->setText(
stats->nodeStats.m_last_recv
? GUIUtil::formatDurationStr(GetTimeSeconds() -
stats->nodeStats.m_last_recv)
: tr("never"));
TimeDurationField(time_now, stats->nodeStats.m_last_recv));
ui->peerBytesSent->setText(
GUIUtil::formatBytes(stats->nodeStats.nSendBytes));
ui->peerBytesRecv->setText(
GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
ui->peerConnTime->setText(GUIUtil::formatDurationStr(
GetTimeSeconds() - stats->nodeStats.nTimeConnected));
ui->peerPingTime->setText(
GUIUtil::formatPingTime(stats->nodeStats.m_last_ping_time));
ui->peerMinPing->setText(
Expand Down
10 changes: 10 additions & 0 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ public Q_SLOTS:
/** Update UI with latest network info from model. */
void updateNetworkState();

/**
* Helper for the output of a time duration field. Inputs are UNIX epoch
* times.
*/
QString TimeDurationField(uint64_t time_now, uint64_t time_at_event) const {
return time_at_event
? GUIUtil::formatDurationStr(time_now - time_at_event)
: tr("Never");
}

private Q_SLOTS:
void updateAlerts(const QString &warnings);
};
Expand Down

0 comments on commit 85e5bdc

Please sign in to comment.