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

Method ThreadOpenAddedConnections

src/net.cpp:1959–1984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1957}
1958
1959void CConnman::ThreadOpenAddedConnections()
1960{
1961 while (true)
1962 {
1963 CSemaphoreGrant grant(*semAddnode);
1964 std::vector<AddedNodeInfo> vInfo = GetAddedNodeInfo();
1965 bool tried = false;
1966 for (const AddedNodeInfo& info : vInfo) {
1967 if (!info.fConnected) {
1968 if (!grant.TryAcquire()) {
1969 // If we've used up our semaphore and need a new one, let's not wait here since while we are waiting
1970 // the addednodeinfo state might change.
1971 break;
1972 }
1973 tried = true;
1974 CAddress addr(CService(), NODE_NONE);
1975 OpenNetworkConnection(addr, false, &grant, info.strAddedNode.c_str(), false, false, true);
1976 if (!interruptNet.sleep_for(std::chrono::milliseconds(500)))
1977 return;
1978 }
1979 }
1980 // Retry every 60 seconds if a connection was attempted, otherwise two seconds
1981 if (!interruptNet.sleep_for(std::chrono::seconds(tried ? 60 : 2)))
1982 return;
1983 }
1984}
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)

Callers

nothing calls this directly

Calls 3

TryAcquireMethod · 0.80
sleep_forMethod · 0.80
CServiceClass · 0.70

Tested by

no test coverage detected