diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2017-04-17 15:57:19 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2018-04-04 16:52:40 -0400 |
commit | e0b66a3b7c5d3a079636d61fcf611bb6b36c7bc1 (patch) | |
tree | 4115ee48eb6dd0689d22a9029b27ecfffcdb8873 /src/qt/peertablemodel.cpp | |
parent | d7c2c9594897c39df6739b92610dfb5a7a1cb3ec (diff) |
Remove direct bitcoin calls from qt/peertablemodel.cpp
Diffstat (limited to 'src/qt/peertablemodel.cpp')
-rw-r--r-- | src/qt/peertablemodel.cpp | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 0a57dcfca3..f33db8e761 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -8,6 +8,7 @@ #include <qt/guiconstants.h> #include <qt/guiutil.h> +#include <interface/node.h> #include <validation.h> // for cs_main #include <sync.h> @@ -56,38 +57,26 @@ public: std::map<NodeId, int> mapNodeRows; /** Pull a full list of peers from vNodes into our cache */ - void refreshPeers() + void refreshPeers(interface::Node& node) { { cachedNodeStats.clear(); - std::vector<CNodeStats> vstats; - if(g_connman) - g_connman->GetNodeStats(vstats); + + interface::Node::NodesStats nodes_stats; + node.getNodesStats(nodes_stats); #if QT_VERSION >= 0x040700 - cachedNodeStats.reserve(vstats.size()); + cachedNodeStats.reserve(nodes_stats.size()); #endif - for (const CNodeStats& nodestats : vstats) + for (auto& node_stats : nodes_stats) { CNodeCombinedStats stats; - stats.nodeStateStats.nMisbehavior = 0; - stats.nodeStateStats.nSyncHeight = -1; - stats.nodeStateStats.nCommonHeight = -1; - stats.fNodeStateStatsAvailable = false; - stats.nodeStats = nodestats; + stats.nodeStats = std::get<0>(node_stats); + stats.fNodeStateStatsAvailable = std::get<1>(node_stats); + stats.nodeStateStats = std::get<2>(node_stats); cachedNodeStats.append(stats); } } - // Try to retrieve the CNodeStateStats for each node. - { - TRY_LOCK(cs_main, lockMain); - if (lockMain) - { - for (CNodeCombinedStats &stats : cachedNodeStats) - stats.fNodeStateStatsAvailable = GetNodeStateStats(stats.nodeStats.nodeid, stats.nodeStateStats); - } - } - if (sortColumn >= 0) // sort cacheNodeStats (use stable sort to prevent rows jumping around unnecessarily) qStableSort(cachedNodeStats.begin(), cachedNodeStats.end(), NodeLessThan(sortColumn, sortOrder)); @@ -113,8 +102,9 @@ public: } }; -PeerTableModel::PeerTableModel(ClientModel *parent) : +PeerTableModel::PeerTableModel(interface::Node& node, ClientModel *parent) : QAbstractTableModel(parent), + m_node(node), clientModel(parent), timer(0) { @@ -235,7 +225,7 @@ const CNodeCombinedStats *PeerTableModel::getNodeStats(int idx) void PeerTableModel::refresh() { Q_EMIT layoutAboutToBeChanged(); - priv->refreshPeers(); + priv->refreshPeers(m_node); Q_EMIT layoutChanged(); } |