Skip to content

Commit

Permalink
fix overlay max peers
Browse files Browse the repository at this point in the history
  • Loading branch information
yungwine committed Mar 6, 2024
1 parent c926f06 commit 90efa09
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pytoniq/adnl/overlay/overlay_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ async def get_more_peers(self):
self.logger.debug(f'Got {len(self.overlay.peers)} first peers')
await asyncio.sleep(10)
continue
if len(self.overlay.peers) >= self.max_peers:
await asyncio.sleep(10)
continue
clients = []
tasks = []
for _, peer in list(self.overlay.peers.items()):
if len(self.overlay.peers) > self.max_peers:
return 0
self.logger.debug(f'getting nodes from peer {peer.get_key_id().hex()}')
if not peer.connected:
self.logger.debug(f'peer {peer.get_key_id().hex()} is already not connected')
Expand Down Expand Up @@ -108,7 +109,7 @@ async def try_connect(client):

tasks = []
for new_client in clients:
if len(self.overlay.peers) > self.max_peers:
if len(self.overlay.peers) + len(tasks) >= self.max_peers:
break
if new_client is not None:
tasks.append(try_connect(new_client))
Expand Down

0 comments on commit 90efa09

Please sign in to comment.