aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-10-19 10:41:49 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-10-19 10:43:54 +0200
commite44753c0679497ceabf094ba08df06a8064332cf (patch)
treea41558f99d3070c9ce23ad6849c674ea89248b6c
parent1230890a6d04bd196e0a176de709296e0da2639d (diff)
parent46304791353d2bb61004a035869612620c30b4eb (diff)
downloadbitcoin-e44753c0679497ceabf094ba08df06a8064332cf.tar.xz
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)
-rw-r--r--src/net.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 34dc67eb43..1bca168d1d 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1463,12 +1463,19 @@ static std::string GetDNSHost(const CDNSSeedData& data, ServiceFlags* requiredSe
void CConnman::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;
}
@@ -1675,8 +1682,8 @@ void CConnman::ThreadOpenConnections()
if (nANow - addr.nLastTry < 600 && nTries < 30)
continue;
- // only consider nodes missing relevant services after 40 failed attempts
- if ((addr.nServices & nRelevantServices) != nRelevantServices && nTries < 40)
+ // only consider nodes missing relevant services after 40 failed attempts and only if less than half the outbound are up.
+ if ((addr.nServices & nRelevantServices) != nRelevantServices && (nTries < 40 || nOutbound >= (nMaxOutbound >> 1)))
continue;
// do not allow non-default ports, unless after 50 invalid addresses selected already