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

Method OpenNetworkConnection

src/net.cpp:1987–2024  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1985
1986// if successful, this moves the passed grant to the constructed node
1987void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection)
1988{
1989 //
1990 // Initiate outbound network connection
1991 //
1992 if (interruptNet) {
1993 return;
1994 }
1995 if (!fNetworkActive) {
1996 return;
1997 }
1998 if (!pszDest) {
1999 if (IsLocal(addrConnect) ||
2000 FindNode(static_cast<CNetAddr>(addrConnect)) || IsBanned(addrConnect) ||
2001 FindNode(addrConnect.ToStringIPPort()))
2002 return;
2003 } else if (FindNode(std::string(pszDest)))
2004 return;
2005
2006 CNode* pnode = ConnectNode(addrConnect, pszDest, fCountFailure, manual_connection);
2007
2008 if (!pnode)
2009 return;
2010 if (grantOutbound)
2011 grantOutbound->MoveTo(pnode->grantOutbound);
2012 if (fOneShot)
2013 pnode->fOneShot = true;
2014 if (fFeeler)
2015 pnode->fFeeler = true;
2016 if (manual_connection)
2017 pnode->m_manual_connection = true;
2018
2019 m_msgproc->InitializeNode(pnode);
2020 {
2021 LOCK(cs_vNodes);
2022 vNodes.push_back(pnode);
2023 }
2024}
2025
2026void CConnman::ThreadMessageHandler()
2027{

Callers 1

addnodeFunction · 0.80

Calls 5

IsLocalFunction · 0.85
ToStringIPPortMethod · 0.80
MoveToMethod · 0.80
InitializeNodeMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected