void Connected_(NetworkAddress addr, DateTimeOffset nTime) { int unused; AddressInfo pinfo = Find(addr, out unused); // if not found, bail out if (pinfo == null) { return; } AddressInfo info = pinfo; // check whether we are talking about the exact same CService (including same port) if (!info.Match(addr)) { return; } // update info var nUpdateInterval = TimeSpan.FromSeconds(20 * 60); if (nTime - info.nTime > nUpdateInterval) { info.nTime = nTime; } }
private void Attempt_(NetworkAddress addr, DateTimeOffset nTime) { #if LOCAL_TESTS AddressInfo pinfo = Find(addr.Endpoint); #else AddressInfo pinfo = Find(addr.Endpoint.Address); #endif // if not found, bail out if (pinfo == null) { return; } AddressInfo info = pinfo; // check whether we are talking about the exact same CService (including same port) if (!info.Match(addr)) { return; } // update info info.LastTry = nTime; info.nAttempts++; }
private void Good_(NetworkAddress addr, DateTimeOffset nTime) { int nId; AddressInfo pinfo = Find(addr, out nId); // if not found, bail out if (pinfo == null) { return; } AddressInfo info = pinfo; // check whether we are talking about the exact same CService (including same port) if (!info.Match(addr)) { return; } // update info info.LastSuccess = nTime; info.LastTry = nTime; info.nAttempts = 0; // nTime is not updated here, to avoid leaking information about // currently-connected peers. // if it is already in the tried set, don't do anything else if (info.fInTried) { return; } // find a bucket it is in now int nRnd = GetRandInt(ADDRMAN_NEW_BUCKET_COUNT); int nUBucket = -1; for (int n = 0; n < ADDRMAN_NEW_BUCKET_COUNT; n++) { int nB = (n + nRnd) % ADDRMAN_NEW_BUCKET_COUNT; int nBpos = info.GetBucketPosition(nKey, true, nB); if (vvNew[nB, nBpos] == nId) { nUBucket = nB; break; } } // if no bucket is found, something bad happened; // TODO: maybe re-add the node, but for now, just bail out if (nUBucket == -1) { return; } // move nId to the tried tables MakeTried(info, nId); }