From 3a56de7fc318a45a7096cd318e2f2d7f8124ce24 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 18 Aug 2014 16:50:39 -0400 Subject: [PATCH] addrman: Do not propagate obviously poor addresses onto the network --- src/addrman.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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); } }