aboutsummaryrefslogtreecommitdiff
path: root/src/interface
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2017-04-17 15:57:19 -0400
committerJohn Newbery <john@johnnewbery.com>2018-04-04 16:52:40 -0400
commite0b66a3b7c5d3a079636d61fcf611bb6b36c7bc1 (patch)
tree4115ee48eb6dd0689d22a9029b27ecfffcdb8873 /src/interface
parentd7c2c9594897c39df6739b92610dfb5a7a1cb3ec (diff)
Remove direct bitcoin calls from qt/peertablemodel.cpp
Diffstat (limited to 'src/interface')
-rw-r--r--src/interface/node.cpp26
-rw-r--r--src/interface/node.h8
2 files changed, 34 insertions, 0 deletions
diff --git a/src/interface/node.cpp b/src/interface/node.cpp
index 281164779d..1937fe9d9b 100644
--- a/src/interface/node.cpp
+++ b/src/interface/node.cpp
@@ -10,6 +10,7 @@
#include <interface/handler.h>
#include <interface/wallet.h>
#include <net.h>
+#include <net_processing.h>
#include <netaddress.h>
#include <netbase.h>
#include <primitives/block.h>
@@ -79,6 +80,31 @@ class NodeImpl : public Node
{
return g_connman ? g_connman->GetNodeCount(flags) : 0;
}
+ bool getNodesStats(NodesStats& stats) override
+ {
+ stats.clear();
+
+ if (g_connman) {
+ std::vector<CNodeStats> stats_temp;
+ g_connman->GetNodeStats(stats_temp);
+
+ stats.reserve(stats_temp.size());
+ for (auto& node_stats_temp : stats_temp) {
+ stats.emplace_back(std::move(node_stats_temp), false, CNodeStateStats());
+ }
+
+ // Try to retrieve the CNodeStateStats for each node.
+ TRY_LOCK(::cs_main, lockMain);
+ if (lockMain) {
+ for (auto& node_stats : stats) {
+ std::get<1>(node_stats) =
+ GetNodeStateStats(std::get<0>(node_stats).nodeid, std::get<2>(node_stats));
+ }
+ }
+ return true;
+ }
+ return false;
+ }
int64_t getTotalBytesRecv() override { return g_connman ? g_connman->GetTotalBytesRecv() : 0; }
int64_t getTotalBytesSent() override { return g_connman ? g_connman->GetTotalBytesSent() : 0; }
size_t getMempoolSize() override { return ::mempool.size(); }
diff --git a/src/interface/node.h b/src/interface/node.h
index 5275030ca1..6288487032 100644
--- a/src/interface/node.h
+++ b/src/interface/node.h
@@ -14,8 +14,12 @@
#include <stddef.h>
#include <stdint.h>
#include <string>
+#include <tuple>
+#include <vector>
+class CNodeStats;
class proxyType;
+struct CNodeStateStats;
namespace interface {
@@ -79,6 +83,10 @@ public:
//! Get number of connections.
virtual size_t getNodeCount(CConnman::NumConnections flags) = 0;
+ //! Get stats for connected nodes.
+ using NodesStats = std::vector<std::tuple<CNodeStats, bool, CNodeStateStats>>;
+ virtual bool getNodesStats(NodesStats& stats) = 0;
+
//! Get total bytes recv.
virtual int64_t getTotalBytesRecv() = 0;