From 7e2beab2d28d8ab039d9554744a11592a7d7dc76 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Thu, 24 Dec 2020 12:35:37 +0100 Subject: [PATCH 1/4] gui: create GUIUtil::ConnectionTypeToQString utility function --- src/qt/guiutil.cpp | 13 +++++++++++++ src/qt/guiutil.h | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 8205b0506cd..430ecd322ff 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -764,6 +764,19 @@ QString NetworkToQString(Network net) assert(false); } +QString ConnectionTypeToQString(ConnectionType conn_type) +{ + switch (conn_type) { + case ConnectionType::INBOUND: return QObject::tr("Inbound"); + case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay"); + case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay"); + case ConnectionType::MANUAL: return QObject::tr("Outbound Manual"); + case ConnectionType::FEELER: return QObject::tr("Outbound Feeler"); + case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch"); + } // no default case, so the compiler can warn about missing cases + assert(false); +} + QString formatDurationStr(int secs) { QStringList strList; diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 4bef13efb53..c471b888f7b 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -7,17 +7,18 @@ #include #include +#include #include #include #include #include +#include #include #include #include #include #include -#include class QValidatedLineEdit; class SendCoinsRecipient; @@ -228,6 +229,9 @@ namespace GUIUtil /** Convert enum Network to QString */ QString NetworkToQString(Network net); + /** Convert enum ConnectionType to QString */ + QString ConnectionTypeToQString(ConnectionType conn_type); + /** Convert seconds into a QString with days, hours, mins, secs */ QString formatDurationStr(int secs); From 2c19ba2e1d26e2077da8b469f44588c20af87e23 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Thu, 24 Dec 2020 12:37:38 +0100 Subject: [PATCH 2/4] gui: replace Direction with Connection Type in peer details --- src/qt/forms/debugwindow.ui | 9 ++++++--- src/qt/rpcconsole.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index d8112117cc1..dc98df4ab6f 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -1077,14 +1077,17 @@ - + + + The type of peer connection:<ul><li>Inbound: initiated by peer</li><li>Outbound Full Relay: default</li><li>Outbound Block Relay: does not relay transactions or addresses</li><li>Outbound Manual: added using RPC addnode or -addnode/-connect configuration options</li><li>Outbound Feeler: short-lived, for testing addresses</li><li>Outbound Address Fetch: short-lived, for soliciting addresses</li></ul> + - Direction + Connection Type - + IBeamCursor diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 61f47e3ad31..981e5384c49 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -1111,7 +1111,7 @@ void RPCConsole::updateDetailWidget() ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset)); ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion)); ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer)); - ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound")); + ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type)); ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network)); if (stats->nodeStats.m_permissionFlags == PF_NONE) { ui->peerPermissions->setText(tr("N/A")); From c95fe6e38f542f9fe8ddb1522b5ff1cac17db4bf Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 25 Dec 2020 22:43:29 +0100 Subject: [PATCH 3/4] gui: improve connection type tooltip - remove RPC and option names from the translatable string - use non-breaking hyphens --- src/qt/forms/debugwindow.ui | 2 +- src/qt/rpcconsole.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index dc98df4ab6f..bce578a1584 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -1079,7 +1079,7 @@ - The type of peer connection:<ul><li>Inbound: initiated by peer</li><li>Outbound Full Relay: default</li><li>Outbound Block Relay: does not relay transactions or addresses</li><li>Outbound Manual: added using RPC addnode or -addnode/-connect configuration options</li><li>Outbound Feeler: short-lived, for testing addresses</li><li>Outbound Address Fetch: short-lived, for soliciting addresses</li></ul> + The type of peer connection:<ul><li>Inbound: initiated by peer</li><li>Outbound Full Relay: default</li><li>Outbound Block Relay: does not relay transactions or addresses</li><li>Outbound Manual: added using RPC %1 or %2/%3 configuration options</li><li>Outbound Feeler: short-lived, for testing addresses</li><li>Outbound Address Fetch: short-lived, for soliciting addresses</li></ul> Connection Type diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 981e5384c49..e081706c5ad 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -463,6 +463,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty ui->dataDir->setToolTip(ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) + "datadir")); ui->blocksDir->setToolTip(ui->blocksDir->toolTip().arg(QString(nonbreaking_hyphen) + "blocksdir")); ui->openDebugLogfileButton->setToolTip(ui->openDebugLogfileButton->toolTip().arg(PACKAGE_NAME)); + ui->peerConnectionTypeLabel->setToolTip(ui->peerConnectionTypeLabel->toolTip().arg("addnode").arg(QString(nonbreaking_hyphen) + "addnode").arg(QString(nonbreaking_hyphen) + "connect")); if (platformStyle->getImagesOnButtons()) { ui->openDebugLogfileButton->setIcon(platformStyle->SingleColorIcon(":/icons/export")); From 06ba9b300866f33e21512af9d7d2891ee1501bf4 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Sat, 26 Dec 2020 21:58:52 +0100 Subject: [PATCH 4/4] rpc: move getpeerinfo connection_type help to correct place per review feedback --- src/rpc/net.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index ddbd7e91428..c4561fa1b42 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -128,9 +128,6 @@ static RPCHelpMan getpeerinfo() {RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"}, {RPCResult::Type::BOOL, "bip152_hb_to", "Whether we selected peer as (compact blocks) high-bandwidth peer"}, {RPCResult::Type::BOOL, "bip152_hb_from", "Whether peer selected us as (compact blocks) high-bandwidth peer"}, - {RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n" - "Please note this output is unlikely to be stable in upcoming releases as we iterate to\n" - "best capture connection behaviors."}, {RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"}, {RPCResult::Type::NUM, "synced_headers", "The last header we have in common with this peer"}, {RPCResult::Type::NUM, "synced_blocks", "The last block we have in common with this peer"}, @@ -156,6 +153,9 @@ static RPCHelpMan getpeerinfo() "Only known message types can appear as keys in the object and all bytes received\n" "of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'."} }}, + {RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n" + "Please note this output is unlikely to be stable in upcoming releases as we iterate to\n" + "best capture connection behaviors."}, }}, }}, },