aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 8ca6df0f9b..e1cfc565d6 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2267,6 +2267,72 @@ bool CConnman::RemoveAddedNode(const std::string& strNode)
return false;
}
+size_t CConnman::GetNodeCount(NumConnections flags)
+{
+ LOCK(cs_vNodes);
+ if (flags == CConnman::CONNECTIONS_ALL) // Shortcut if we want total
+ return vNodes.size();
+
+ int nNum = 0;
+ for(std::vector<CNode*>::const_iterator it = vNodes.begin(); it != vNodes.end(); ++it)
+ if (flags & ((*it)->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT))
+ nNum++;
+
+ return nNum;
+}
+
+void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats)
+{
+ vstats.clear();
+ LOCK(cs_vNodes);
+ vstats.reserve(vNodes.size());
+ for(std::vector<CNode*>::iterator it = vNodes.begin(); it != vNodes.end(); ++it) {
+ CNode* pnode = *it;
+ CNodeStats stats;
+ pnode->copyStats(stats);
+ vstats.push_back(stats);
+ }
+}
+
+bool CConnman::DisconnectAddress(const CNetAddr& netAddr)
+{
+ if (CNode* pnode = FindNode(netAddr)) {
+ pnode->fDisconnect = true;
+ return true;
+ }
+ return false;
+}
+
+bool CConnman::DisconnectSubnet(const CSubNet& subNet)
+{
+ if (CNode* pnode = FindNode(subNet)) {
+ pnode->fDisconnect = true;
+ return true;
+ }
+ return false;
+}
+
+bool CConnman::DisconnectNode(const std::string& strNode)
+{
+ if (CNode* pnode = FindNode(strNode)) {
+ pnode->fDisconnect = true;
+ return true;
+ }
+ return false;
+}
+
+bool CConnman::DisconnectNode(NodeId id)
+{
+ LOCK(cs_vNodes);
+ for(CNode* pnode : vNodes) {
+ if (id == pnode->id) {
+ pnode->fDisconnect = true;
+ return true;
+ }
+ }
+ return false;
+}
+
void RelayTransaction(const CTransaction& tx)
{
CInv inv(MSG_TX, tx.GetHash());