aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-04-16 19:13:12 -0400
committerCory Fields <cory-nospam-@coryfields.com>2016-09-08 12:24:06 -0400
commit53347f0cb99e514815e44a56439a4a10012238f8 (patch)
treefc5baefe46ef918143904a299fd8aa5083097eda /src/net.h
parentc0569c7fa1e25599b3f1d6a16b15ec23052021da (diff)
net: create generic functor accessors and move vNodes to CConnman
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/net.h b/src/net.h
index 9e2408cd70..5b1e80bfbe 100644
--- a/src/net.h
+++ b/src/net.h
@@ -95,12 +95,7 @@ struct AddedNodeInfo
bool fInbound;
};
-CNode* FindNode(const CNetAddr& ip);
-CNode* FindNode(const CSubNet& subNet);
-CNode* FindNode(const std::string& addrName);
-CNode* FindNode(const CService& ip);
-CNode* FindNode(const NodeId id); //TODO: Remove this
-
+class CTransaction;
class CNodeStats;
class CConnman
{
@@ -120,6 +115,14 @@ public:
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false, bool fFeeler = false);
+ bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);
+ bool ForEachNode(std::function<bool(CNode* pnode)> func);
+ bool ForEachNode(std::function<bool(const CNode* pnode)> func) const;
+ bool ForEachNodeThen(std::function<bool(CNode* pnode)> pre, std::function<void()> post);
+ bool ForEachNodeThen(std::function<bool(const CNode* pnode)> pre, std::function<void()> post) const;
+
+ void RelayTransaction(const CTransaction& tx);
+
// Addrman functions
size_t GetAddressCount() const;
void SetServices(const CService &addr, ServiceFlags nServices);
@@ -182,6 +185,12 @@ private:
void ThreadSocketHandler();
void ThreadDNSAddressSeed();
+ CNode* FindNode(const CNetAddr& ip);
+ CNode* FindNode(const CSubNet& subNet);
+ CNode* FindNode(const std::string& addrName);
+ CNode* FindNode(const CService& addr);
+
+ bool AttemptToEvictConnection();
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure);
void DeleteNode(CNode* pnode);
//!check is the banlist has unwritten changes
@@ -204,6 +213,8 @@ private:
CCriticalSection cs_vOneShots;
std::vector<std::string> vAddedNodes;
CCriticalSection cs_vAddedNodes;
+ std::vector<CNode*> vNodes;
+ mutable CCriticalSection cs_vNodes;
};
extern std::unique_ptr<CConnman> g_connman;
void MapPort(bool fUseUPnP);
@@ -279,8 +290,6 @@ extern uint64_t nLocalHostNonce;
/** Maximum number of connections to simultaneously allow (aka connection slots) */
extern int nMaxConnections;
-extern std::vector<CNode*> vNodes;
-extern CCriticalSection cs_vNodes;
extern limitedmap<uint256, int64_t> mapAlreadyAskedFor;
extern NodeId nLastNodeId;
@@ -828,8 +837,6 @@ public:
-class CTransaction;
-void RelayTransaction(const CTransaction& tx);
/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */