Skip to content

Commit

Permalink
add broadcasts garbage collection
Browse files Browse the repository at this point in the history
  • Loading branch information
yungwine committed Mar 7, 2024
1 parent 90efa09 commit 217343c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pytoniq/adnl/overlay/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ async def _process_custom_message(self, message: dict, peer: Node):
if data['@type'] == 'overlay.broadcast':
from .broadcast import BroadcastSimple
await BroadcastSimple(self, data).run()
self.bcast_gc()
return
if data['@type'] == 'overlay.broadcastFec':
from .fec_broadcast import BroadcastFecPart
await BroadcastFecPart(self, data).run()
self.bcast_gc()
return

await self._process_custom_message_handler(data, peer)
Expand Down Expand Up @@ -238,7 +240,7 @@ async def get_capabilities(self, peer: OverlayNode):
return await self.send_query_message(tl_schema_name='tonNode.getCapabilities', data={}, peer=peer)

def bcast_gc(self):
i = iter(self.broadcasts)
i = iter(self.broadcasts.copy())
while len(self.broadcasts) > 1000:
brcst = next(i)
del self.broadcasts[brcst]
Expand Down

0 comments on commit 217343c

Please sign in to comment.