Exemple #1
0
def peer_address_to_message(
        peer_address: PeerAddress) -> squeak_admin_pb2.PeerAddress:
    return squeak_admin_pb2.PeerAddress(
        network=peer_address.network.name,
        host=peer_address.host,
        port=peer_address.port,
    )
Exemple #2
0
def get_peer_by_address(node_stub, host, port):
    get_peer_by_address_response = node_stub.GetPeerByAddress(
        squeak_admin_pb2.GetPeerByAddressRequest(
            peer_address=squeak_admin_pb2.PeerAddress(
                network="IPV4",
                host="fake_host",
                port=1234,
            )))
    return get_peer_by_address_response.squeak_peer
Exemple #3
0
def disconnect_squeak_peer(node_stub, host, port):
    disconnect_peer_response = node_stub.DisconnectPeer(
        squeak_admin_pb2.DisconnectPeerRequest(
            peer_address=squeak_admin_pb2.PeerAddress(
                network="IPV4",
                host=host,
                port=port,
            )))
    return disconnect_peer_response
Exemple #4
0
def get_connected_peer(node_stub, host, port):
    get_connected_peer_response = node_stub.GetConnectedPeer(
        squeak_admin_pb2.GetConnectedPeerRequest(
            peer_address=squeak_admin_pb2.PeerAddress(
                network="IPV4",
                host=host,
                port=port,
            )))
    return get_connected_peer_response.connected_peer
Exemple #5
0
def create_saved_peer(node_stub, name, host, port):
    create_peer_response = node_stub.CreatePeer(
        squeak_admin_pb2.CreatePeerRequest(
            peer_name=name,
            peer_address=squeak_admin_pb2.PeerAddress(
                network="IPV4",
                host=host,
                port=port,
            )))
    return create_peer_response.peer_id
Exemple #6
0
def peer_address_message():
    yield squeak_admin_pb2.PeerAddress(
        network="IPV4",
        host="fake_host",
        port=8765,
    )