Skip to content

Commit d1ddead

Browse files
committed
Merge bitcoin-core#180: Peer details: connection type follow-ups
79a2576 doc: update ConnectionType Doxygen documentation (Jon Atack) f3153dc gui: improve markup handling of connection type tooltip (Jon Atack) 4f09615 gui: return inbound {full, block} relay type in peer details (Jon Atack) Pull request description: Three follow-ups to bitcoin-core#163: - return relay type for inbound peers - improve markup handling in the tooltip to facilitate translations - update ConnectionType doxygen documentation ![Screenshot from 2021-01-11 08-37-44](https://user-images.githubusercontent.com/2415484/104156081-50e69300-53e0-11eb-9b0f-880cb5626d68.png) ACKs for top commit: hebasto: re-ACK 79a2576, only suggested changes since my [previous](bitcoin-core#180 (review)) review. jarolrod: ACK 79a2576, tested on macOS 11.1 with Qt 5.15.2 laanwj: Code review ACK 79a2576 Tree-SHA512: 4a8d8f8bfbaefd68e8d1bf3b20d29e4a8e8cfe97b2f8d59d3a4c338a50b61de0a67d97bd8646c04bd5df5a9679c4954b9b46e7cba24bb89f4d0e44e94cf9d66c
2 parents 15a9df0 + 79a2576 commit d1ddead

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

src/net.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ struct CSerializedNetMsg
111111
* connection. Aside from INBOUND, all types are initiated by us.
112112
*
113113
* If adding or removing types, please update CONNECTION_TYPE_DOC in
114-
* src/rpc/net.cpp. */
114+
* src/rpc/net.cpp and src/qt/rpcconsole.cpp, as well as the descriptions in
115+
* src/qt/guiutil.cpp and src/bitcoin-cli.cpp::NetinfoRequestHandler. */
115116
enum class ConnectionType {
116117
/**
117118
* Inbound connections are those initiated by a peer. This is the only
@@ -122,16 +123,16 @@ enum class ConnectionType {
122123

123124
/**
124125
* These are the default connections that we use to connect with the
125-
* network. There is no restriction on what is relayed- by default we relay
126+
* network. There is no restriction on what is relayed; by default we relay
126127
* blocks, addresses & transactions. We automatically attempt to open
127128
* MAX_OUTBOUND_FULL_RELAY_CONNECTIONS using addresses from our AddrMan.
128129
*/
129130
OUTBOUND_FULL_RELAY,
130131

131132

132133
/**
133-
* We open manual connections to addresses that users explicitly inputted
134-
* via the addnode RPC, or the -connect command line argument. Even if a
134+
* We open manual connections to addresses that users explicitly requested
135+
* via the addnode RPC or the -addnode/-connect configuration options. Even if a
135136
* manual connection is misbehaving, we do not automatically disconnect or
136137
* add it to our discouragement filter.
137138
*/
@@ -150,7 +151,7 @@ enum class ConnectionType {
150151
* although in our codebase feeler connections encompass test-before-evict as well.
151152
* We make these connections approximately every FEELER_INTERVAL:
152153
* first we resolve previously found collisions if they exist (test-before-evict),
153-
* otherwise connect to a node from the new table.
154+
* otherwise we connect to a node from the new table.
154155
*/
155156
FEELER,
156157

src/qt/forms/debugwindow.ui

Lines changed: 1 addition & 1 deletion
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 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>
1082+
<string>The type of peer connection: %1</string>
10831083
</property>
10841084
<property name="text">
10851085
<string>Connection Type</string>

src/qt/guiutil.cpp

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

767-
QString ConnectionTypeToQString(ConnectionType conn_type)
767+
QString ConnectionTypeToQString(ConnectionType conn_type, bool relay_txes)
768768
{
769769
switch (conn_type) {
770-
case ConnectionType::INBOUND: return QObject::tr("Inbound");
770+
case ConnectionType::INBOUND: return relay_txes ? QObject::tr("Inbound Full Relay") : QObject::tr("Inbound Block Relay");
771771
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
772772
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
773773
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");

src/qt/guiutil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ namespace GUIUtil
230230
QString NetworkToQString(Network net);
231231

232232
/** Convert enum ConnectionType to QString */
233-
QString ConnectionTypeToQString(ConnectionType conn_type);
233+
QString ConnectionTypeToQString(ConnectionType conn_type, bool relay_txes);
234234

235235
/** Convert seconds into a QString with days, hours, mins, secs */
236236
QString formatDurationStr(int secs);

src/qt/rpcconsole.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
#include <chainparams.h>
1717
#include <interfaces/node.h>
1818
#include <netbase.h>
19-
#include <rpc/server.h>
2019
#include <rpc/client.h>
20+
#include <rpc/server.h>
2121
#include <util/strencodings.h>
22+
#include <util/string.h>
2223
#include <util/system.h>
2324
#include <util/threadnames.h>
2425

@@ -459,11 +460,22 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
459460

460461
ui->splitter->restoreState(settings.value("PeersTabSplitterSizes").toByteArray());
461462

462-
QChar nonbreaking_hyphen(8209);
463+
constexpr QChar nonbreaking_hyphen(8209);
464+
const std::vector<QString> CONNECTION_TYPE_DOC{
465+
tr("Inbound Full/Block Relay: initiated by peer"),
466+
tr("Outbound Full Relay: default"),
467+
tr("Outbound Block Relay: does not relay transactions or addresses"),
468+
tr("Outbound Manual: added using RPC %1 or %2/%3 configuration options")
469+
.arg("addnode")
470+
.arg(QString(nonbreaking_hyphen) + "addnode")
471+
.arg(QString(nonbreaking_hyphen) + "connect"),
472+
tr("Outbound Feeler: short-lived, for testing addresses"),
473+
tr("Outbound Address Fetch: short-lived, for soliciting addresses")};
474+
const QString list{"<ul><li>" + Join(CONNECTION_TYPE_DOC, QString("</li><li>")) + "</li></ul>"};
475+
ui->peerConnectionTypeLabel->setToolTip(ui->peerConnectionTypeLabel->toolTip().arg(list));
463476
ui->dataDir->setToolTip(ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) + "datadir"));
464477
ui->blocksDir->setToolTip(ui->blocksDir->toolTip().arg(QString(nonbreaking_hyphen) + "blocksdir"));
465478
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"));
467479

468480
if (platformStyle->getImagesOnButtons()) {
469481
ui->openDebugLogfileButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
@@ -1108,7 +1120,7 @@ void RPCConsole::updateDetailWidget()
11081120
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
11091121
ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
11101122
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
1111-
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type));
1123+
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type, stats->nodeStats.fRelayTxes));
11121124
ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network));
11131125
if (stats->nodeStats.m_permissionFlags == PF_NONE) {
11141126
ui->peerPermissions->setText(tr("N/A"));

0 commit comments

Comments
 (0)