From 3f30ed4437c3d53d613913b52121e7f0a61a360b Mon Sep 17 00:00:00 2001 From: yashksaini-coder Date: Thu, 18 Sep 2025 21:36:25 +0530 Subject: [PATCH] Fix typo in connection timeout comment and improve identify example output formatting --- .../multiple_connections_example.py | 2 +- examples/identify/identify.py | 42 ++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/examples/doc-examples/multiple_connections_example.py b/examples/doc-examples/multiple_connections_example.py index 20a7fd86..ebc8119f 100644 --- a/examples/doc-examples/multiple_connections_example.py +++ b/examples/doc-examples/multiple_connections_example.py @@ -156,7 +156,7 @@ async def example_production_ready_config() -> None: # Production-ready connection configuration connection_config = ConnectionConfig( max_connections_per_peer=3, # Balance between performance and resource usage - connection_timeout=30.0, # Reasonable timeout + connection_timeout=30.0, # Reasonable timeouta load_balancing_strategy="round_robin", # Simple, predictable strategy ) diff --git a/examples/identify/identify.py b/examples/identify/identify.py index 01b270f0..1e3eb62d 100644 --- a/examples/identify/identify.py +++ b/examples/identify/identify.py @@ -95,22 +95,36 @@ async def run(port: int, destination: str, use_varint_format: bool = True) -> No # Get all available addresses with peer ID all_addrs = host_a.get_addrs() - format_name = "length-prefixed" if use_varint_format else "raw protobuf" - format_flag = "--raw-format" if not use_varint_format else "" + if use_varint_format: + format_name = "length-prefixed" + print(f"First host listening (using {format_name} format).") + print("Listener ready, listening on:\n") + for addr in all_addrs: + print(f"{addr}") - print(f"First host listening (using {format_name} format).") - print("Listener ready, listening on:\n") - for addr in all_addrs: - print(f"{addr}") + # Use optimal address for the client command + optimal_addr = get_optimal_binding_address(port) + optimal_addr_with_peer = f"{optimal_addr}/p2p/{host_a.get_id().to_string()}" + print( + f"\nRun this from the same folder in another console:\n\n" + f"identify-demo -d {optimal_addr_with_peer}\n" + ) + print("Waiting for incoming identify request...") + else: + format_name = "raw protobuf" + print(f"First host listening (using {format_name} format).") + print("Listener ready, listening on:\n") + for addr in all_addrs: + print(f"{addr}") - # Use optimal address for the client command - optimal_addr = get_optimal_binding_address(port) - optimal_addr_with_peer = f"{optimal_addr}/p2p/{host_a.get_id().to_string()}" - print( - f"\nRun this from the same folder in another console:\n\n" - f"identify-demo {format_flag} -d {optimal_addr_with_peer}\n" - ) - print("Waiting for incoming identify request...") + # Use optimal address for the client command + optimal_addr = get_optimal_binding_address(port) + optimal_addr_with_peer = f"{optimal_addr}/p2p/{host_a.get_id().to_string()}" + print( + f"\nRun this from the same folder in another console:\n\n" + f"identify-demo -d {optimal_addr_with_peer}\n" + ) + print("Waiting for incoming identify request...") # Add a custom handler to show connection events async def custom_identify_handler(stream):