-
Notifications
You must be signed in to change notification settings - Fork 271
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,11 @@ | |
#include <net_processing.h> // For CNodeStateStats | ||
#include <net.h> | ||
|
||
#include <memory> | ||
|
||
#include <QAbstractTableModel> | ||
#include <QList> | ||
#include <QModelIndex> | ||
#include <QStringList> | ||
#include <QVariant> | ||
|
||
class PeerTablePriv; | ||
|
||
|
@@ -61,18 +62,23 @@ class PeerTableModel : public QAbstractTableModel | |
|
||
/** @name Methods overridden from QAbstractTableModel | ||
@{*/ | ||
int rowCount(const QModelIndex &parent) const override; | ||
int columnCount(const QModelIndex &parent) const override; | ||
QVariant data(const QModelIndex &index, int role) const override; | ||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override; | ||
QModelIndex index(int row, int column, const QModelIndex &parent) const override; | ||
int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
hebasto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int columnCount(const QModelIndex& parent = QModelIndex()) const override; | ||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; | ||
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; | ||
Qt::ItemFlags flags(const QModelIndex &index) const override; | ||
/*@}*/ | ||
|
||
public Q_SLOTS: | ||
void refresh(); | ||
|
||
Q_SIGNALS: | ||
void changed(); | ||
|
||
private: | ||
//! Internal peer data structure. | ||
QList<CNodeCombinedStats> m_peers_data{}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is redundant. Leaving as is to be explicit. |
||
interfaces::Node& m_node; | ||
const QStringList columns{ | ||
/*: Title of Peers Table column which contains a | ||
|
@@ -99,7 +105,6 @@ public Q_SLOTS: | |
/*: Title of Peers Table column which contains the peer's | ||
User Agent string. */ | ||
tr("User Agent")}; | ||
std::unique_ptr<PeerTablePriv> priv; | ||
QTimer *timer; | ||
}; | ||
|
||
|
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
:(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 :)
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.
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).