| 191 | } |
| 192 | |
| 193 | void CAddrMan::Good_(const CService& addr, int64_t nTime) |
| 194 | { |
| 195 | int nId; |
| 196 | CAddrInfo* pinfo = Find(addr, &nId); |
| 197 | |
| 198 | // if not found, bail out |
| 199 | if (!pinfo) |
| 200 | return; |
| 201 | |
| 202 | CAddrInfo& info = *pinfo; |
| 203 | |
| 204 | // check whether we are talking about the exact same CService (including same port) |
| 205 | if (info != addr) |
| 206 | return; |
| 207 | |
| 208 | // update info |
| 209 | info.nLastSuccess = nTime; |
| 210 | info.nLastTry = nTime; |
| 211 | info.nAttempts = 0; |
| 212 | // nTime is not updated here, to avoid leaking information about |
| 213 | // currently-connected peers. |
| 214 | |
| 215 | // if it is already in the tried set, don't do anything else |
| 216 | if (info.fInTried) |
| 217 | return; |
| 218 | |
| 219 | // find a bucket it is in now |
| 220 | int nRnd = GetRandInt(ADDRMAN_NEW_BUCKET_COUNT); |
| 221 | int nUBucket = -1; |
| 222 | for (unsigned int n = 0; n < ADDRMAN_NEW_BUCKET_COUNT; n++) { |
| 223 | int nB = (n + nRnd) % ADDRMAN_NEW_BUCKET_COUNT; |
| 224 | int nBpos = info.GetBucketPosition(nKey, true, nB); |
| 225 | if (vvNew[nB][nBpos] == nId) { |
| 226 | nUBucket = nB; |
| 227 | break; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | // if no bucket is found, something bad happened; |
| 232 | // TODO: maybe re-add the node, but for now, just bail out |
| 233 | if (nUBucket == -1) |
| 234 | return; |
| 235 | |
| 236 | LogPrint("addrman", "Moving %s to tried\n", addr.ToString()); |
| 237 | |
| 238 | // move nId to the tried tables |
| 239 | MakeTried(info, nId); |
| 240 | } |
| 241 | |
| 242 | bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty) |
| 243 | { |
nothing calls this directly
no test coverage detected