use std::sample to grab MaxGossipPeers when populating std::unordered_set

pull/1723/head
Jeff Becker 3 years ago
parent a739e7b532
commit 9ad63140f2
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -92,13 +92,10 @@ namespace llarp
},
true);
// limit the number of peers we gossip to
if (gossipTo.size() > MaxGossipPeers)
{
gossipTo.resize(MaxGossipPeers);
}
const std::unordered_set<RouterID> keys{gossipTo.begin(), gossipTo.end()};
std::unordered_set<RouterID> keys;
// grab the keys we want to use
std::sample(
gossipTo.begin(), gossipTo.end(), std::inserter(keys, keys.end()), MaxGossipPeers, CSRNG{});
m_LinkManager->ForEachPeer([&](ILinkSession* peerSession) {
if (not(peerSession && peerSession->IsEstablished()))

Loading…
Cancel
Save