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

Function OpenNetworkConnection

src/net.cpp:1117–1142  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1115
1116// if successful, this moves the passed grant to the constructed node
1117bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant* grantOutbound, const char* strDest,
1118 bool fOneShot) {
1119 //
1120 // Initiate outbound network connection
1121 //
1122 boost::this_thread::interruption_point();
1123 if (!strDest)
1124 if (IsLocal(addrConnect) || FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) ||
1125 FindNode(addrConnect.ToStringIPPort().c_str()))
1126 return false;
1127 if (strDest && FindNode(strDest))
1128 return false;
1129
1130 CNode* pNode = ConnectNode(addrConnect, strDest);
1131 boost::this_thread::interruption_point();
1132
1133 if (!pNode)
1134 return false;
1135 if (grantOutbound)
1136 grantOutbound->MoveTo(pNode->grantOutbound);
1137 pNode->fNetworkNode = true;
1138 if (fOneShot)
1139 pNode->fOneShot = true;
1140
1141 return true;
1142}
1143
1144void static StartSync(const vector<CNode*>& vNodes) {
1145 CNode* pnodeNewSync = nullptr;

Callers 3

ProcessOneShotFunction · 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