Skip to content

Commit d875bcc

Browse files
committed
Merge bitcoin#162: Add network to peers window and peer details
e262a19 gui: display network in peer details (Jon Atack) 9136953 gui: rename peer tab column headers, initialize in .h (Hennadii Stepanov) 05c08c6 gui: add network column in peers tab/window (Jon Atack) e0e5506 gui: fix broken doxygen formatting in src/qt/guiutil.h (Jon Atack) 0d5613f gui: create GUIUtil::NetworkToQString() utility function (Jon Atack) af9103c net, rpc: change CNodeStats::m_network from string to Network (Jon Atack) Pull request description: and rename peers window column headers from NodeId and Node/Service to Peer Id and Address. ![Screenshot from 2020-12-27 14-45-31](https://user-images.githubusercontent.com/2415484/103172228-efec8600-4849-11eb-8cee-04a3d2ab1273.png) ACKs for top commit: laanwj: ACK e262a19 Tree-SHA512: 709c2a805c109c2dd033aca7b6b6dc94ebe2ce7a0168c71249e1e661c9c57d1f1c781a5b9ccf3b776bedeb83ae2fb5c505637337c45b1eb9a418cb1693a89761
2 parents e3dd0a5 + e262a19 commit d875bcc

File tree

9 files changed

+105
-53
lines changed

9 files changed

+105
-53
lines changed

src/net.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
566566
X(nServices);
567567
X(addr);
568568
X(addrBind);
569-
stats.m_network = GetNetworkName(ConnectedThroughNetwork());
569+
stats.m_network = ConnectedThroughNetwork();
570570
stats.m_mapped_as = addr.GetMappedAS(m_asmap);
571571
if (m_tx_relay != nullptr) {
572572
LOCK(m_tx_relay->cs_filter);

src/net.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,8 @@ class CNodeStats
720720
CAddress addr;
721721
// Bind address of our side of the connection
722722
CAddress addrBind;
723-
// Name of the network the peer connected through
724-
std::string m_network;
723+
// Network the peer connected through
724+
Network m_network;
725725
uint32_t m_mapped_as;
726726
std::string m_conn_type_string;
727727
};

src/qt/forms/debugwindow.ui

+58-32
Original file line numberDiff line numberDiff line change
@@ -1100,13 +1100,39 @@
11001100
</widget>
11011101
</item>
11021102
<item row="2" column="0">
1103+
<widget class="QLabel" name="peerNetworkLabel">
1104+
<property name="toolTip">
1105+
<string>The network protocol this peer is connected through: IPv4, IPv6, Onion, I2P, or CJDNS.</string>
1106+
</property>
1107+
<property name="text">
1108+
<string>Network</string>
1109+
</property>
1110+
</widget>
1111+
</item>
1112+
<item row="2" column="1">
1113+
<widget class="QLabel" name="peerNetwork">
1114+
<property name="cursor">
1115+
<cursorShape>IBeamCursor</cursorShape>
1116+
</property>
1117+
<property name="text">
1118+
<string>N/A</string>
1119+
</property>
1120+
<property name="textFormat">
1121+
<enum>Qt::PlainText</enum>
1122+
</property>
1123+
<property name="textInteractionFlags">
1124+
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
1125+
</property>
1126+
</widget>
1127+
</item>
1128+
<item row="3" column="0">
11031129
<widget class="QLabel" name="label_21">
11041130
<property name="text">
11051131
<string>Version</string>
11061132
</property>
11071133
</widget>
11081134
</item>
1109-
<item row="2" column="1">
1135+
<item row="3" column="1">
11101136
<widget class="QLabel" name="peerVersion">
11111137
<property name="cursor">
11121138
<cursorShape>IBeamCursor</cursorShape>
@@ -1122,14 +1148,14 @@
11221148
</property>
11231149
</widget>
11241150
</item>
1125-
<item row="3" column="0">
1151+
<item row="4" column="0">
11261152
<widget class="QLabel" name="label_28">
11271153
<property name="text">
11281154
<string>User Agent</string>
11291155
</property>
11301156
</widget>
11311157
</item>
1132-
<item row="3" column="1">
1158+
<item row="4" column="1">
11331159
<widget class="QLabel" name="peerSubversion">
11341160
<property name="cursor">
11351161
<cursorShape>IBeamCursor</cursorShape>
@@ -1145,14 +1171,14 @@
11451171
</property>
11461172
</widget>
11471173
</item>
1148-
<item row="4" column="0">
1174+
<item row="5" column="0">
11491175
<widget class="QLabel" name="label_4">
11501176
<property name="text">
11511177
<string>Services</string>
11521178
</property>
11531179
</widget>
11541180
</item>
1155-
<item row="4" column="1">
1181+
<item row="5" column="1">
11561182
<widget class="QLabel" name="peerServices">
11571183
<property name="cursor">
11581184
<cursorShape>IBeamCursor</cursorShape>
@@ -1168,14 +1194,14 @@
11681194
</property>
11691195
</widget>
11701196
</item>
1171-
<item row="5" column="0">
1197+
<item row="6" column="0">
11721198
<widget class="QLabel" name="label_29">
11731199
<property name="text">
11741200
<string>Starting Block</string>
11751201
</property>
11761202
</widget>
11771203
</item>
1178-
<item row="5" column="1">
1204+
<item row="6" column="1">
11791205
<widget class="QLabel" name="peerHeight">
11801206
<property name="cursor">
11811207
<cursorShape>IBeamCursor</cursorShape>
@@ -1191,14 +1217,14 @@
11911217
</property>
11921218
</widget>
11931219
</item>
1194-
<item row="6" column="0">
1220+
<item row="7" column="0">
11951221
<widget class="QLabel" name="label_27">
11961222
<property name="text">
11971223
<string>Synced Headers</string>
11981224
</property>
11991225
</widget>
12001226
</item>
1201-
<item row="6" column="1">
1227+
<item row="7" column="1">
12021228
<widget class="QLabel" name="peerSyncHeight">
12031229
<property name="cursor">
12041230
<cursorShape>IBeamCursor</cursorShape>
@@ -1214,14 +1240,14 @@
12141240
</property>
12151241
</widget>
12161242
</item>
1217-
<item row="7" column="0">
1243+
<item row="8" column="0">
12181244
<widget class="QLabel" name="label_25">
12191245
<property name="text">
12201246
<string>Synced Blocks</string>
12211247
</property>
12221248
</widget>
12231249
</item>
1224-
<item row="7" column="1">
1250+
<item row="8" column="1">
12251251
<widget class="QLabel" name="peerCommonHeight">
12261252
<property name="cursor">
12271253
<cursorShape>IBeamCursor</cursorShape>
@@ -1237,14 +1263,14 @@
12371263
</property>
12381264
</widget>
12391265
</item>
1240-
<item row="8" column="0">
1266+
<item row="9" column="0">
12411267
<widget class="QLabel" name="label_22">
12421268
<property name="text">
12431269
<string>Connection Time</string>
12441270
</property>
12451271
</widget>
12461272
</item>
1247-
<item row="8" column="1">
1273+
<item row="9" column="1">
12481274
<widget class="QLabel" name="peerConnTime">
12491275
<property name="cursor">
12501276
<cursorShape>IBeamCursor</cursorShape>
@@ -1260,14 +1286,14 @@
12601286
</property>
12611287
</widget>
12621288
</item>
1263-
<item row="9" column="0">
1289+
<item row="10" column="0">
12641290
<widget class="QLabel" name="label_15">
12651291
<property name="text">
12661292
<string>Last Send</string>
12671293
</property>
12681294
</widget>
12691295
</item>
1270-
<item row="9" column="1">
1296+
<item row="10" column="1">
12711297
<widget class="QLabel" name="peerLastSend">
12721298
<property name="cursor">
12731299
<cursorShape>IBeamCursor</cursorShape>
@@ -1283,14 +1309,14 @@
12831309
</property>
12841310
</widget>
12851311
</item>
1286-
<item row="10" column="0">
1312+
<item row="11" column="0">
12871313
<widget class="QLabel" name="label_19">
12881314
<property name="text">
12891315
<string>Last Receive</string>
12901316
</property>
12911317
</widget>
12921318
</item>
1293-
<item row="10" column="1">
1319+
<item row="11" column="1">
12941320
<widget class="QLabel" name="peerLastRecv">
12951321
<property name="cursor">
12961322
<cursorShape>IBeamCursor</cursorShape>
@@ -1306,14 +1332,14 @@
13061332
</property>
13071333
</widget>
13081334
</item>
1309-
<item row="11" column="0">
1335+
<item row="12" column="0">
13101336
<widget class="QLabel" name="label_18">
13111337
<property name="text">
13121338
<string>Sent</string>
13131339
</property>
13141340
</widget>
13151341
</item>
1316-
<item row="11" column="1">
1342+
<item row="12" column="1">
13171343
<widget class="QLabel" name="peerBytesSent">
13181344
<property name="cursor">
13191345
<cursorShape>IBeamCursor</cursorShape>
@@ -1329,14 +1355,14 @@
13291355
</property>
13301356
</widget>
13311357
</item>
1332-
<item row="12" column="0">
1358+
<item row="13" column="0">
13331359
<widget class="QLabel" name="label_20">
13341360
<property name="text">
13351361
<string>Received</string>
13361362
</property>
13371363
</widget>
13381364
</item>
1339-
<item row="12" column="1">
1365+
<item row="13" column="1">
13401366
<widget class="QLabel" name="peerBytesRecv">
13411367
<property name="cursor">
13421368
<cursorShape>IBeamCursor</cursorShape>
@@ -1352,14 +1378,14 @@
13521378
</property>
13531379
</widget>
13541380
</item>
1355-
<item row="13" column="0">
1381+
<item row="14" column="0">
13561382
<widget class="QLabel" name="label_26">
13571383
<property name="text">
13581384
<string>Ping Time</string>
13591385
</property>
13601386
</widget>
13611387
</item>
1362-
<item row="13" column="1">
1388+
<item row="14" column="1">
13631389
<widget class="QLabel" name="peerPingTime">
13641390
<property name="cursor">
13651391
<cursorShape>IBeamCursor</cursorShape>
@@ -1375,7 +1401,7 @@
13751401
</property>
13761402
</widget>
13771403
</item>
1378-
<item row="14" column="0">
1404+
<item row="15" column="0">
13791405
<widget class="QLabel" name="peerPingWaitLabel">
13801406
<property name="toolTip">
13811407
<string>The duration of a currently outstanding ping.</string>
@@ -1385,7 +1411,7 @@
13851411
</property>
13861412
</widget>
13871413
</item>
1388-
<item row="14" column="1">
1414+
<item row="15" column="1">
13891415
<widget class="QLabel" name="peerPingWait">
13901416
<property name="cursor">
13911417
<cursorShape>IBeamCursor</cursorShape>
@@ -1401,14 +1427,14 @@
14011427
</property>
14021428
</widget>
14031429
</item>
1404-
<item row="15" column="0">
1430+
<item row="16" column="0">
14051431
<widget class="QLabel" name="peerMinPingLabel">
14061432
<property name="text">
14071433
<string>Min Ping</string>
14081434
</property>
14091435
</widget>
14101436
</item>
1411-
<item row="15" column="1">
1437+
<item row="16" column="1">
14121438
<widget class="QLabel" name="peerMinPing">
14131439
<property name="cursor">
14141440
<cursorShape>IBeamCursor</cursorShape>
@@ -1424,14 +1450,14 @@
14241450
</property>
14251451
</widget>
14261452
</item>
1427-
<item row="16" column="0">
1453+
<item row="17" column="0">
14281454
<widget class="QLabel" name="label_timeoffset">
14291455
<property name="text">
14301456
<string>Time Offset</string>
14311457
</property>
14321458
</widget>
14331459
</item>
1434-
<item row="16" column="1">
1460+
<item row="17" column="1">
14351461
<widget class="QLabel" name="timeoffset">
14361462
<property name="cursor">
14371463
<cursorShape>IBeamCursor</cursorShape>
@@ -1447,7 +1473,7 @@
14471473
</property>
14481474
</widget>
14491475
</item>
1450-
<item row="17" column="0">
1476+
<item row="18" column="0">
14511477
<widget class="QLabel" name="peerMappedASLabel">
14521478
<property name="toolTip">
14531479
<string>The mapped Autonomous System used for diversifying peer selection.</string>
@@ -1457,7 +1483,7 @@
14571483
</property>
14581484
</widget>
14591485
</item>
1460-
<item row="17" column="1">
1486+
<item row="18" column="1">
14611487
<widget class="QLabel" name="peerMappedAS">
14621488
<property name="cursor">
14631489
<cursorShape>IBeamCursor</cursorShape>
@@ -1473,7 +1499,7 @@
14731499
</property>
14741500
</widget>
14751501
</item>
1476-
<item row="18" column="0">
1502+
<item row="19" column="0">
14771503
<spacer name="verticalSpacer_3">
14781504
<property name="orientation">
14791505
<enum>Qt::Vertical</enum>

src/qt/guiutil.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,21 @@ QString boostPathToQString(const fs::path &path)
749749
return QString::fromStdString(path.string());
750750
}
751751

