From 8e3ea794513805c2e4f7521623aaf44d1eb4128c Mon Sep 17 00:00:00 2001 From: Quinten Stokkink Date: Wed, 24 Apr 2024 14:32:33 +0200 Subject: [PATCH] Periodically sample 5 peers for popular torrents --- src/tribler/core/content_discovery/community.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tribler/core/content_discovery/community.py b/src/tribler/core/content_discovery/community.py index de6b2172da..3d892bb2c6 100644 --- a/src/tribler/core/content_discovery/community.py +++ b/src/tribler/core/content_discovery/community.py @@ -132,10 +132,14 @@ def gossip_random_torrents_health(self): """ Gossip random torrent health information to another peer. """ - if not self.get_peers() or not self.composition.torrent_checker: + peers = self.get_peers() + if not peers or not self.composition.torrent_checker: return - self.ez_send(random.choice(self.get_peers()), TorrentsHealthPayload.create(self.get_random_torrents(), {})) + self.ez_send(random.choice(peers), TorrentsHealthPayload.create(self.get_random_torrents(), {})) + + for p in random.sample(peers, min(len(peers), 5)): + self.ez_send(p, PopularTorrentsRequest()) @lazy_wrapper(TorrentsHealthPayload) async def on_torrents_health(self, peer, payload: TorrentsHealthPayload):