diff --git a/src/addrman.cpp b/src/addrman.cpp index 3628af2eab..704766dbf8 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -492,17 +492,23 @@ int CAddrMan::Check_() void CAddrMan::GetAddr_(std::vector &vAddr) { - int nNodes = ADDRMAN_GETADDR_MAX_PCT*vRandom.size()/100; + unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100; if (nNodes > ADDRMAN_GETADDR_MAX) nNodes = ADDRMAN_GETADDR_MAX; - // perform a random shuffle over the first nNodes elements of vRandom (selecting from all) - for (int n = 0; n= nNodes) + break; + int nRndPos = GetRandInt(vRandom.size() - n) + n; SwapRandom(n, nRndPos); assert(mapInfo.count(vRandom[n]) == 1); - vAddr.push_back(mapInfo[vRandom[n]]); + + const CAddrInfo& ai = mapInfo[vRandom[n]]; + if (!ai.IsTerrible()) + vAddr.push_back(ai); } }