-
Notifications
You must be signed in to change notification settings - Fork 269
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
Handle peer addition/removal in a right way #164
Conversation
734dd5f
to
d325799
Compare
Will be rebased after any progress in #161 :) |
…tion b3e9bca qt, refactor: Drop no longer used PeerTableModel::getNodeStats function (Hennadii Stepanov) 49c6040 qt: Use PeerTableModel::StatsRole (Hennadii Stepanov) 35007ed qt: Add PeerTableModel::StatsRole (Hennadii Stepanov) Pull request description: This PR allows to access to the `CNodeCombinedStats` instance directly from any view object. The `PeerTableModel::getNodeStats` member function removed as a kind of layer violation. No behavior changes. Also other pulls (bugfixes) are based on this one: #18 and #164. ACKs for top commit: jonatack: Tested re-ACK b3e9bca per `git range-diff ae8f797 4c05fe0 b3e9bca` promag: Code review ACK b3e9bca. jonasschnelli: utACK b3e9bca Tree-SHA512: 6ba50d5dd2c0373655d491ce8b130c47d598da2db5ff4b00633f447404c7e70f8562ead53ddf166e851384d9632ff9146a770c99845c2cdd3ff7250677e4c130
d325799
to
f73d340
Compare
Why is this based on #18? |
It fixes selection behavior and handling in general. |
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 f73d340
Confirming that the PR fixes the issue laid out in #160 on macOS 11.1 with Qt 5.15.2.
On master
: If I select a peer, and a peer above it is disconnected, then the peer I had selected becomes unselected. Below are screenshots exhibiting this behavior.
Master: I have selected Peer ID 32
Master: Peer ID 32
is no longer selected because Peer ID 29
is above it and disconnected
on this PR
: This behavior no longer occurs. If I select a peer, it remains selected even if a peer above it is disconnected.
PR: Peer ID 0
has disconnected. Peer ID 14
remains selected.
f73d340
to
32ce58c
Compare
32ce58c
to
a3d21d3
Compare
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.
re-ACK a3d21d3, tested on macOS 11.1 Qt 5.15.2 after rebase
Rebased a3d21d3 -> fa95a22 (pr164.05 -> pr164.06) due to the conflict with bitcoin/bitcoin#21015. |
m_node.getNodesStats(nodes_stats); | ||
decltype(m_peers_data) new_peers_data; | ||
new_peers_data.reserve(nodes_stats.size()); | ||
for (const auto& node_stats : nodes_stats) { |
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.
Ugh, my suggestion was not good enought, you can actually move values out of that local nodes_stats
:
for (auto&& node_stats : nodes_stats) {
const CNodeCombinedStats stats{std::get<0>(std::move(node_stats)),
std::get<2>(std::move(node_stats)),
std::get<1>(std::move(node_stats))};
(note loop variable is no longer cost reference!)
Or even with an algorithm (also moves, at least it does on local test), if one would care about "No raw loops" mantra :)
std::transform(nodes_stats.begin(), nodes_stats.end(), std::back_inserter(new_peers_data), [](auto&& i) {
return CNodeCombinedStats{std::get<0>(std::move(i)), std::get<2>(std::move(i)), std::get<1>(std::move(i))};
});
Though moving std::transform
seems fishy, not sure if it's "legal" to move source... But gcc 10.2.1 does that.
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.
Ugh, my suggestion was not good enought...
It seems like a kind of premature optimization, no?
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.
Maybe, probably. Since there will be mostly on up to ~128 nodes by default, "nobody" would care if there are some extra copies I guess, and std::transform
variant do look particularly "noisy" (i.e. "optimization" not worth the effort/readability cost).
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 ec3075d, tested on Debian Sid with Qt 5.15.2.
Tested using two bitcoind's connected to PR's bitcoin-qt in regtest mode. Did some reconnects, and so far table seems to work fine.
See Qt docs for QAbstractTableModel and QAbstractItemModel classes.
This commit does not change behavior.
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 ACK e102c90 on macos 11.2.3 with depends build.
Also ran with -server
and while some peer was selected removing/adding others from -cli
didn't mess with the selection. Also didn't observe weird behaviors while resizing columns.
Concept ACK. If this fixes what I think it does, it would be good to see it in v22 as a bug fix. |
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 e102c90
Tested functionality on Arch Linux Qt 5.15.2
, macOS 11.3 Qt 5.15.2
, and cross-compile from Linux to Windows 10
.
Notes on Commits:
- efb7e5a
- code review ACK cross-checked with Qt docs for QAbstractTableModel and QAbstractItemModel
- 1b66f6e
- code review ACK, the
PeerTablePriv
class would no longer be needed.
- code review ACK, the
- e102c90
Screenshots:
The below screenshots show that this PR will close the mutated version of #160 (see, #160 (comment)). While I am not including videos showing that this PR also fixes #191, I can confirm that it does on all three tested platforms.
Arch Linux
master
Select Peer 6 | Disconnect Peer 0, Peer 7 is now selected ❌ |
---|---|
PR
Select Peer 9 | Disconnect Peer 1, Peer 9 remains selected ✅ |
---|---|
macOS 11.3
master
Select Peer 6 | Disconnect Peer 0, Peer 7 is now selected ❌ |
---|---|
PR
Select Peer 8 | Disconnect Peer 0, Peer 8 remains selected ✅ |
---|---|
Windows 10
Note: Difference between UI on master and PR is because master includes ab86ac7
master
Select Peer 4 | Disconnect Peer 0, Peer 6 is now selected ❌ |
---|---|
PR
Select Peer 5 | Disconnect Peer 1, Peer 5 remains selected ✅ |
---|---|
This change fixes a bug when a multiple rows selection gets inconsistent after a peer addition/removal.
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 ecbd911 just improvements to the comment since last review.
re-ACK ecbd911 Only changes since last review are implementation of comment nits |
ecbd911 qt: Handle peer addition/removal in a right way (Hennadii Stepanov) 1b66f6e qt: Drop PeerTablePriv class (Hennadii Stepanov) efb7e5a qt, refactor: Use default arguments for overridden functions (Hennadii Stepanov) Pull request description: This PR makes `PeerTableModel` handle a peer addition/removal in a right way. See: - https://doc.qt.io/qt-5/model-view-programming.html#inserting-and-removing-rows - https://doc.qt.io/qt-5/model-view-programming.html#resizable-models Fixes #160. Fixes #191. ACKs for top commit: jarolrod: re-ACK ecbd911 promag: reACK ecbd911 just improvements to the comment since last review. Tree-SHA512: 074935d67f78561724218e8b33822e2de16749f873c29054926b720ffcd642f08249a222b563983cf65a9b716290aa14e2372c47fc04e5f401f759db25ca710f
986bf78 qt: Emit dataChanged signal to dynamically re-sort Peers table (Hennadii Stepanov) Pull request description: [By default](https://doc.qt.io/qt-5/qsortfilterproxymodel.html#details), the `PeerTableSortProxy` > dynamically re-sorts ... data whenever the original model changes. That is not the case on master (8cdf917) as in ecbd911 (#164) no signals are emitted to notify about model changes. This PR uses a dedicated [`dataChanged`](https://doc.qt.io/qt-5/qabstractitemmodel.html#dataChanged) signal. Fixes #367. An alternative to #374. ACKs for top commit: jarolrod: ACK 986bf78 Tree-SHA512: dcb92c2f9a2c632880429e9528007db426d2ad938c64dfa1f1538c03e4b62620df52ad7daf33b582976c67b472ff76bc0dae707049f4bbbd4941232cee9ce3d4
This PR makes
PeerTableModel
handle a peer addition/removal in a right way. See:Fixes #160.
Fixes #191.