MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetAddr_

Method GetAddr_

src/addrman.cpp:446–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444#endif
445
446void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr)
447{
448 unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100;
449 if (nNodes > ADDRMAN_GETADDR_MAX)
450 nNodes = ADDRMAN_GETADDR_MAX;
451
452 // gather a list of random nodes, skipping those of low quality
453 for (unsigned int n = 0; n < vRandom.size(); n++) {
454 if (vAddr.size() >= nNodes)
455 break;
456
457 int nRndPos = GetRandInt(vRandom.size() - n) + n;
458 SwapRandom(n, nRndPos);
459 assert(mapInfo.count(vRandom[n]) == 1);
460
461 const CAddrInfo& ai = mapInfo[vRandom[n]];
462 if (!ai.IsTerrible())
463 vAddr.push_back(ai);
464 }
465}
466
467void CAddrMan::Connected_(const CService& addr, int64_t nTime)
468{

Callers

nothing calls this directly

Calls 5

GetRandIntFunction · 0.85
IsTerribleMethod · 0.80
sizeMethod · 0.45
countMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected