@@ -342,8 +342,8 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
342
342
CNode* pnode = FindNode ((CService)addrConnect);
343
343
if (pnode)
344
344
{
345
- pnode-> AddRef ( );
346
- return pnode ;
345
+ LogPrintf ( " Failed to open new connection, already connected \n " );
346
+ return NULL ;
347
347
}
348
348
}
349
349
@@ -369,18 +369,16 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
369
369
// In that case, drop the connection that was just created, and return the existing CNode instead.
370
370
// Also store the name we used to connect in that CNode, so that future FindNode() calls to that
371
371
// name catch this early.
372
+ LOCK (cs_vNodes);
372
373
CNode* pnode = FindNode ((CService)addrConnect);
373
374
if (pnode)
374
375
{
375
- pnode->AddRef ();
376
- {
377
- LOCK (cs_vNodes);
378
- if (pnode->addrName .empty ()) {
379
- pnode->addrName = std::string (pszDest);
380
- }
376
+ if (pnode->addrName .empty ()) {
377
+ pnode->addrName = std::string (pszDest);
381
378
}
382
379
CloseSocket (hSocket);
383
- return pnode;
380
+ LogPrintf (" Failed to open new connection, already connected\n " );
381
+ return NULL ;
384
382
}
385
383
}
386
384
@@ -393,11 +391,6 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
393
391
pnode->nServicesExpected = ServiceFlags (addrConnect.nServices & nRelevantServices);
394
392
pnode->nTimeConnected = GetSystemTimeInSeconds ();
395
393
pnode->AddRef ();
396
- GetNodeSignals ().InitializeNode (pnode, *this );
397
- {
398
- LOCK (cs_vNodes);
399
- vNodes.push_back (pnode);
400
- }
401
394
402
395
return pnode;
403
396
} else if (!proxyConnectionFailed) {
@@ -1840,6 +1833,12 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
1840
1833
if (fAddnode )
1841
1834
pnode->fAddnode = true ;
1842
1835
1836
+ {
1837
+ LOCK (cs_vNodes);
1838
+ vNodes.push_back (pnode);
1839
+ }
1840
+ GetNodeSignals ().InitializeNode (pnode, *this );
1841
+
1843
1842
return true ;
1844
1843
}
1845
1844
@@ -2371,26 +2370,9 @@ void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats)
2371
2370
}
2372
2371
}
2373
2372
2374
- bool CConnman::DisconnectAddress (const CNetAddr& netAddr)
2375
- {
2376
- if (CNode* pnode = FindNode (netAddr)) {
2377
- pnode->fDisconnect = true ;
2378
- return true ;
2379
- }
2380
- return false ;
2381
- }
2382
-
2383
- bool CConnman::DisconnectSubnet (const CSubNet& subNet)
2384
- {
2385
- if (CNode* pnode = FindNode (subNet)) {
2386
- pnode->fDisconnect = true ;
2387
- return true ;
2388
- }
2389
- return false ;
2390
- }
2391
-
2392
2373
bool CConnman::DisconnectNode (const std::string& strNode)
2393
2374
{
2375
+ LOCK (cs_vNodes);
2394
2376
if (CNode* pnode = FindNode (strNode)) {
2395
2377
pnode->fDisconnect = true ;
2396
2378
return true ;
@@ -2409,16 +2391,6 @@ bool CConnman::DisconnectNode(NodeId id)
2409
2391
return false ;
2410
2392
}
2411
2393
2412
- void CConnman::RelayTransaction (const CTransaction& tx)
2413
- {
2414
- CInv inv (MSG_TX, tx.GetHash ());
2415
- LOCK (cs_vNodes);
2416
- BOOST_FOREACH (CNode* pnode, vNodes)
2417
- {
2418
- pnode->PushInventory (inv);
2419
- }
2420
- }
2421
-
2422
2394
void CConnman::RecordBytesRecv (uint64_t bytes)
2423
2395
{
2424
2396
LOCK (cs_totalBytesRecv);
0 commit comments