Skip to content

Commit 927f8ee

Browse files
committed
Add ability to fetch CNode by NodeId
1 parent d25cd3e commit 927f8ee

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/net.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,16 @@ CNode* FindNode(const CService& addr)
368368
return NULL;
369369
}
370370

371+
//TODO: This is used in only one place in main, and should be removed
372+
CNode* FindNode(const NodeId nodeid)
373+
{
374+
LOCK(cs_vNodes);
375+
BOOST_FOREACH(CNode* pnode, vNodes)
376+
if (pnode->GetId() == nodeid)
377+
return (pnode);
378+
return NULL;
379+
}
380+
371381
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure)
372382
{
373383
if (pszDest == NULL) {

src/net.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,15 @@ static const unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Defaul
8080
unsigned int ReceiveFloodSize();
8181
unsigned int SendBufferSize();
8282

83+
typedef int NodeId;
84+
8385
void AddOneShot(const std::string& strDest);
8486
void AddressCurrentlyConnected(const CService& addr);
8587
CNode* FindNode(const CNetAddr& ip);
8688
CNode* FindNode(const CSubNet& subNet);
8789
CNode* FindNode(const std::string& addrName);
8890
CNode* FindNode(const CService& ip);
91+
CNode* FindNode(const NodeId id); //TODO: Remove this
8992
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);
9093
void MapPort(bool fUseUPnP);
9194
unsigned short GetListenPort();
@@ -94,8 +97,6 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler);
9497
bool StopNode();
9598
void SocketSendData(CNode *pnode);
9699

97-
typedef int NodeId;
98-
99100
struct CombinerAll
100101
{
101102
typedef bool result_type;

0 commit comments

Comments
 (0)