Skip to content

Commit 0944024

Browse files
author
MarcoFalke
committed
Merge bitcoin-core#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 bitcoin-core#159. ACKs for top commit: hebasto: re-ACK 06ba9b3, the tooltip content is organized as unordered list. jarolrod: re-ACK 06ba9b3 Tree-SHA512: 24f46494ceb42ed308e4a4f2a543dbc4f4e6409a6f738c145a9f16e175bf69d411cbc944a4fd969f1829d57644dfbc194182fa8d4e9e6bce82acbeca8c673748
2 parents 555fc07 + 06ba9b3 commit 0944024

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

src/qt/forms/debugwindow.ui

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,14 +1077,17 @@
10771077
</widget>
10781078
</item>
10791079
<item row="1" column="0">
1080-
<widget class="QLabel" name="label_23">
1080+
<widget class="QLabel" name="peerConnectionTypeLabel">
1081+
<property name="toolTip">
1082+
<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>
1083+
</property>
10811084
<property name="text">
1082-
<string>Direction</string>
1085+
<string>Connection Type</string>
10831086
</property>
10841087
</widget>
10851088
</item>
10861089
<item row="1" column="1">
1087-
<widget class="QLabel" name="peerDirection">
1090+
<widget class="QLabel" name="peerConnectionType">
10881091
<property name="cursor">
10891092
<cursorShape>IBeamCursor</cursorShape>
10901093
</property>

src/qt/guiutil.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,19 @@ QString NetworkToQString(Network net)
764764
assert(false);
765765
}
766766

767+
QString ConnectionTypeToQString(ConnectionType conn_type)
768+
{
769+
switch (conn_type) {
770+
case ConnectionType::INBOUND: return QObject::tr("Inbound");
771+
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
772+
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
773+
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
774+
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
775+
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
776+
} // no default case, so the compiler can warn about missing cases
777+
assert(false);
778+
}
779+
767780
QString formatDurationStr(int secs)
768781
{
769782
QStringList strList;

src/qt/guiutil.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77

88
#include <amount.h>
99
#include <fs.h>
10+
#include <net.h>
1011
#include <netaddress.h>
1112

1213
#include <QEvent>
1314
#include <QHeaderView>
1415
#include <QItemDelegate>
16+
#include <QLabel>
1517
#include <QMessageBox>
1618
#include <QObject>
1719
#include <QProgressBar>
1820
#include <QString>
1921
#include <QTableView>
20-
#include <QLabel>
2122

2223
class QValidatedLineEdit;
2324
class SendCoinsRecipient;
@@ -228,6 +229,9 @@ namespace GUIUtil
228229
/** Convert enum Network to QString */
229230
QString NetworkToQString(Network net);
230231

232+
/** Convert enum ConnectionType to QString */
233+
QString ConnectionTypeToQString(ConnectionType conn_type);
234+
231235
/** Convert seconds into a QString with days, hours, mins, secs */
232236
QString formatDurationStr(int secs);
233237

src/qt/rpcconsole.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
463463
ui->dataDir->setToolTip(ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) + "datadir"));
464464
ui->blocksDir->setToolTip(ui->blocksDir->toolTip().arg(QString(nonbreaking_hyphen) + "blocksdir"));
465465
ui->openDebugLogfileButton->setToolTip(ui->openDebugLogfileButton->toolTip().arg(PACKAGE_NAME));
466+
ui->peerConnectionTypeLabel->setToolTip(ui->peerConnectionTypeLabel->toolTip().arg("addnode").arg(QString(nonbreaking_hyphen) + "addnode").arg(QString(nonbreaking_hyphen) + "connect"));
466467

467468
if (platformStyle->getImagesOnButtons()) {
468469
ui->openDebugLogfileButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
@@ -1111,7 +1112,7 @@ void RPCConsole::updateDetailWidget()
11111112
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
11121113
ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
11131114
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
1114-
ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound"));
1115+
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type));
11151116
ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network));
11161117
if (stats->nodeStats.m_permissionFlags == PF_NONE) {
11171118
ui->peerPermissions->setText(tr("N/A"));

src/rpc/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ static RPCHelpMan getpeerinfo()
128128
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
129129
{RPCResult::Type::BOOL, "bip152_hb_to", "Whether we selected peer as (compact blocks) high-bandwidth peer"},
130130
{RPCResult::Type::BOOL, "bip152_hb_from", "Whether peer selected us as (compact blocks) high-bandwidth peer"},
131-
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
132-
"Please note this output is unlikely to be stable in upcoming releases as we iterate to\n"
133-
"best capture connection behaviors."},
134131
{RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
135132
{RPCResult::Type::NUM, "synced_headers", "The last header we have in common with this peer"},
136133
{RPCResult::Type::NUM, "synced_blocks", "The last block we have in common with this peer"},
@@ -156,6 +153,9 @@ static RPCHelpMan getpeerinfo()
156153
"Only known message types can appear as keys in the object and all bytes received\n"
157154
"of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'."}
158155
}},
156+
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
157+
"Please note this output is unlikely to be stable in upcoming releases as we iterate to\n"
158+
"best capture connection behaviors."},
159159
}},
160160
}},
161161
},

0 commit comments

Comments
 (0)