mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-21 00:24:37 +03:00
remove unneeded function and use is_trusted_peer
This commit is contained in:
parent
fe5d9c12e0
commit
7cb0344be8
@ -53,7 +53,7 @@ async def print_connections(rpc_client: RpcClient, trusted_peers: Dict[str, Any]
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from chia.server.outbound_message import NodeType
|
from chia.server.outbound_message import NodeType
|
||||||
from chia.util.network import is_trusted_inner
|
from chia.util.network import is_trusted_peer
|
||||||
|
|
||||||
connections = await rpc_client.get_connections()
|
connections = await rpc_client.get_connections()
|
||||||
print("Connections:")
|
print("Connections:")
|
||||||
@ -68,7 +68,7 @@ async def print_connections(rpc_client: RpcClient, trusted_peers: Dict[str, Any]
|
|||||||
# Strip IPv6 brackets
|
# Strip IPv6 brackets
|
||||||
host = host.strip("[]")
|
host = host.strip("[]")
|
||||||
|
|
||||||
trusted: bool = is_trusted_inner(host, con["node_id"], trusted_peers, False)
|
trusted: bool = is_trusted_peer(host, con["node_id"], trusted_peers, False)
|
||||||
# Nodetype length is 9 because INTRODUCER will be deprecated
|
# Nodetype length is 9 because INTRODUCER will be deprecated
|
||||||
if NodeType(con["type"]) is NodeType.FULL_NODE:
|
if NodeType(con["type"]) is NodeType.FULL_NODE:
|
||||||
peak_height = con.get("peak_height", None)
|
peak_height = con.get("peak_height", None)
|
||||||
|
@ -175,17 +175,6 @@ def get_host_addr(host: str, *, prefer_ipv6: bool = False) -> IPAddress:
|
|||||||
raise ValueError(f"failed to resolve {host} into an IP address")
|
raise ValueError(f"failed to resolve {host} into an IP address")
|
||||||
|
|
||||||
|
|
||||||
def is_trusted_inner(peer_host: str, peer_node_id: bytes32, trusted_peers: Dict, testing: bool) -> bool:
|
|
||||||
if trusted_peers is None:
|
|
||||||
return False
|
|
||||||
if not testing and peer_host == "127.0.0.1":
|
|
||||||
return True
|
|
||||||
if peer_node_id.hex() not in trusted_peers:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def select_port(prefer_ipv6: bool, addresses: List[Any]) -> uint16:
|
def select_port(prefer_ipv6: bool, addresses: List[Any]) -> uint16:
|
||||||
selected_port: uint16
|
selected_port: uint16
|
||||||
for address_string, port, *_ in addresses:
|
for address_string, port, *_ in addresses:
|
||||||
|
Loading…
Reference in New Issue
Block a user