Skip to content

Commit e44753c

Browse files
committed
Merge #8949: Be more agressive in getting connections to peers with relevant services.
4630479 Make dnsseed's definition of acute need include relevant services. (Gregory Maxwell) 9583477 Be more aggressive in connecting to peers with relevant services. (Gregory Maxwell)
2 parents 1230890 + 4630479 commit e44753c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/net.cpp

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

14701473
LOCK(cs_vNodes);
1471-
if (vNodes.size() >= 2) {
1474+
int nRelevant = 0;
1475+
for (auto pnode : vNodes) {
1476+
nRelevant += pnode->fSuccessfullyConnected && ((pnode->nServices & nRelevantServices) == nRelevantServices);
1477+
}
1478+
if (nRelevant >= 2) {
14721479
LogPrintf("P2P peers available. Skipped DNS seeding.\n");
14731480
return;
14741481
}
@@ -1675,8 +1682,8 @@ void CConnman::ThreadOpenConnections()
16751682
if (nANow - addr.nLastTry < 600 && nTries < 30)
16761683
continue;
16771684

1678-
// only consider nodes missing relevant services after 40 failed attempts
1679-
if ((addr.nServices & nRelevantServices) != nRelevantServices && nTries < 40)
1685+
// only consider nodes missing relevant services after 40 failed attempts and only if less than half the outbound are up.
1686+
if ((addr.nServices & nRelevantServices) != nRelevantServices && (nTries < 40 || nOutbound >= (nMaxOutbound >> 1)))
16801687
continue;
16811688

16821689
// do not allow non-default ports, unless after 50 invalid addresses selected already

0 commit comments

Comments
 (0)