Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add network to peers window and peer details #162

Merged
merged 6 commits into from
Dec 28, 2020

Conversation

jonatack
Copy link
Member

@jonatack jonatack commented Dec 24, 2020

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

Screenshot from 2020-12-27 14-45-31

@hebasto
Copy link
Member

hebasto commented Dec 24, 2020

Concept ACK.

@Sjors
Copy link
Member

Sjors commented Dec 24, 2020

tACK b1704ea

Especially handy because IPv6 addresses are turned into ellipses until you expand it:

Schermafbeelding 2020-12-24 om 12 29 34

This column might be a more natural place for the inbound/outbound arrow.

@maflcko maflcko changed the title gui: add network to peers window and in peer details add network to peers window and in peer details Dec 24, 2020
@jonatack jonatack changed the title add network to peers window and in peer details Add network to peers window and peer details Dec 24, 2020
@jonatack
Copy link
Member Author

This column might be a more natural place for the inbound/outbound arrow.

Thanks @Sjors. Good idea, done.

@RandyMcMillan
Copy link
Contributor

RandyMcMillan commented Dec 24, 2020

@jonatack

#135

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.

@jonatack
Copy link
Member Author

@RandyMcMillan not a problem, will just drop the last commit if that PR is merged

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the code (79e997e), 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.

@jonatack
Copy link
Member Author

jonatack commented Dec 25, 2020

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.)

@hebasto
Copy link
Member

hebasto commented Dec 25, 2020

(Can drop the clang-formatting changes in the refactoring commit but some of the conditionals have error-prone formatting.)

The most of the re-formatted code could go away in #18 :)

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 67e8b63

@hebasto
Copy link
Member

hebasto commented Dec 25, 2020

@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:

?

@hebasto
Copy link
Member

hebasto commented Dec 25, 2020

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);

@jonatack jonatack force-pushed the display-peer-networks branch 2 times, most recently from da5e661 to 12212e2 Compare December 25, 2020 16:18
@jonatack
Copy link
Member Author

jonatack commented Dec 25, 2020

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.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 12212e2, tested on Linux Mint 20 (x86_64) + Qt 5.12.8.

Looks great:
Screenshot from 2020-12-25 20-26-53

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:
Screenshot from 2020-12-25 21-05-16

TBH, I don't like it, but it could be changed in a followup.

@jonatack
Copy link
Member Author

jonatack commented Dec 25, 2020

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.

@hebasto
Copy link
Member

hebasto commented Dec 25, 2020

After #18 a filter feature could be easy added, and the sort order will do not matter :)

@jonatack
Copy link
Member Author

SGTM, will review PRs 161 -> 18 ->164.

@jonatack jonatack force-pushed the display-peer-networks branch from 12212e2 to 2f23c08 Compare December 27, 2020 13:36
@jonatack jonatack force-pushed the display-peer-networks branch from 2f23c08 to e262a19 Compare December 27, 2020 13:38
@jonatack
Copy link
Member Author

jonatack commented Dec 27, 2020

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.

Screenshot from 2020-12-27 14-21-28

@jonatack
Copy link
Member Author

Re-opening here, leaving the main repo pull closed. The changes are minor enough to not warrant moving it to the main repo.

@jonatack jonatack reopened this Dec 28, 2020
@laanwj
Copy link
Member

laanwj commented Dec 28, 2020

ACK e262a19

@laanwj laanwj merged commit d875bcc into bitcoin-core:master Dec 28, 2020
@jonatack jonatack deleted the display-peer-networks branch December 28, 2020 23:01
Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post-merge ACK e262a19

@@ -1100,13 +1100,39 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="peerNetworkLabel">
<property name="toolTip">
<string>The network protocol this peer is connected through: IPv4, IPv6, Onion, I2P, or CJDNS.</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggestion for a follow-up is to remove untranslatable network names from the translatable tooltip string.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants