Changeset View
Changeset View
Standalone View
Standalone View
src/qt/peertablemodel.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <qt/peertablemodel.h> | #include <qt/peertablemodel.h> | ||||
#include <qt/clientmodel.h> | #include <qt/clientmodel.h> | ||||
#include <qt/guiconstants.h> | #include <qt/guiconstants.h> | ||||
#include <qt/guiutil.h> | #include <qt/guiutil.h> | ||||
#include <interfaces/node.h> | #include <interfaces/node.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <validation.h> // for cs_main | #include <validation.h> // for cs_main | ||||
#include <algorithm> | |||||
#include <QDebug> | #include <QDebug> | ||||
#include <QList> | #include <QList> | ||||
#include <QTimer> | #include <QTimer> | ||||
bool NodeLessThan::operator()(const CNodeCombinedStats &left, | bool NodeLessThan::operator()(const CNodeCombinedStats &left, | ||||
const CNodeCombinedStats &right) const { | const CNodeCombinedStats &right) const { | ||||
const CNodeStats *pLeft = &(left.nodeStats); | const CNodeStats *pLeft = &(left.nodeStats); | ||||
const CNodeStats *pRight = &(right.nodeStats); | const CNodeStats *pRight = &(right.nodeStats); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | void refreshPeers(interfaces::Node &node) { | ||||
stats.nodeStateStats = std::get<2>(node_stats); | stats.nodeStateStats = std::get<2>(node_stats); | ||||
cachedNodeStats.append(stats); | cachedNodeStats.append(stats); | ||||
} | } | ||||
} | } | ||||
if (sortColumn >= 0) { | if (sortColumn >= 0) { | ||||
// sort cacheNodeStats (use stable sort to prevent rows jumping | // sort cacheNodeStats (use stable sort to prevent rows jumping | ||||
// around unnecessarily) | // around unnecessarily) | ||||
qStableSort(cachedNodeStats.begin(), cachedNodeStats.end(), | std::stable_sort(cachedNodeStats.begin(), cachedNodeStats.end(), | ||||
NodeLessThan(sortColumn, sortOrder)); | NodeLessThan(sortColumn, sortOrder)); | ||||
} | } | ||||
// build index map | // build index map | ||||
mapNodeRows.clear(); | mapNodeRows.clear(); | ||||
int row = 0; | int row = 0; | ||||
for (const CNodeCombinedStats &stats : cachedNodeStats) { | for (const CNodeCombinedStats &stats : cachedNodeStats) { | ||||
mapNodeRows.insert( | mapNodeRows.insert( | ||||
std::pair<NodeId, int>(stats.nodeStats.nodeid, row++)); | std::pair<NodeId, int>(stats.nodeStats.nodeid, row++)); | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |