Files
chia-blockchain/chia/cmds/peer.py
Matt HauffandGitHub 40db4635a8 [LABS-245] Enable PEP604 Ruff rules (#20269)
* Enable PEP604 Ruff rules

* Fix harcoded signature in test

* Hack CLVMStreamable test with note to fast follow
2025-11-18 12:34:00 -08:00

50 lines
1.4 KiB
Python

from __future__ import annotations
import click
from chia.cmds.cmd_classes import ChiaCliContext
from chia.cmds.cmds_util import NODE_TYPES
from chia.cmds.peer_funcs import peer_async
@click.command("peer", help="Show, or modify peering connections", no_args_is_help=True)
@click.option(
"-p",
"--rpc-port",
help=(
"Set the port where the farmer, wallet, full node or harvester "
"is hosting the RPC interface. See the rpc_port in config.yaml"
),
type=int,
default=None,
)
@click.option(
"-c", "--connections", help="List connections to the specified service", is_flag=True, type=bool, default=False
)
@click.option("-a", "--add-connection", help="Connect specified Chia service to ip:port", type=str, default="")
@click.option(
"-r", "--remove-connection", help="Remove a Node by the first 8 characters of NodeID", type=str, default=""
)
@click.argument("node_type", type=click.Choice(list(NODE_TYPES.keys())), nargs=1, required=True)
@click.pass_context
def peer_cmd(
ctx: click.Context,
rpc_port: int | None,
connections: bool,
add_connection: str,
remove_connection: str,
node_type: str,
) -> None:
import asyncio
asyncio.run(
peer_async(
node_type,
rpc_port,
ChiaCliContext.set_default(ctx).root_path,
connections,
add_connection,
remove_connection,
)
)