-
Notifications
You must be signed in to change notification settings - Fork 334
peers-tab: add connection duration column to tableview #543
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
peers-tab: add connection duration column to tableview #543
Conversation
|
commit 363f181 - the column is resizing to accommodate |
|
commit 281b65b we make adjustments so that the peers tab collapses down to a useful "desktop widget". |
|
This PR and #540 will work well together. Both the network graph and peers tab will be useful in a minimized window size and present information in a well formatted way. |
jarolrod
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to add this column to the peers table? Why is it a useful metric for a user of the GUI?
src/qt/peertablemodel.h
Outdated
| /*: Title of Peers Table column which describes the type of | ||
| peer connection. The "type" describes why the connection exists. */ | ||
| tr("Duration"), | ||
| /*: Title of Peers Table column which describes the duration of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You added this translator comment in reverse, the comment on lines 95 and 96 should be above line 94 in this diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your attention on this.
I guess one could ask - why And the fact that there is so much visual real estate NOT BEING USED FOR ANYTHING AT ALL - I am not even sure what the concern or hesitation to adding more columns to the table view would be. On wider screens more than half of the available real-estate is LITERALLY EMPTY SPACE. |
|
If - by your assertion - the connection duration is NOT USEFUL - why track it? Why not rip it out of the Client Model - a system could use that memory and resources for something else. |
|
The command line equivalent NOTE: I agree with using a 3 char column title in the command line equivalent - but in the gui - |
|
Note: I like the idea of verbosity in the command line version. If defending the nuance and minutia of gui design changes wasn't so ridiculous (in this repo) - we could consider adding similar functionality to the gui (levels of verbosity to the table) - but I literally don't get paid enough (approaching nothing) to deal with that type of design process unless every one else was already on board. |
|
Concept ACK
Duration is also useful combined with other things because users can see how much data was sent and received in that duration. |
|
Concept ACK. I do look frequently at age in -netinfo. The direction and type columns should remain together, as combined they form the connection type, like Edit: the commits seem overly fine-grained, maybe combine the first three or four into one. |
src/qt/peertablemodel.h
Outdated
| tr("Direction"), | ||
| /*: Title of Peers Table column which indicates the duration (length of time) | ||
| since the peer connection started. */ | ||
| tr("Duration"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like Age, but if you don't, maybe consider Uptime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used Age as column name
src/qt/rpcconsole.cpp
Outdated
| ui->banlistWidget->setColumnWidth(BanTableModel::Address, BANSUBNET_COLUMN_WIDTH); | ||
| ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH); | ||
| } | ||
| ui->banlistWidget->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::ResizeToContents); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and line 694 as well
| ui->banlistWidget->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::ResizeToContents); | |
| ui->banlistWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed white space
|
@jonatack - thanks for the constructive feedback - I appreciate your reasoning. I will re-implement accordingly. |
16c9ebf to
22b1a40
Compare
|
commit 22b1a40 implements suggested changes. |
|
Screenshots of 22b1a40 If anybody wants to send a patch truncating the time format - I will gladly add it with attribution. |
ghost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 22b1a40
|
Concept ACK I do note the sort will be the same as sorting by ID... |
|
@luke-jr - good observation - thanks again for your great feed back - (my apologize for the other thing - I will make the mempool-tab repo more "normal" 😄 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug build is clean and seems to be working. Can you update, squash and fix the commit names, descriptions, and code organization? i.e. make this ready for more final review.
It would be nice to remove the seconds display--seems noisy, distracting and unneeded. Nodes can be up for weeks, months or longer.
sorting the tableview with the connection duration is made possible.
Suggest removing the above from the pull description, as it is the same as the existing sort by peer id. Albeit with the current version, the sort orders of Peer and Age are inversed.
e4d1d6c to
d01c0b3
Compare
|
Commit: d01c0b3 Cleaned up commit structure and messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested approach ACK, this seems much improved.
src/qt/peertablemodel.cpp
Outdated
| return GUIUtil::formatDurationStr(std::chrono::duration_cast<std::chrono::seconds>(time_now-rec->nodeStats.m_connected)); | ||
| }else{ | ||
| return GUIUtil::formatDurationStr(std::chrono::duration_cast<std::chrono::minutes>(time_now-rec->nodeStats.m_connected)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d01c0b3 suggestions
- clang-format
- use chrono literals, e.g.
60sinstead ofstd::chrono::seconds{60} - drop unneeded casts and comment that echoes the code (and shouldn't be in doxygen format here)
suggested diff
+using namespace std::chrono_literals;
+
PeerTableModel::PeerTableModel(interfaces::Node& node, QObject* parent) :
QAbstractTableModel(parent),
m_node(node),
@@ -72,11 +75,11 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
case NetNodeId:
return (qint64)rec->nodeStats.nodeid;
case Age:
- if(std::chrono::duration_cast<std::chrono::minutes>(time_now-rec->nodeStats.m_connected) < std::chrono::seconds{60}){
- /* display connection "Age" in seconds for first minute */
- return GUIUtil::formatDurationStr(std::chrono::duration_cast<std::chrono::seconds>(time_now-rec->nodeStats.m_connected));
- }else{
- return GUIUtil::formatDurationStr(std::chrono::duration_cast<std::chrono::minutes>(time_now-rec->nodeStats.m_connected));
+ if (time_now - rec->nodeStats.m_connected < 60s) {
+ return GUIUtil::formatDurationStr(time_now - rec->nodeStats.m_connected);
+ } else {
+ return GUIUtil::formatDurationStr(
+ std::chrono::duration_cast<std::chrono::minutes>(time_now - rec->nodeStats.m_connected));
}If this becomes larger, say, to display in DD:HH format after 24 hours it may make sense to extract it to a helper function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ResizeToContents settings should accommodate the duration string as the connection persists longer than 24 hours.
NOTE: The fact that <chrono> is formatting the string for # s, # m then # h # m suggests that it will
format for # d # h # m. I guess we could spoof the time to prove/test this.
I applied your suggested diff with attribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that
<chrono>is formatting the string for# s,# mthen# h # msuggests that it will format for# d # h # m. I guess we could spoof the time to prove/test this.
Tested with a few different values and you're right: 23 h 59 s, 1 d, 1 d 1 h 59 m, 1 d 2 h, 1 d 2 h 1 m, etc. The spacing makes the column wider and a bit noisier than necessary. Could be improved here or as a follow-up.
- const auto time_now{GetTime<std::chrono::seconds>()};
+ const auto time_now{GetTime<std::chrono::seconds>() + 86380s};139f2ed to
795a03d
Compare
ghost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK a2e44c1
src/qt/guiutil.cpp
Outdated
| if (hours >= 24) return QObject::tr("%1 d").arg(hours / 24); | ||
| if (hours) return QObject::tr("%1 h").arg(hours); | ||
| const auto minutes{std::chrono::duration_cast<std::chrono::minutes>(age).count()}; | ||
| return QObject::tr("%1 m").arg(minutes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RandyMcMillan, looking at this further, I think the function in 349c597 can be simplified and improved as follows:
@@ -736,12 +736,10 @@ QString FormatPeerAge(std::chrono::seconds time_connected)
{
const auto time_now{GetTime<std::chrono::seconds>()};
const auto age{time_now - time_connected};
- if (age < 60s) return QObject::tr("%1 s").arg(age.count());
- const auto hours{std::chrono::duration_cast<std::chrono::hours>(age).count()};
- if (hours >= 24) return QObject::tr("%1 d").arg(hours / 24);
- if (hours) return QObject::tr("%1 h").arg(hours);
- const auto minutes{std::chrono::duration_cast<std::chrono::minutes>(age).count()};
- return QObject::tr("%1 m").arg(minutes);
+ if (age >= 24h) return QObject::tr("%1 d").arg(age / 24h);
+ if (age >= 1h) return QObject::tr("%1 h").arg(age / 1h);
+ if (age >= 1min) return QObject::tr("%1 m").arg(age / 1min);
+ return QObject::tr("%1 s").arg(age / 1s);
} There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I repushed an update to https://github.com/jonatack/gui/commits/gui-peers-tab-age-column with the changes in #543 (comment) and #543 (comment) if you want to cherry-pick them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably add translator notes too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably add translator notes too
Agree, am doing this for several of these (FormatPeerAge, formatDurationStr, TimeDurationField, etc.) as a follow-up.
a2e44c1 to
35d685a
Compare
|
ACK 35d685a I like that the Peer and Age columns have the opposite default sort direction, displaying both the newest and oldest peers by default. Note that there is a Connection Time in the peer details that displays the Age in a more verbose format. I think it's ok as-is, as the formats are different, or maybe might propose renaming the former to Age (Connection Time). |
ghost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK 35d685a
|
This has been a fun collaborative effort. 😄 I enjoyed watching a rough idea get polished into an "ACK-able" state. |
shaavan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 35d685a
I agree with the concept of adding an Age column in the Node window table because I agree with all the reasons for its approval discussed above. To briefly reiterate them:
- We have unused screen real estate which could be used more productively.
- The Age column is displayed in the
-netinfocommand forbitcoin-cli. It makes logical sense to keep our GUI consistent with the cli. - Age column is frequently used by users through
-netinfocommand. So it would be a good idea to add the GUI.
Regarding the code:
- I like the structuring of the
FormatPeerPagefunction. The code is clean and easy to understand. - I like the idea of displaying only the highest degree of time, instead of precise time. This gives users a general idea of how a node has been contacted to them, while also not taking too much screen real estate, and user’s attention.
- I think naming the column “Age” seems appropriate to me. This keeps it consistent with bitcoin-cli's naming.
Here are some screenshots I have added showing the correct working of this PR, on Ubuntu 20.04
| Master | PR |
|---|---|
![]() |
![]() |
w0xlt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 35d685a on Ubuntu 21.10 Qt 5.15.2
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
| return strList.join(" "); | ||
| } | ||
|
|
||
| QString FormatPeerAge(std::chrono::seconds time_connected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be idempotent QString FormatAge(std::chrono::seconds age), to avoid GetTime.
Note that PeerTableModel has a timer to refresh the data, just call GetTime once there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@promag I agree this would be an improvement and am looking into it, but am not sure how to integrate GetTime into the peertablemodel.cpp QTimer code. Pointers welcome.
| case NetNodeId: | ||
| return (qint64)rec->nodeStats.nodeid; | ||
| case Age: | ||
| return GUIUtil::FormatPeerAge(rec->nodeStats.m_connected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following my previous comment, this could be
return GUIUtil::FormatAge(m_now - rec->nodeStats.m_connected);|
This pull has 4 ACKs and could perhaps be merged now that v23 has been branched off, which would enable moving forward on planned follow-ups like #543 (comment), while still allowing a possible improvement per #543 (comment). |
|
7ddff98 merged requested changes. |
|
ACK. Squashing the changes into the relevant commit (in this case, the last commit 35d685a) when re-pushing an update can save time for reviewers and speed up the merge. See the "Squashing Commits" section of CONTRIBUTING.md. |
Co-authored-by: randymcmillan <randy.lee.mcmillan@gmail.com>
Co-authored-by: Jon Atack <jon@atack.com>
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
7ddff98 to
51708c4
Compare
|
re-ACK 51708c4 |
|
(PR #543) |
|
… On Wed, Mar 16, 2022, 9:05 PM Jon Atack ***@***.***> wrote:
re-ACK 51708c4
<51708c4>
—
Reply to this email directly, view it on GitHub
<#543 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWXCCBYJ3XSYP7MP53GSSL3VAI5G3ANCNFSM5NNV222A>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
@Jamewood - thank you for the ACK if this was your intention - please ACK in the appropriate format - and remove the other comments. 😀 |
shaavan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK 51708c4
Changes since my last review:
- Dropped “Magic numbers”. i.e.,
1→PeerTableModel::Age
0→BanTableModel::Address - Rebased over master.
I agree with the idea of dropping “magic” numbers because:
- It makes code easier to understand and reason with.
- It makes code robust to change in enum ordering under the class’s definition.
hebasto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 51708c4, I have reviewed the code and it looks OK, I agree it can be merged.
… to tableview 51708c4 gui: peersWidget - ResizeToContents Age and IP/Netmask columns (randymcmillan) 209301a gui: add Age column to peers tab (randymcmillan) 127de22 gui: add FormatPeerAge() utility helper (Jon Atack) Pull request description: This change adds an "Age" column to the peers table view, which displays the duration of each peer's connection. ACKs for top commit: jonatack: re-ACK 51708c4 Jamewood: > re-ACK 51708c4 shaavan: reACK 51708c4 hebasto: ACK 51708c4, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 27323f7080ec0d3fcdbf1b190fba1cd2d7406840ab6607c221cf8af950db9134e22721cc5a88f4fc4f390d8b05e98bc4b7521661a31fadad9e2c6c6390e71788












This change adds an "Age" column to the peers table view,
which displays the duration of each peer's connection.