and rename peers window column headers from NodeId and Node/Service to Peer Id and Address.

and rename peers window column headers from NodeId and Node/Service to Peer Id and Address.

Concept ACK.
tACK b1704ead912ed813eaa08e80af5e14a2c087574e
Especially handy because IPv6 addresses are turned into ellipses until you expand it:
<img width="812" alt="Schermafbeelding 2020-12-24 om 12 29 34" src="https://user-images.githubusercontent.com/10217/103086035-b7e40980-45e3-11eb-9fa6-f483b6f4696e.png">
This column might be a more natural place for the inbound/outbound arrow.
In this PR the direction has its own column. This makes the direction sortable. Having the network type and the direction individually sortable would be great.
Note: I found that offsetting the arrow (based on direction) is a useful visual cue. And this makes seeing the direction (at a glance) easier.
@RandyMcMillan not a problem, will just drop the last commit if that PR is merged
1099 | @@ -1100,13 +1100,39 @@ 1100 | </widget> 1101 | </item> 1102 | <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.</string> 1106 | + </property>
b1704ead912ed813eaa08e80af5e14a2c087574e
It is inconsistent to have a tooltip only for this label among others.
There is one for the Mapped AS field that was added in https://github.com/bitcoin/bitcoin/pull/18402. Probably best to add some of the missing ones but not in this pull.
754 | + if (network == "ipv4") return "IPv4"; 755 | + if (network == "ipv6") return "IPv6"; 756 | + if (network == "onion") return "Onion"; 757 | + return ""; 758 | +} 759 | +
done -- I agree it's a shame to add a function but the GUI UI is non all-lowercase like the RPC/CLI interface
105 | @@ -104,7 +106,7 @@ PeerTableModel::PeerTableModel(interfaces::Node& node, QObject* parent) : 106 | m_node(node), 107 | timer(nullptr) 108 | { 109 | - columns << tr("NodeId") << tr("Node/Service") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent"); 110 | + columns << tr("Node Id") << tr("Node/Service") << tr("Network") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent");
c772533ce5f471b5aa968ac864cf8a2173900fac As you touching the headers, mind considering the following patch
--- a/src/qt/peertablemodel.cpp
+++ b/src/qt/peertablemodel.cpp
@@ -106,7 +106,6 @@ PeerTableModel::PeerTableModel(interfaces::Node& node, QObject* parent) :
m_node(node),
timer(nullptr)
{
- columns << tr("Node Id") << tr("Node/Service") << tr("Network") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent");
priv.reset(new PeerTablePriv());
// set up timer for auto refresh
diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h
index 39cbe16df..61a0132e0 100644
--- a/src/qt/peertablemodel.h
+++ b/src/qt/peertablemodel.h
@@ -83,7 +83,7 @@ public Q_SLOTS:
private:
interfaces::Node& m_node;
- QStringList columns;
+ const QStringList columns{tr("Peer Id"), tr("Address"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
std::unique_ptr<PeerTablePriv> priv;
QTimer *timer;
};
?
sure, done in c2cd8267cb21d496bcf66070b3b9b18d5f181ea5 (can drop the clang-formatting changes in that commit but some of the conditionals have dangerous, error-prone formatting)
I have reviewed the code (79e997e826b93595896839fd513a052b7a4d001d), and tested it.
UX notes.
Disclaimer: I'm not a design expert, and my opinions are based exclusively on my experience.
In this PR the direction has its own column. This makes the direction sortable. Having the network type and the direction individually sortable would be great.
I've been waiting for this feature for many years :)
This column might be a more natural place for the inbound/outbound arrow.
Thanks @Sjors. Good idea, done.
I don't think this change is valuable. It is not possible to sort out all connections through a particular network.
Thanks for the feedback. I dropped the arrows commit (I think there is a better approach possible) and took most of @hebasto's suggestions. (Can drop the clang-formatting changes in the refactoring commit but some of the conditionals have error-prone formatting.)
44 | case PeerTableModel::Received: 45 | return pLeft->nRecvBytes < pRight->nRecvBytes; 46 | - } 47 | + case PeerTableModel::Subversion: 48 | + return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; 49 | + } // no default case, so the compiler can warn about missing cases
I think this comment is not true, as the switch parameter is an int, not a enum.
You're right--thanks!
748 | @@ -749,6 +749,21 @@ QString boostPathToQString(const fs::path &path) 749 | return QString::fromStdString(path.string()); 750 | } 751 | 752 | +QString NetworkToQString(Network net) 753 | +{ 754 | + switch (net) { 755 | + case NET_UNROUTABLE: return "Unroutable";
case NET_UNROUTABLE: return tr("Unroutable");
thanks, done 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 "Internal";
case NET_INTERNAL: return tr("Internal");
thanks, done
ACK 67e8b636a88daf47acf01f04e1e1b62b6f200554
@jonatack Could this patch make things look better
--- a/src/qt/peertablemodel.cpp
+++ b/src/qt/peertablemodel.cpp
@@ -168,6 +168,8 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
}
} else if (role == Qt::TextAlignmentRole) {
switch (index.column()) {
+ case Network:
+ return QVariant(Qt::AlignCenter);
case Ping:
case Sent:
case Received:
?
Due to the header titles are changed this patch seems required:
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -1092,7 +1092,7 @@ void RPCConsole::updateDetailWidget()
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected_rows.first().row());
// update the detail ui with latest node information
QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " ");
- peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid));
+ peerAddrDetails += tr("(peer id: %1)").arg(QString::number(stats->nodeStats.nodeid));
if (!stats->nodeStats.addrLocal.empty())
peerAddrDetails += "<br />" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
ui->peerHeading->setText(peerAddrDetails);
Thanks for the good feedback @hebasto. Added translation, changed the network column align to center, added a commit in your name for the header renaming + initialize columns in the .h, fixed the broken doxygen formatting, dropped the clang formatting, and improved the network tooltip. Updated the PR description and screenshot.
ACK 12212e2b30b87110f81787d6e10259d02d807279, tested on Linux Mint 20 (x86_64) + Qt 5.12.8.
Looks great:

