| 85 | } |
| 86 | |
| 87 | double AddrInfo::GetChance(int64_t nNow) const |
| 88 | { |
| 89 | double fChance = 1.0; |
| 90 | int64_t nSinceLastTry = std::max<int64_t>(nNow - nLastTry, 0); |
| 91 | |
| 92 | // deprioritize very recent attempts away |
| 93 | if (nSinceLastTry < 60 * 10) |
| 94 | fChance *= 0.01; |
| 95 | |
| 96 | // deprioritize 66% after each failed attempt, but at most 1/28th to avoid the search taking forever or overly penalizing outages. |
| 97 | fChance *= pow(0.66, std::min(nAttempts, 8)); |
| 98 | |
| 99 | return fChance; |
| 100 | } |
| 101 | |
| 102 | AddrManImpl::AddrManImpl(std::vector<bool>&& asmap, bool deterministic, int32_t consistency_check_ratio) |
| 103 | : insecure_rand{deterministic} |