mirror of
https://github.com/transmission/transmission.git
synced 2026-02-14 23:19:34 +00:00
refactor: shuffle peers before pumping (#8233)
* refactor: shuffle peers before pumping * code review: use small vector
This commit is contained in:
@@ -2511,12 +2511,17 @@ namespace bandwidth_helpers
|
||||
{
|
||||
void pumpAllPeers(tr_peerMgr* mgr)
|
||||
{
|
||||
auto peers = small::vector<tr_peerMsgs*, TrDefaultPeerLimitGlobal>{};
|
||||
for (auto* const tor : mgr->torrents_)
|
||||
{
|
||||
for (auto const& peer : tor->swarm->peers)
|
||||
{
|
||||
peer->pulse();
|
||||
}
|
||||
std::ranges::transform(tor->swarm->peers, std::back_inserter(peers), [](auto const& p) { return p.get(); });
|
||||
}
|
||||
|
||||
thread_local auto urbg = tr_urbg<size_t>{};
|
||||
std::ranges::shuffle(peers, urbg);
|
||||
for (auto const& peer : peers)
|
||||
{
|
||||
peer->pulse();
|
||||
}
|
||||
}
|
||||
} // namespace bandwidth_helpers
|
||||
|
||||
Reference in New Issue
Block a user