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