gossip sync: sync with random 20 peers per cycle instead of all peers

This commit is contained in:
lichenblankie 2026-06-05 01:58:32 +00:00
parent 38d594ac50
commit 4b98779122
3 changed files with 15 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import json
import random
import threading
import time
import RNS
@ -6,6 +7,7 @@ import RNS
FORUM_APP = "tinyweb-forum"
SYNC_INTERVAL = 300 # 5 minutes
REQUEST_TIMEOUT = 60
GOSSIP_FANOUT = 20 # random peers to sync per cycle
class _ForumAnnounceHandler:
@ -90,7 +92,11 @@ class ForumSync:
while self._running:
try:
instances = self.fdb.get_synced_instances()
for inst in instances:
# Gossip: sync with random subset for scaling
# If <= GOSSIP_FANOUT peers, sync with all (current behavior)
# If more, sync with random FANOUT per cycle — content spreads epidemically
random.shuffle(instances)
for inst in instances[:GOSSIP_FANOUT]:
if not self._running:
break
try: