latest.ipv8.dht.discovery

Module Contents

Classes

DHTDiscoveryCommunity

Community for discovering peers that are behind NAT.

class latest.ipv8.dht.discovery.DHTDiscoveryCommunity(settings: latest.ipv8.community.CommunitySettings)

Bases: latest.ipv8.dht.community.DHTCommunity

Community for discovering peers that are behind NAT.

on_ping_request(peer: latest.ipv8.types.Peer, payload: latest.ipv8.dht.payload.PingRequestPayload, data: bytes) None

When a ping comes in and we store it, update its metrics.

on_ping_response(peer: latest.ipv8.types.Peer, payload: latest.ipv8.dht.payload.PingResponsePayload, data: bytes) None

When a ping response comes in and we store it, update its metrics.

find_node_in_dict(public_key_bin: bytes, node_dict: dict[bytes, list[latest.ipv8.dht.routing.Node]]) latest.ipv8.dht.routing.Node | None

Get the Node instance belonging to the public key in the given dictionary.

async store_peer() list[latest.ipv8.dht.routing.Node]

Store ourselves.

async send_store_peer_request(key: bytes, nodes: list[latest.ipv8.dht.routing.Node]) list[latest.ipv8.dht.routing.Node]

Send a request for storage to the given nodes.

async connect_peer(mid: bytes, peer: latest.ipv8.types.Peer | None = None) list[latest.ipv8.dht.routing.Node]

Attempt to connect to a peer with the given mid, at first without a DHT lookup.

async send_connect_peer_request(key: bytes, nodes: list[latest.ipv8.dht.routing.Node]) list[latest.ipv8.dht.routing.Node]

Send a request for connection to the given nodes.

on_store_peer_request(peer: latest.ipv8.types.Peer, payload: latest.ipv8.dht.payload.StorePeerRequestPayload) None

When we receive a request to store a peer, attempt to add it.

on_store_peer_response(peer: latest.ipv8.types.Peer, payload: latest.ipv8.dht.payload.StorePeerResponsePayload) None

When a peer signals storage is complete, pop it from our cache.

on_connect_peer_request(peer: latest.ipv8.types.Peer, payload: latest.ipv8.dht.payload.ConnectPeerRequestPayload) None

When a peer wants to connect to another peer, try to puncture the requested “other” peer.

on_connect_peer_response(peer: latest.ipv8.types.Peer, payload: latest.ipv8.dht.payload.ConnectPeerResponsePayload) None

Handle responses of peers that performed punctures for us.

ping_all() None

Send a ping to all known nodes.