void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr) #endif { unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100; if (nNodes > ADDRMAN_GETADDR_MAX) nNodes = ADDRMAN_GETADDR_MAX; // gather a list of random nodes, skipping those of low quality for (unsigned int n = 0; n < vRandom.size(); n++) { if (vAddr.size() >= nNodes) break; int nRndPos = GetRandInt(vRandom.size() - n) + n; SwapRandom(n, nRndPos); assert(mapInfo.count(vRandom[n]) == 1); const CAddrInfo& ai = mapInfo[vRandom[n]]; //! Don't send terrible addresses in response to GetAddr requests //#ifdef I2PADDRMAN_EXTENSIONS //! Additional checks, don't send addresses to nodes that cant process them or don't care about them. //! Inclusion of a check for RFC1918() addresses, means any local whitelisted peers that have made //! it into the address manager and are RFC1918 IPs will not be globally shared with peers on the //! Anoncoin network, originally done for software testing, now seems like a good idea to leave it. //! CSlave: There is a logical error in the following conditional string, (!fIpOnly || !ai.IsI2P()) //! always return false and false so the addresses were never shared to I2P peers. Probably the //! fIpOnly check is flawed as it always return true even for I2P only peers. Furthermore I think //! there is no harm to share both IP and I2P address to all peers, hence those conditions are removed. //if( !ai.IsTerrible() && !ai.IsRFC1918() && (!fIpOnly || !ai.IsI2P()) && (!fI2pOnly || ai.IsI2P()) ) if (!ai.IsTerrible() && !ai.IsRFC1918() ) //#else //if(!ai.IsTerrible()) //#endif vAddr.push_back(ai); } }
void CAddrMan::Delete(int nId) { assert(mapInfo.count(nId) != 0); CAddrInfo &info = mapInfo[nId]; assert(!info.fInTried); assert(info.nRefCount == 0); SwapRandom(info.nRandomPos, vRandom.size() - 1); vRandom.pop_back(); mapAddr.erase(info); mapInfo.erase(nId); nNew--; }
void CAddrMan::GetAddr_(std::vector<CAddress> &vAddr) { unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100; if (nNodes > ADDRMAN_GETADDR_MAX) nNodes = ADDRMAN_GETADDR_MAX; // gather a list of random nodes, skipping those of low quality for (unsigned int n = 0; n < vRandom.size(); n++) { if (vAddr.size() >= nNodes) break; int nRndPos = RandomInt(vRandom.size() - n) + n; SwapRandom(n, nRndPos); assert(mapInfo.count(vRandom[n]) == 1); const CAddrInfo &ai = mapInfo[vRandom[n]]; if (!ai.IsTerrible()) vAddr.push_back(ai); } }