752+
QString NetworkToQString(Network net)
753+
{
754+
switch (net) {
755+
case NET_UNROUTABLE: return QObject::tr("Unroutable");
756+
case NET_IPV4: return "IPv4";
757+
case NET_IPV6: return "IPv6";
758+
case NET_ONION: return "Onion";
759+
case NET_I2P: return "I2P";
760+
case NET_CJDNS: return "CJDNS";
761+
case NET_INTERNAL: return QObject::tr("Internal");
762+
case NET_MAX: assert(false);
763+
} // no default case, so the compiler can warn about missing cases
764+
assert(false);
765+
}
766+
752767
QString formatDurationStr(int secs)
753768
{
754769
QStringList strList;

src/qt/guiutil.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

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

1112
#include <QEvent>
1213
#include <QHeaderView>
@@ -218,22 +219,25 @@ namespace GUIUtil
218219
bool GetStartOnSystemStartup();
219220
bool SetStartOnSystemStartup(bool fAutoStart);
220221

221-
/* Convert QString to OS specific boost path through UTF-8 */
222+
/** Convert QString to OS specific boost path through UTF-8 */
222223
fs::path qstringToBoostPath(const QString &path);
223224

224-
/* Convert OS specific boost path to QString through UTF-8 */
225+
/** Convert OS specific boost path to QString through UTF-8 */
225226
QString boostPathToQString(const fs::path &path);
226227

227-
/* Convert seconds into a QString with days, hours, mins, secs */
228+
/** Convert enum Network to QString */
229+
QString NetworkToQString(Network net);
230+
231+
/** Convert seconds into a QString with days, hours, mins, secs */
228232
QString formatDurationStr(int secs);
229233

230-
/* Format CNodeStats.nServices bitmask into a user-readable string */
234+
/** Format CNodeStats.nServices bitmask into a user-readable string */
231235
QString formatServicesStr(quint64 mask);
232236

233-
/* Format a CNodeStats.m_ping_usec into a user-readable string or display N/A, if 0*/
237+
/** Format a CNodeStats.m_ping_usec into a user-readable string or display N/A, if 0 */
234238
QString formatPingTime(int64_t ping_usec);
235239

236-
/* Format a CNodeCombinedStats.nTimeOffset into a user-readable string. */
240+
/** Format a CNodeCombinedStats.nTimeOffset into a user-readable string */
237241
QString formatTimeOffset(int64_t nTimeOffset);
238242

239243
QString formatNiceTimeOffset(qint64 secs);

0 commit comments

Comments
 (0)