Skip to content

Commit

Permalink
gui: Drop PeerTableModel dependency to ClientModel
Browse files Browse the repository at this point in the history
Summary:
> Class PeerTableModel doesn't actually depend on ClientModel.

This removes the circular dependency `qt/clientmodel -> qt/peertablemodel -> qt/clientmodel`

This is a backport of Core [[bitcoin/bitcoin#18060 | PR18060]]

Test Plan:
`ninja && src/qt/bitcoin-qt`

PeerTableModel is used in the rpc console GUI.

`test/lint/lint-circular-dependencies.sh`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D8737
  • Loading branch information
promag authored and PiRK committed Dec 22, 2020
1 parent bc14a0e commit 972b80d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <qt/peertablemodel.h>

#include <qt/clientmodel.h>
#include <qt/guiconstants.h>
#include <qt/guiutil.h>

Expand Down Expand Up @@ -99,9 +98,8 @@ class PeerTablePriv {
}
};

PeerTableModel::PeerTableModel(interfaces::Node &node, ClientModel *parent)
: QAbstractTableModel(parent), m_node(node), clientModel(parent),
timer(nullptr) {
PeerTableModel::PeerTableModel(interfaces::Node &node, QObject *parent)
: QAbstractTableModel(parent), m_node(node), timer(nullptr) {
columns << tr("NodeId") << tr("Node/Service") << tr("Ping") << tr("Sent")
<< tr("Received") << tr("User Agent");
priv.reset(new PeerTablePriv());
Expand Down
5 changes: 1 addition & 4 deletions src/qt/peertablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include <memory>

class ClientModel;
class PeerTablePriv;

namespace interfaces {
Expand Down Expand Up @@ -50,8 +49,7 @@ class PeerTableModel : public QAbstractTableModel {
Q_OBJECT

public:
explicit PeerTableModel(interfaces::Node &node,
ClientModel *parent = nullptr);
explicit PeerTableModel(interfaces::Node &node, QObject *parent);
~PeerTableModel();
const CNodeCombinedStats *getNodeStats(int idx);
int getRowByNodeId(NodeId nodeid);
Expand Down Expand Up @@ -85,7 +83,6 @@ public Q_SLOTS:

private:
interfaces::Node &m_node;
ClientModel *clientModel;
QStringList columns;
std::unique_ptr<PeerTablePriv> priv;
QTimer *timer;
Expand Down
1 change: 0 additions & 1 deletion test/lint/lint-circular-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
"index/txindex -> validation -> index/txindex"
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
"qt/bitcoingui -> qt/walletframe -> qt/bitcoingui"
"qt/clientmodel -> qt/peertablemodel -> qt/clientmodel"
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel"
"txmempool -> validation -> txmempool"
Expand Down

0 comments on commit 972b80d

Please sign in to comment.