mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 16:10:57 +00:00
Fix typo in connection timeout comment and improve identify example output formatting
This commit is contained in:
@ -156,7 +156,7 @@ async def example_production_ready_config() -> None:
|
|||||||
# Production-ready connection configuration
|
# Production-ready connection configuration
|
||||||
connection_config = ConnectionConfig(
|
connection_config = ConnectionConfig(
|
||||||
max_connections_per_peer=3, # Balance between performance and resource usage
|
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
|
load_balancing_strategy="round_robin", # Simple, predictable strategy
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -95,22 +95,36 @@ async def run(port: int, destination: str, use_varint_format: bool = True) -> No
|
|||||||
# Get all available addresses with peer ID
|
# Get all available addresses with peer ID
|
||||||
all_addrs = host_a.get_addrs()
|
all_addrs = host_a.get_addrs()
|
||||||
|
|
||||||
format_name = "length-prefixed" if use_varint_format else "raw protobuf"
|
if use_varint_format:
|
||||||
format_flag = "--raw-format" if not use_varint_format else ""
|
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).")
|
# Use optimal address for the client command
|
||||||
print("Listener ready, listening on:\n")
|
optimal_addr = get_optimal_binding_address(port)
|
||||||
for addr in all_addrs:
|
optimal_addr_with_peer = f"{optimal_addr}/p2p/{host_a.get_id().to_string()}"
|
||||||
print(f"{addr}")
|
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
|
# Use optimal address for the client command
|
||||||
optimal_addr = get_optimal_binding_address(port)
|
optimal_addr = get_optimal_binding_address(port)
|
||||||
optimal_addr_with_peer = f"{optimal_addr}/p2p/{host_a.get_id().to_string()}"
|
optimal_addr_with_peer = f"{optimal_addr}/p2p/{host_a.get_id().to_string()}"
|
||||||
print(
|
print(
|
||||||
f"\nRun this from the same folder in another console:\n\n"
|
f"\nRun this from the same folder in another console:\n\n"
|
||||||
f"identify-demo {format_flag} -d {optimal_addr_with_peer}\n"
|
f"identify-demo -d {optimal_addr_with_peer}\n"
|
||||||
)
|
)
|
||||||
print("Waiting for incoming identify request...")
|
print("Waiting for incoming identify request...")
|
||||||
|
|
||||||
# Add a custom handler to show connection events
|
# Add a custom handler to show connection events
|
||||||
async def custom_identify_handler(stream):
|
async def custom_identify_handler(stream):
|
||||||
|
|||||||
Reference in New Issue
Block a user