Skip to content

Commit

Permalink
Cap nAttempts penalty at 8 and switch to pow instead of a division loop.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
gmaxwell committed Apr 19, 2015
1 parent 8f955b9 commit a784f90
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

This comment has been minimized.

Copy link
@gmaxwell

gmaxwell Apr 19, 2015

Author Contributor

Note that the prior comment was incorrect. 1/1.5 is 2/3s.

fChance *= pow(0.66, min(nAttempts, 8));

return fChance;
}
Expand Down

0 comments on commit a784f90

Please sign in to comment.