Trait subspace_networking::KnownPeersRegistry

source ·
pub trait KnownPeersRegistry: Send + Sync {
    // Required methods
    fn add_known_peer<'life0, 'async_trait>(
        &'life0 mut self,
        peer_id: PeerId,
        addresses: Vec<Multiaddr>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove_known_peer_addresses<'life0, 'async_trait>(
        &'life0 mut self,
        peer_id: PeerId,
        addresses: Vec<Multiaddr>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove_all_known_peer_addresses(&mut self, peer_id: PeerId);
    fn all_known_peers<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Vec<(PeerId, Vec<Multiaddr>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn run<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_unreachable_address(
        &mut self,
        handler: Arc<dyn Fn(&PeerAddressRemovedEvent) + Send + Sync + 'static>,
    ) -> Option<HandlerId>;
}
Expand description

Defines operations with the networking parameters.

Required Methods§

source

fn add_known_peer<'life0, 'async_trait>( &'life0 mut self, peer_id: PeerId, addresses: Vec<Multiaddr>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Registers a peer ID and associated addresses

source

fn remove_known_peer_addresses<'life0, 'async_trait>( &'life0 mut self, peer_id: PeerId, addresses: Vec<Multiaddr>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Unregisters associated addresses for peer ID.

source

fn remove_all_known_peer_addresses(&mut self, peer_id: PeerId)

Unregisters associated addresses for peer ID.

source

fn all_known_peers<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Vec<(PeerId, Vec<Multiaddr>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns all known peers and their addresses without P2P suffix at the end

source

fn run<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Drive async work in the persistence provider

source

fn on_unreachable_address( &mut self, handler: Arc<dyn Fn(&PeerAddressRemovedEvent) + Send + Sync + 'static>, ) -> Option<HandlerId>

Triggers when we removed the peer address from the permanent storage. Returns optional event HandlerId. Option enables stub implementation. One of the usages is to notify Kademlia about the expired(unreachable) address when it check for how long address was unreachable.

Implementors§