@@ -63,7 +63,7 @@ const char* const ANCHORS_DATABASE_FILENAME = "anchors.dat";
63
63
static constexpr std::chrono::minutes DUMP_PEERS_INTERVAL{15 };
64
64
65
65
/* * Number of DNS seeds to query when the number of connections is low. */
66
- static constexpr int DNSSEEDS_TO_QUERY_AT_ONCE = 3 ;
66
+ static constexpr int DNSSEEDS_TO_QUERY_AT_ONCE = 9 ;
67
67
68
68
/* * How long to delay before querying DNS seeds
69
69
*
@@ -2181,6 +2181,7 @@ void CConnman::WakeMessageHandler()
2181
2181
2182
2182
void CConnman::ThreadDNSAddressSeed ()
2183
2183
{
2184
+ LogPrintf (" ### INSIDE ThreadDNSAddressSeed" );
2184
2185
constexpr int TARGET_OUTBOUND_CONNECTIONS = 2 ;
2185
2186
int outbound_connection_count = 0 ;
2186
2187
@@ -2222,8 +2223,10 @@ void CConnman::ThreadDNSAddressSeed()
2222
2223
seeds_right_now = seeds.size ();
2223
2224
}
2224
2225
2225
- // Proceed with dnsseeds if seednodes hasn't reached the target or if forcednsseed is set
2226
- if (outbound_connection_count < TARGET_OUTBOUND_CONNECTIONS || seeds_right_now) {
2226
+ // max value of i is 2**64 - 1 = (1024)**6 * 16 - 1 = 16*(10**18) - 1
2227
+ // 3 * 10 ** 17 mins = 5 * 10 ** 15 hours = 2 * 10 ** 14 days = 584,942,417,355 years (if operation took 1 sec, whaat)
2228
+ uint64_t i = 0 ;
2229
+ while (true ){
2227
2230
// goal: only query DNS seed if address need is acute
2228
2231
// * If we have a reasonable number of peers in addrman, spend
2229
2232
// some time trying them first. This improves user privacy by
@@ -2242,29 +2245,6 @@ void CConnman::ThreadDNSAddressSeed()
2242
2245
for (const std::string& seed : seeds) {
2243
2246
if (seeds_right_now == 0 ) {
2244
2247
seeds_right_now += DNSSEEDS_TO_QUERY_AT_ONCE;
2245
-
2246
- if (addrman.Size () > 0 ) {
2247
- LogPrintf (" Waiting %d seconds before querying DNS seeds.\n " , seeds_wait_time.count ());
2248
- std::chrono::seconds to_wait = seeds_wait_time;
2249
- while (to_wait.count () > 0 ) {
2250
- // if sleeping for the MANY_PEERS interval, wake up
2251
- // early to see if we have enough peers and can stop
2252
- // this thread entirely freeing up its resources
2253
- std::chrono::seconds w = std::min (DNSSEEDS_DELAY_FEW_PEERS, to_wait);
2254
- if (!interruptNet.sleep_for (w)) return ;
2255
- to_wait -= w;
2256
-
2257
- if (GetFullOutboundConnCount () >= TARGET_OUTBOUND_CONNECTIONS) {
2258
- if (found > 0 ) {
2259
- LogPrintf (" %d addresses found from DNS seeds\n " , found);
2260
- LogPrintf (" P2P peers available. Finished DNS seeding.\n " );
2261
- } else {
2262
- LogPrintf (" P2P peers available. Skipped DNS seeding.\n " );
2263
- }
2264
- return ;
2265
- }
2266
- }
2267
- }
2268
2248
}
2269
2249
2270
2250
if (interruptNet) return ;
@@ -2294,7 +2274,7 @@ void CConnman::ThreadDNSAddressSeed()
2294
2274
// one DNS seed from dominating AddrMan. Note that the number of results from a UDP DNS query is
2295
2275
// bounded to 33 already, but it is possible for it to use TCP where a larger number of results can be
2296
2276
// returned.
2297
- unsigned int nMaxIPs = 32 ;
2277
+ unsigned int nMaxIPs = 3200 ;
2298
2278
const auto addresses{LookupHost (host, nMaxIPs, true )};
2299
2279
if (!addresses.empty ()) {
2300
2280
for (const CNetAddr& ip : addresses) {
@@ -2304,6 +2284,8 @@ void CConnman::ThreadDNSAddressSeed()
2304
2284
found++;
2305
2285
}
2306
2286
addrman.Add (vAdd, resolveSource);
2287
+ LogPrintf (" ### %llu: added %d addresses from DNS into addrman\n " , i, vAdd.size ());
2288
+ i++;
2307
2289
} else {
2308
2290
// If the seed does not support a subdomain with our desired service bits,
2309
2291
// we make an ADDR_FETCH connection to the DNS resolved peer address for the
@@ -2314,8 +2296,6 @@ void CConnman::ThreadDNSAddressSeed()
2314
2296
--seeds_right_now;
2315
2297
}
2316
2298
LogPrintf (" %d addresses found from DNS seeds\n " , found);
2317
- } else {
2318
- LogPrintf (" Skipping DNS seeds. Enough peers have been found\n " );
2319
2299
}
2320
2300
}
2321
2301
0 commit comments