MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / OpenNetworkConnection

Function OpenNetworkConnection

src/net.cpp:1506–1534  ·  view source on GitHub ↗

if successful, this moves the passed grant to the constructed node

Source from the content-addressed store, hash-verified

1504
1505// if successful, this moves the passed grant to the constructed node
1506bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler)
1507{
1508 //
1509 // Initiate outbound network connection
1510 //
1511 boost::this_thread::interruption_point();
1512 if (!pszDest) {
1513 if (IsLocal(addrConnect) ||
1514 FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) ||
1515 FindNode(addrConnect.ToStringIPPort()))
1516 return false;
1517 } else if (FindNode(std::string(pszDest)))
1518 return false;
1519
1520 CNode* pnode = ConnectNode(addrConnect, pszDest, fCountFailure);
1521 boost::this_thread::interruption_point();
1522
1523 if (!pnode)
1524 return false;
1525 if (grantOutbound)
1526 grantOutbound->MoveTo(pnode->grantOutbound);
1527 pnode->fNetworkNode = true;
1528 if (fOneShot)
1529 pnode->fOneShot = true;
1530 if (fFeeler)
1531 pnode->fFeeler = true;
1532
1533 return true;
1534}
1535
1536
1537void ThreadMessageHandler()

Callers 4

addnodeFunction · 0.85
ProcessOneShotFunction · 0.85
BOOST_FOREACHFunction · 0.85
ThreadOpenConnectionsFunction · 0.85

Calls 5

IsLocalFunction · 0.85
FindNodeFunction · 0.85
ConnectNodeFunction · 0.85
ToStringIPPortMethod · 0.80
MoveToMethod · 0.80

Tested by

no test coverage detected