| 51 | } |
| 52 | |
| 53 | double CAddrInfo::GetChance(int64_t nNow) const |
| 54 | { |
| 55 | double fChance = 1.0; |
| 56 | int64_t nSinceLastTry = std::max<int64_t>(nNow - nLastTry, 0); |
| 57 | |
| 58 | // deprioritize very recent attempts away |
| 59 | if (nSinceLastTry < 60 * 10) |
| 60 | fChance *= 0.01; |
| 61 | |
| 62 | // deprioritize 66% after each failed attempt, but at most 1/28th to avoid the search taking forever or overly penalizing outages. |
| 63 | fChance *= pow(0.66, std::min(nAttempts, 8)); |
| 64 | |
| 65 | return fChance; |
| 66 | } |
| 67 | |
| 68 | CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int* pnId) |
| 69 | { |