Skip to content

Commit 4ad23d2

Browse files
committed
Merge pull request #4559
2e7009d Avoid querying DNS seeds, if we have open connections. (Jeff Garzik)
2 parents 2920322 + 2e7009d commit 4ad23d2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/init.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ std::string HelpMessage(HelpMessageMode mode)
240240
strUsage += " -connect=<ip> " + _("Connect only to the specified node(s)") + "\n";
241241
strUsage += " -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n";
242242
strUsage += " -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + " " + _("(default: 1)") + "\n";
243-
strUsage += " -dnsseed " + _("Find peers using DNS lookup (default: 1 unless -connect)") + "\n";
243+
strUsage += " -dnsseed " + _("Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect)") + "\n";
244+
strUsage += " -forcednsseed " + _("Always query for peer addresses via DNS lookup (default: 0)") + "\n";
244245
strUsage += " -externalip=<ip> " + _("Specify your own public address") + "\n";
245246
strUsage += " -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n";
246247
strUsage += " -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n";

src/net.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,18 @@ void MapPort(bool)
12211221

12221222
void ThreadDNSAddressSeed()
12231223
{
1224+
// goal: only query DNS seeds if address need is acute
1225+
if ((addrman.size() > 0) &&
1226+
(!GetBoolArg("-forcednsseed", false))) {
1227+
MilliSleep(11 * 1000);
1228+
1229+
LOCK(cs_vNodes);
1230+
if (vNodes.size() >= 2) {
1231+
LogPrintf("P2P peers available. Skipped DNS seeding.\n");
1232+
return;
1233+
}
1234+
}
1235+
12241236
const vector<CDNSSeedData> &vSeeds = Params().DNSSeeds();
12251237
int found = 0;
12261238

0 commit comments

Comments
 (0)