[][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]

Deprecated:

this function is now equivalent to new() and will be removed in the future

Creates a Kademlia.

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

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

Adds a known address for the given PeerId. We are connected to this address.

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

Adds a known address for the given PeerId. We are not connected or don't know whether we are connected to this address.

pub fn kbuckets_entries(&self) -> impl Iterator<Item = &PeerId>[src]

Returns an iterator to all the peer IDs in the bucket, without the pending nodes.

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, target: 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_new_listen_addr(&mut self, _addr: &Multiaddr)[src]

Indicates to the behaviour that we have started listening on a new multiaddr.

fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)[src]

Indicates to the behaviour that a new multiaddr we were listening on has expired, which means that we are no longer listening in it. Read more

fn inject_new_external_addr(&mut self, _addr: &Multiaddr)[src]

Indicates to the behaviour that we have discovered a new external address for us.

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 = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.

impl<T> Same for T

type Output = T

Should always be Self

impl<T> Erased for T