[][src]Struct libp2p_kad::Kademlia

pub struct Kademlia<TSubstream> { /* fields omitted */ }

Network behaviour that handles Kademlia.

Methods

impl<TSubstream> Kademlia<TSubstream>[src]

pub fn new(local_peer_id: PeerId) -> Self[src]

Creates a Kademlia.

pub fn without_init(local_peer_id: PeerId) -> Self[src]

Creates a Kademlia.

Contrary to new, doesn't perform the initialization queries that store our local ID into the DHT.

pub fn add_address(&mut self, peer_id: &PeerId, address: Multiaddr)[src]

Adds a known address for the given PeerId.

impl<TSubstream> Kademlia<TSubstream>[src]

pub fn find_node(&mut self, peer_id: PeerId)[src]

Starts an iterative FIND_NODE request.

This will eventually produce an event containing the nodes of the DHT closest to the requested PeerId.

pub fn get_providers(&mut self, key: Multihash)[src]

Starts an iterative GET_PROVIDERS request.

pub fn add_providing(&mut self, key: PeerId)[src]

Register the local node as the provider for the given key.

This will periodically send ADD_PROVIDER messages to the nodes closest to the key. When someone performs a GET_PROVIDERS iterative request on the DHT, our local node will be returned as part of the results.

The actual meaning of providing the value of a key is not defined, and is specific to the value whose key is the hash.

pub fn remove_providing(&mut self, key: &Multihash)[src]

Cancels a registration done with add_providing.

There doesn't exist any "remove provider" message to broadcast on the network, therefore we will still be registered as a provider in the DHT for as long as the timeout doesn't expire.

Trait Implementations

impl<TSubstream> NetworkBehaviour for Kademlia<TSubstream> where
    TSubstream: AsyncRead + AsyncWrite
[src]

type ProtocolsHandler = KademliaHandler<TSubstream, QueryId>

Handler for all the protocols the network supports.

type OutEvent = KademliaOut

Event generated by the swarm.

fn inject_dial_failure(
    &mut self,
    _peer_id: Option<&PeerId>,
    _addr: &Multiaddr,
    _error: &dyn Error
)
[src]

Indicates to the behaviour that we tried to reach a node, but failed.

Auto Trait Implementations

impl<TSubstream> Send for Kademlia<TSubstream> where
    TSubstream: Send

impl<TSubstream> Sync for Kademlia<TSubstream> where
    TSubstream: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self

impl<T> Erased for T