Skip to content

Commit 4630479

Browse files
committed
Make dnsseed's definition of acute need include relevant services.
We normally prefer to connect to peers offering the relevant services. If we're not connected to enough peers with relevant services, we probably don't know about them and could use dnsseed's help.
1 parent 9583477 commit 4630479

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/net.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,12 +1462,19 @@ static std::string GetDNSHost(const CDNSSeedData& data, ServiceFlags* requiredSe
14621462
void CConnman::ThreadDNSAddressSeed()
14631463
{
14641464
// goal: only query DNS seeds if address need is acute
1465+
// Avoiding DNS seeds when we don't need them improves user privacy by
1466+
// creating fewer identifying DNS requests, reduces trust by giving seeds
1467+
// less influence on the network topology, and reduces traffic to the seeds.
14651468
if ((addrman.size() > 0) &&
14661469
(!GetBoolArg("-forcednsseed", DEFAULT_FORCEDNSSEED))) {
14671470
MilliSleep(11 * 1000);
14681471

14691472
LOCK(cs_vNodes);
1470-
if (vNodes.size() >= 2) {
1473+
int nRelevant = 0;
1474+
for (auto pnode : vNodes) {
1475+
nRelevant += pnode->fSuccessfullyConnected && ((pnode->nServices & nRelevantServices) == nRelevantServices);
1476+
}
1477+
if (nRelevant >= 2) {
14711478
LogPrintf("P2P peers available. Skipped DNS seeding.\n");
14721479
return;
14731480
}

0 commit comments

Comments
 (0)