Skip to content

Commit b8b3c4c

Browse files
MarcoFalkePastaPastaPasta
authored andcommitted
Merge bitcoin-core/gui#163: Peer details: replace Direction with Connection Type
06ba9b3 rpc: move getpeerinfo connection_type help to correct place (Jon Atack) c95fe6e gui: improve connection type tooltip (Hennadii Stepanov) 2c19ba2 gui: replace Direction with Connection Type in peer details (Jon Atack) 7e2beab gui: create GUIUtil::ConnectionTypeToQString utility function (Jon Atack) Pull request description: ![Screenshot from 2021-01-09 11-23-17](https://user-images.githubusercontent.com/2415484/104089297-c5e18d80-5265-11eb-9251-49afcfdb562b.png) Closes dashpay#159. ACKs for top commit: hebasto: re-ACK 06ba9b3, the tooltip content is organized as unordered list. jarolrod: re-ACK 06ba9b3 Tree-SHA512: 24f46494ceb42ed308e4a4f2a543dbc4f4e6409a6f738c145a9f16e175bf69d411cbc944a4fd969f1829d57644dfbc194182fa8d4e9e6bce82acbeca8c673748
1 parent 00b828c commit b8b3c4c

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

src/qt/forms/debugwindow.ui

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,14 +1026,17 @@
10261026
</widget>
10271027
</item>
10281028
<item row="4" column="0">
1029-
<widget class="QLabel" name="label_23">
1029+
<widget class="QLabel" name="peerConnectionTypeLabel">
1030+
<property name="toolTip">
1031+
<string>The type of peer connection:&lt;ul&gt;&lt;li&gt;Inbound: initiated by peer&lt;/li&gt;&lt;li&gt;Outbound Full Relay: default&lt;/li&gt;&lt;li&gt;Outbound Block Relay: does not relay transactions or addresses&lt;/li&gt;&lt;li&gt;Outbound Manual: added using RPC %1 or %2/%3 configuration options&lt;/li&gt;&lt;li&gt;Outbound Feeler: short-lived, for testing addresses&lt;/li&gt;&lt;li&gt;Outbound Address Fetch: short-lived, for soliciting addresses&lt;/li&gt;&lt;/ul&gt;</string>
1032+
</property>
10301033
<property name="text">
1031-
<string>Direction</string>
1034+
<string>Connection Type</string>
10321035
</property>
10331036
</widget>
10341037
</item>
10351038
<item row="4" column="2">
1036-
<widget class="QLabel" name="peerDirection">
1039+
<widget class="QLabel" name="peerConnectionType">
10371040
<property name="cursor">
10381041
<cursorShape>IBeamCursor</cursorShape>
10391042
</property>

src/qt/guiutil.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,19 @@ QString NetworkToQString(Network net)
16601660
assert(false);
16611661
}
16621662

1663+
QString ConnectionTypeToQString(ConnectionType conn_type)
1664+
{
1665+
switch (conn_type) {
1666+
case ConnectionType::INBOUND: return QObject::tr("Inbound");
1667+
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
1668+
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
1669+
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
1670+
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
1671+
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
1672+
} // no default case, so the compiler can warn about missing cases
1673+
assert(false);
1674+
}
1675+
16631676
QString formatDurationStr(int secs)
16641677
{
16651678
QStringList strList;

src/qt/guiutil.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88
#include <amount.h>
99
#include <fs.h>
1010
#include <qt/guiconstants.h>
11+
#include <net.h>
1112
#include <netaddress.h>
1213
#include <util/check.h>
1314

1415
#include <QApplication>
1516
#include <QEvent>
1617
#include <QHeaderView>
1718
#include <QItemDelegate>
19+
#include <QLabel>
1820
#include <QMessageBox>
1921
#include <QMetaObject>
2022
#include <QObject>
2123
#include <QProgressBar>
2224
#include <QString>
2325
#include <QTableView>
24-
#include <QLabel>
2526

2627
#include <cassert>
2728
#include <chrono>
@@ -396,6 +397,9 @@ namespace GUIUtil
396397
/** Convert enum Network to QString */
397398
QString NetworkToQString(Network net);
398399

400+
/** Convert enum ConnectionType to QString */
401+
QString ConnectionTypeToQString(ConnectionType conn_type);
402+
399403
/** Convert seconds into a QString with days, hours, mins, secs */
400404
QString formatDurationStr(int secs);
401405

src/qt/rpcconsole.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, QWidget* parent, Qt::WindowFlags
479479
ui->dataDir->setToolTip(ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) + "datadir"));
480480
ui->blocksDir->setToolTip(ui->blocksDir->toolTip().arg(QString(nonbreaking_hyphen) + "blocksdir"));
481481
ui->openDebugLogfileButton->setToolTip(ui->openDebugLogfileButton->toolTip().arg(PACKAGE_NAME));
482+
ui->peerConnectionTypeLabel->setToolTip(ui->peerConnectionTypeLabel->toolTip().arg("addnode").arg(QString(nonbreaking_hyphen) + "addnode").arg(QString(nonbreaking_hyphen) + "connect"));
482483

483484
setButtonIcons();
484485

@@ -1249,11 +1250,7 @@ void RPCConsole::updateDetailWidget()
12491250
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
12501251
ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
12511252
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
1252-
ui->peerDirection->setText(stats->nodeStats.fInbound
1253-
? tr("Inbound")
1254-
: stats->nodeStats.fRelayTxes
1255-
? tr("Outbound")
1256-
: tr("Outbound block-relay"));
1253+
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type));
12571254
ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network));
12581255
if (stats->nodeStats.m_permissionFlags == NetPermissionFlags::None) {
12591256
ui->peerPermissions->setText(tr("N/A"));

src/rpc/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ static RPCHelpMan getpeerinfo()
133133
{RPCResult::Type::STR, "subver", "The string version"},
134134
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
135135
{RPCResult::Type::BOOL, "addnode", "Whether connection was due to addnode/-connect or if it was an automatic/inbound connection"},
136-
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
137-
"Please note this output is unlikely to be stable in upcoming releases as we iterate to\n"
138-
"best capture connection behaviors."},
139136
{RPCResult::Type::BOOL, "masternode", "Whether connection was due to masternode connection attempt"},
140137
{RPCResult::Type::NUM, "banscore", "The ban score (DEPRECATED, returned only if config option -deprecatedrpc=banscore is passed)"},
141138
{RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
@@ -165,6 +162,9 @@ static RPCHelpMan getpeerinfo()
165162
"When a message type is not listed in this json object, the bytes received are 0.\n"
166163
"Only known message types can appear as keys in the object and all bytes received of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'."}
167164
}},
165+
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
166+
"Please note this output is unlikely to be stable in upcoming releases as we iterate to\n"
167+
"best capture connection behaviors."},
168168
}},
169169
}}},
170170
RPCExamples{

0 commit comments

Comments
 (0)