pub trait KademliaTopology: Topology {
    type ClosestPeersIter: Iterator<Item = PeerId>;
    type GetProvidersIter: Iterator<Item = PeerId>;

    fn add_kad_discovered_address(
        &mut self,
        peer: PeerId,
        addr: Multiaddr,
        connection_ty: KadConnectionType
    ); fn closest_peers(
        &mut self,
        target: &Multihash,
        max: usize
    ) -> Self::ClosestPeersIter; fn add_provider(&mut self, key: Multihash, peer_id: PeerId); fn get_providers(&mut self, key: &Multihash) -> Self::GetProvidersIter; }
Expand description

Trait allowing retreival of information necessary for the Kadmelia system to work.

Required Associated Types

Iterator returned by closest_peers.

Iterator returned by get_providers.

Required Methods

Adds an address discovered through Kademlia to the topology.

Note: Keep in mind that peer can be the local peer.

Returns the known peers closest by XOR distance to the target.

The max parameter is the maximum number of results that we are going to use. If more than max elements are returned, they will be ignored.

Note: The results should include the local node.

Registers the given peer as provider of the resource with the given ID.

Note: There is no remove_provider method. Implementations must include a time-to-live system so that entries disappear after a while.

Returns the list of providers that have been registered with add_provider.

If the local node is a provider for key, our local peer ID should also be returned.

Implementations on Foreign Types

Implementors