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.

Github-Pull: #8949
Rebased-From: 4630479135
This commit is contained in:
Gregory Maxwell 2016-10-17 23:11:35 +00:00 committed by Wladimir J. van der Laan
parent 33cd5539b2
commit 91ae0b06b9
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
1 changed files with 8 additions and 1 deletions

View File

@ -1497,12 +1497,19 @@ static std::string GetDNSHost(const CDNSSeedData& data, ServiceFlags* requiredSe
void ThreadDNSAddressSeed()
{
// goal: only query DNS seeds if address need is acute
// Avoiding DNS seeds when we don't need them improves user privacy by
// creating fewer identifying DNS requests, reduces trust by giving seeds
// less influence on the network topology, and reduces traffic to the seeds.
if ((addrman.size() > 0) &&
(!GetBoolArg("-forcednsseed", DEFAULT_FORCEDNSSEED))) {
MilliSleep(11 * 1000);
LOCK(cs_vNodes);
if (vNodes.size() >= 2) {
int nRelevant = 0;
for (auto pnode : vNodes) {
nRelevant += pnode->fSuccessfullyConnected && ((pnode->nServices & nRelevantServices) == nRelevantServices);
}
if (nRelevant >= 2) {
LogPrintf("P2P peers available. Skipped DNS seeding.\n");
return;
}