aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2015-04-19 11:47:56 -0700
committerWladimir J. van der Laan <laanwj@gmail.com>2015-04-20 13:59:19 +0200
commit139cd8177be4895f8b4c2befee35030bdf961326 (patch)
tree899885fdf0bf7aa7a57953bcc5303f4d85cb4f81 /src
parentbac6fca3c91ba4c0e3c64d65c5c359b50036a2b6 (diff)
downloadbitcoin-139cd8177be4895f8b4c2befee35030bdf961326.tar.xz
Cap nAttempts penalty at 8 and switch to pow instead of a division loop.
On hosts that had spent some time with a failed internet connection their nAttempts penalty was going through the roof (e.g. thousands for all peers) and as a result the connect search was pegging the CPU and failing to get more than a 4 connections after days of running (because it was taking so long per try). Rebased-From: a784f90c9892f06b9fea4e7579f5eca3585482c3 Github-Pull: #6029
Diffstat (limited to 'src')
-rw-r--r--src/addrman.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 015589343d..ad7fa9bd51 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -67,9 +67,8 @@ double CAddrInfo::GetChance(int64_t nNow) const
if (nSinceLastTry < 60 * 10)
fChance *= 0.01;
- // deprioritize 50% after each failed attempt
- for (int n = 0; n < nAttempts; n++)
- fChance /= 1.5;
+ // deprioritize 66% after each failed attempt, but at most 1/28th to avoid the search taking forever or overly penalizing outages.
+ fChance *= pow(0.66, min(nAttempts, 8));
return fChance;
}