aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2016-05-06 11:50:24 -0700
committerMatt Corallo <git@bluematt.me>2016-06-19 23:06:55 -0700
commit927f8eede0c9e0ab9cc2b5e43e39cfe3e1340dd6 (patch)
tree5881ee45f21ce4ca0c23d86350fabbdba855a140 /src
parentd25cd3ec4e8961c5f36c29a65395f52d0db294c5 (diff)
downloadbitcoin-927f8eede0c9e0ab9cc2b5e43e39cfe3e1340dd6.tar.xz
Add ability to fetch CNode by NodeId
Diffstat (limited to 'src')
-rw-r--r--src/net.cpp10
-rw-r--r--src/net.h5
2 files changed, 13 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 4eca3d75cc..336163a896 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -368,6 +368,16 @@ CNode* FindNode(const CService& addr)
return NULL;
}
+//TODO: This is used in only one place in main, and should be removed
+CNode* FindNode(const NodeId nodeid)
+{
+ LOCK(cs_vNodes);
+ BOOST_FOREACH(CNode* pnode, vNodes)
+ if (pnode->GetId() == nodeid)
+ return (pnode);
+ return NULL;
+}
+
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure)
{
if (pszDest == NULL) {
diff --git a/src/net.h b/src/net.h
index 67b95fe0e4..aa9b2c11a3 100644
--- a/src/net.h
+++ b/src/net.h
@@ -80,12 +80,15 @@ static const unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Defaul
unsigned int ReceiveFloodSize();
unsigned int SendBufferSize();
+typedef int NodeId;
+
void AddOneShot(const std::string& strDest);
void AddressCurrentlyConnected(const CService& addr);
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
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);
void MapPort(bool fUseUPnP);
unsigned short GetListenPort();
@@ -94,8 +97,6 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler);
bool StopNode();
void SocketSendData(CNode *pnode);
-typedef int NodeId;
-
struct CombinerAll
{
typedef bool result_type;