Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
Periodically sample 5 peers for popular torrents
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Apr 24, 2024
1 parent 5f71463 commit 8e3ea79
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tribler/core/content_discovery/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 8e3ea79

Please sign in to comment.