From ad0b5505bab3f73944c2a2b6b00a6695c21a1844 Mon Sep 17 00:00:00 2001 From: sukhman Date: Wed, 2 Jul 2025 13:11:34 +0530 Subject: [PATCH] make limit configurable in push_identify_to_peers --- libp2p/identity/identify_push/identify_push.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libp2p/identity/identify_push/identify_push.py b/libp2p/identity/identify_push/identify_push.py index 71656c27..5a71cc38 100644 --- a/libp2p/identity/identify_push/identify_push.py +++ b/libp2p/identity/identify_push/identify_push.py @@ -41,7 +41,6 @@ ID_PUSH = TProtocol("/ipfs/id/push/1.0.0") PROTOCOL_VERSION = "ipfs/0.1.0" AGENT_VERSION = get_agent_version() CONCURRENCY_LIMIT = 10 -LIMIT = trio.Semaphore(CONCURRENCY_LIMIT) def identify_push_handler_for(host: IHost) -> StreamHandlerFn: @@ -134,7 +133,10 @@ async def _update_peerstore_from_identify( async def push_identify_to_peer( - host: IHost, peer_id: ID, observed_multiaddr: Multiaddr | None = None + host: IHost, + peer_id: ID, + observed_multiaddr: Multiaddr | None = None, + limit=trio.Semaphore(CONCURRENCY_LIMIT), ) -> bool: """ Push an identify message to a specific peer. @@ -148,7 +150,7 @@ async def push_identify_to_peer( True if the push was successful, False otherwise. """ - async with LIMIT: + async with limit: try: # Create a new stream to the peer using the identify/push protocol stream = await host.new_stream(peer_id, [ID_PUSH])