MCPcopy Create free account
hub / github.com/ElementsProject/elements / OpenNetworkConnection

Method OpenNetworkConnection

src/net.cpp:2285–2318  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2283
2284// if successful, this moves the passed grant to the constructed node
2285void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, ConnectionType conn_type)
2286{
2287 assert(conn_type != ConnectionType::INBOUND);
2288
2289 //
2290 // Initiate outbound network connection
2291 //
2292 if (interruptNet) {
2293 return;
2294 }
2295 if (!fNetworkActive) {
2296 return;
2297 }
2298 if (!pszDest) {
2299 bool banned_or_discouraged = m_banman && (m_banman->IsDiscouraged(addrConnect) || m_banman->IsBanned(addrConnect));
2300 if (IsLocal(addrConnect) || banned_or_discouraged || AlreadyConnectedToAddress(addrConnect)) {
2301 return;
2302 }
2303 } else if (FindNode(std::string(pszDest)))
2304 return;
2305
2306 CNode* pnode = ConnectNode(addrConnect, pszDest, fCountFailure, conn_type);
2307
2308 if (!pnode)
2309 return;
2310 if (grantOutbound)
2311 grantOutbound->MoveTo(pnode->grantOutbound);
2312
2313 m_msgproc->InitializeNode(pnode);
2314 {
2315 LOCK(m_nodes_mutex);
2316 m_nodes.push_back(pnode);
2317 }
2318}
2319
2320void CConnman::ThreadMessageHandler()
2321{

Callers 1

addnodeFunction · 0.80

Calls 6

IsLocalFunction · 0.85
IsDiscouragedMethod · 0.80
IsBannedMethod · 0.80
MoveToMethod · 0.80
InitializeNodeMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected