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 PeerTableModel::StatsRole to prevent data layer violation #161

Merged
merged 3 commits into from
Jan 11, 2021

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Dec 23, 2020

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.

@hebasto hebasto marked this pull request as draft December 24, 2020 08:56
@hebasto hebasto changed the title Rework RPCConsole::banSelectedNode function Add PeerTableModel::StatsRole to prevent data layer violation Dec 24, 2020
@hebasto hebasto marked this pull request as ready for review December 24, 2020 12:42
@hebasto
Copy link
Member Author

hebasto commented Dec 24, 2020

Reworked from scratch.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Light ACK 4c05fe0 with the caveat that I don't know the qt framework or this code well. Saw no regression while manually testing. A few suggestions below to aid in reading and understanding the code.

src/qt/rpcconsole.cpp Show resolved Hide resolved
src/qt/rpcconsole.cpp Outdated Show resolved Hide resolved
src/qt/rpcconsole.cpp Show resolved Hide resolved
src/qt/rpcconsole.cpp Show resolved Hide resolved
src/qt/peertablemodel.h Show resolved Hide resolved
This change allows access to CNodeCombinedStats instance directly from
any view object.
This change prevents direct calls to the PeerTableModel object that is a
layer violation.
@hebasto
Copy link
Member Author

hebasto commented Dec 30, 2020

Updated 4c05fe0 -> b3e9bca (pr161.02 -> pr161.03):

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Tested re-ACK b3e9bca per git range-diff ae8f797 4c05fe0 b3e9bca

Thanks for updating.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Code review ACK b3e9bca.

As follow ups, maybe it could make sense to split each member of

struct CNodeCombinedStats {
    CNodeStats nodeStats;
    CNodeStateStats nodeStateStats;
    bool fNodeStateStatsAvailable;
};

on a dedicated role.

Or just add some other roles like:

- const auto stats = peer.data(PeerTableModel::StatsRole).value<CNodeCombinedStats*>();
- cachedNodeids.append(stats->nodeStats.nodeid);
+ cachedNodeids.append(peer.data(PeerTableModel::NodeIdRole).toInt());

Copy link
Contributor

@jonasschnelli jonasschnelli left a comment

Choose a reason for hiding this comment

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

utACK b3e9bca

@jonasschnelli jonasschnelli merged commit 616eace into bitcoin-core:master Jan 11, 2021
@hebasto hebasto deleted the 201223-ban branch January 11, 2021 08:12
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 11, 2021
…data layer violation

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
@bitcoin-core bitcoin-core locked as resolved and limited conversation to collaborators Aug 16, 2022
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.

4 participants