Also I've verified that the "network" field in the getpeerinfo RPC has not changed behavior.
With this patch
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -566,7 +566,7 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
X(nServices);
X(addr);
X(addrBind);
- stats.m_network = ConnectedThroughNetwork();
+ stats.m_network = static_cast<enum Network>(stats.nodeid % NET_MAX);
stats.m_network_name = GetNetworkName(stats.m_network);
stats.m_mapped_as = addr.GetMappedAS(m_asmap);
if (m_tx_relay != nullptr) {
I've verified that items in the "Network" column are sorted in lexicographical order:

TBH, I don't like it, but it could be changed in a followup.
Thanks! The sort order was deliberate--my thinking was that users expect this to be sorted by alphabetical order as there isn't an obvious alternative sort expectation, so I went with sort by name rather than by enum id (which may be more what you're thinking of, e.g. ipv4, then ipv6, then onion, then i2p, then cjdns, but that may violate the principle of least surprise to users). I don't mind updating if there is consensus on sort by enum id.
SGTM, will review PRs 161 -> 18 ->164.
Updated the first commit to remove the now-redundant network string (same idea as @promag's suggestion in the connection type pull) and updated the network column ordering by enum id rather than by network name (@hebasto I agree it's better, though maybe more surprising to some users, see screenshot with your patch to show all the Network enum members). Will open this in the main repo as it now touches RPC code.

Re-opening here, leaving the main repo pull closed. The changes are minor enough to not warrant moving it to the main repo.
ACK e262a19b0ba07d8d2334551f49ca1577ab2999fc
1099 | @@ -1100,13 +1100,39 @@ 1100 | </widget> 1101 | </item> 1102 | <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>
The suggestion for a follow-up is to remove untranslatable network names from the translatable tooltip string.
post-merge ACK e262a19b0ba07d8d2334551f49ca1577ab2999fc