Skip to content

Commit

Permalink
fix distributing broadcasts in overlay (#18)
Browse files Browse the repository at this point in the history
* fix distributing broadcasts

* Update setup.py
  • Loading branch information
yungwine authored Feb 18, 2024
1 parent 333ce79 commit ca8614a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pytoniq/adnl/adnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions pytoniq/adnl/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pytoniq",
version="0.1.31",
version="0.1.32",
author="Maksim Kurbatov",
author_email="[email protected]",
description="TON Blockchain SDK",
Expand Down

0 comments on commit ca8614a

Please sign in to comment.