if successful, this moves the passed grant to the constructed node
| 2283 | |
| 2284 | // if successful, this moves the passed grant to the constructed node |
| 2285 | void 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 | |
| 2320 | void CConnman::ThreadMessageHandler() |
| 2321 | { |
no test coverage detected