| 1742 | } |
| 1743 | |
| 1744 | void CConnman::ThreadOpenConnections(const std::vector<std::string> connect) |
| 1745 | { |
| 1746 | // Connect to specific addresses |
| 1747 | if (!connect.empty()) |
| 1748 | { |
| 1749 | for (int64_t nLoop = 0;; nLoop++) |
| 1750 | { |
| 1751 | ProcessOneShot(); |
| 1752 | for (const std::string& strAddr : connect) |
| 1753 | { |
| 1754 | CAddress addr(CService(), NODE_NONE); |
| 1755 | OpenNetworkConnection(addr, false, nullptr, strAddr.c_str(), false, false, true); |
| 1756 | for (int i = 0; i < 10 && i < nLoop; i++) |
| 1757 | { |
| 1758 | if (!interruptNet.sleep_for(std::chrono::milliseconds(500))) |
| 1759 | return; |
| 1760 | } |
| 1761 | } |
| 1762 | if (!interruptNet.sleep_for(std::chrono::milliseconds(500))) |
| 1763 | return; |
| 1764 | } |
| 1765 | } |
| 1766 | |
| 1767 | // Initiate network connections |
| 1768 | int64_t nStart = GetTime(); |
| 1769 | |
| 1770 | // Minimum time before next feeler connection (in microseconds). |
| 1771 | int64_t nNextFeeler = PoissonNextSend(nStart*1000*1000, FEELER_INTERVAL); |
| 1772 | while (!interruptNet) |
| 1773 | { |
| 1774 | ProcessOneShot(); |
| 1775 | |
| 1776 | if (!interruptNet.sleep_for(std::chrono::milliseconds(500))) |
| 1777 | return; |
| 1778 | |
| 1779 | CSemaphoreGrant grant(*semOutbound); |
| 1780 | if (interruptNet) |
| 1781 | return; |
| 1782 | |
| 1783 | // Add seed nodes if DNS seeds are all down (an infrastructure attack?). |
| 1784 | if (addrman.size() == 0 && (GetTime() - nStart > 60)) { |
| 1785 | static bool done = false; |
| 1786 | if (!done) { |
| 1787 | LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n"); |
| 1788 | CNetAddr local; |
| 1789 | local.SetInternal("fixedseeds"); |
| 1790 | addrman.Add(convertSeed6(Params().FixedSeeds()), local); |
| 1791 | done = true; |
| 1792 | } |
| 1793 | } |
| 1794 | |
| 1795 | // |
| 1796 | // Choose an address to connect to based on most recently seen |
| 1797 | // |
| 1798 | CAddress addrConnect; |
| 1799 | |
| 1800 | // Only connect out to one peer per network group (/16 for IPv4). |
| 1801 | int nOutbound = 0; |
nothing calls this directly
no test coverage detected