From ca8614ad149d761ea5cc04394d30d15f2da06c48 Mon Sep 17 00:00:00 2001 From: Maksim Kurbatov <94808996+yungwine@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:37:56 +0700 Subject: [PATCH] fix distributing broadcasts in overlay (#18) * fix distributing broadcasts * Update setup.py --- pytoniq/adnl/adnl.py | 6 +++--- pytoniq/adnl/overlay.py | 6 +++--- setup.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pytoniq/adnl/adnl.py b/pytoniq/adnl/adnl.py index 88f90b4..9ab00b7 100644 --- a/pytoniq/adnl/adnl.py +++ b/pytoniq/adnl/adnl.py @@ -404,9 +404,9 @@ async def listen(self): peer = self.peers.get(bytes.fromhex(response['from_short']['id'])) if peer is not None: - received_confirm_seqno = response.get('confirm_seqno', 0) - if received_confirm_seqno > peer.confirm_seqno: - peer.confirm_seqno = received_confirm_seqno + received_seqno = response.get('seqno', 0) + if received_seqno > peer.confirm_seqno: + peer.confirm_seqno = received_seqno message = response.get('message') messages = response.get('messages') diff --git a/pytoniq/adnl/overlay.py b/pytoniq/adnl/overlay.py index 1082226..9468f15 100644 --- a/pytoniq/adnl/overlay.py +++ b/pytoniq/adnl/overlay.py @@ -104,13 +104,13 @@ async def _process_custom_message(self, message: dict, peer: Node): assert data[0]['overlay'] == self.overlay_id, 'Unknown overlay id received' data = data[-1] if data['@type'] == 'overlay.broadcast': - # Force broadcast spreading for the network stability. Can be removed in the future. + # Force broadcast distributing for the network stability. Can be removed in the future. # Note that this is almost takes no time to do and will be done in the background. - asyncio.create_task(self.spread_broadcast(data, ignore_errors=True)) + asyncio.create_task(self.distribute_broadcast(data, ignore_errors=True)) await self._process_custom_message_handler(data, peer) - async def spread_broadcast(self, message: dict, ignore_errors: bool = True): + async def distribute_broadcast(self, message: dict, ignore_errors: bool = True): tasks = [] peers = random.choices(list(self.peers.items()), k=3) # https://github.com/ton-blockchain/ton/blob/e30049930a7372a3c1d28a1e59956af8eb489439/overlay/overlay-broadcast.cpp#L69 for _, peer in peers: diff --git a/setup.py b/setup.py index c0ae207..8429773 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="pytoniq", - version="0.1.31", + version="0.1.32", author="Maksim Kurbatov", author_email="cyrbatoff@gmail.com", description="TON Blockchain SDK",