[−][src]Struct libp2p_kad::Kademlia
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]
Use add_connected_address or add_not_connected_address instead
Adds a known address for the given PeerId
.
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]
&mut self,
peer_id: &PeerId,
address: Multiaddr
)
Adds a known address for the given PeerId
. We are not connected or don't know whether we
are connected to this address.
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]
TSubstream: AsyncRead + AsyncWrite,
type ProtocolsHandler = KademliaHandler<TSubstream, QueryId>
Handler for all the protocols the network supports.
type OutEvent = KademliaOut
Event generated by the swarm.
fn new_handler(&mut self) -> Self::ProtocolsHandler
[src]
fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec<Multiaddr>
[src]
fn inject_connected(&mut self, id: PeerId, endpoint: ConnectedPoint)
[src]
fn inject_dial_failure(
&mut self,
peer_id: Option<&PeerId>,
addr: &Multiaddr,
_: &dyn Error
)
[src]
&mut self,
peer_id: Option<&PeerId>,
addr: &Multiaddr,
_: &dyn Error
)
fn inject_disconnected(&mut self, id: &PeerId, old_endpoint: ConnectedPoint)
[src]
fn inject_replaced(
&mut self,
peer_id: PeerId,
old_endpoint: ConnectedPoint,
new_endpoint: ConnectedPoint
)
[src]
&mut self,
peer_id: PeerId,
old_endpoint: ConnectedPoint,
new_endpoint: ConnectedPoint
)
fn inject_node_event(
&mut self,
source: PeerId,
event: KademliaHandlerEvent<QueryId>
)
[src]
&mut self,
source: PeerId,
event: KademliaHandlerEvent<QueryId>
)
fn poll(
&mut self,
parameters: &mut PollParameters
) -> Async<NetworkBehaviourAction<<Self::ProtocolsHandler as ProtocolsHandler>::InEvent, Self::OutEvent>>
[src]
&mut self,
parameters: &mut PollParameters
) -> Async<NetworkBehaviourAction<<Self::ProtocolsHandler as ProtocolsHandler>::InEvent, Self::OutEvent>>
Auto Trait Implementations
impl<TSubstream> Send for Kademlia<TSubstream> where
TSubstream: Send,
TSubstream: Send,
impl<TSubstream> Sync for Kademlia<TSubstream> where
TSubstream: Sync,
TSubstream: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Same for T
type Output = T
Should always be Self