hopr_db_api::peers

Trait HoprDbPeersOperations

Source
pub trait HoprDbPeersOperations {
    // Required methods
    fn add_network_peer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer: &'life1 PeerId,
        origin: PeerOrigin,
        mas: Vec<Multiaddr>,
        backoff: f64,
        quality_window: u32,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove_network_peer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer: &'life1 PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update_network_peer<'life0, 'async_trait>(
        &'life0 self,
        new_status: PeerStatus,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_network_peer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer: &'life1 PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<PeerStatus>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_network_peers<'a, 'async_trait>(
        &'a self,
        selector: PeerSelector,
        sort_last_seen_asc: bool,
    ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, PeerStatus>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait;
    fn network_peer_stats<'life0, 'async_trait>(
        &'life0 self,
        quality_threshold: f64,
    ) -> Pin<Box<dyn Future<Output = Result<Stats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}

Required Methods§

Source

fn add_network_peer<'life0, 'life1, 'async_trait>( &'life0 self, peer: &'life1 PeerId, origin: PeerOrigin, mas: Vec<Multiaddr>, backoff: f64, quality_window: u32, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Adds a peer to the backend.

Should fail if the given peer id already exists in the store.

Source

fn remove_network_peer<'life0, 'life1, 'async_trait>( &'life0 self, peer: &'life1 PeerId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes the peer from the backend.

Should fail if the given peer id does not exist.

Source

fn update_network_peer<'life0, 'async_trait>( &'life0 self, new_status: PeerStatus, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates stored information about the peer. Should fail if the peer does not exist in the store.

Source

fn get_network_peer<'life0, 'life1, 'async_trait>( &'life0 self, peer: &'life1 PeerId, ) -> Pin<Box<dyn Future<Output = Result<Option<PeerStatus>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Gets stored information about the peer.

Should return None if such peer does not exist in the store.

Source

fn get_network_peers<'a, 'async_trait>( &'a self, selector: PeerSelector, sort_last_seen_asc: bool, ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, PeerStatus>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Returns a stream of all stored peers, optionally matching the given PeerSelector filter.

The sort_last_seen_asc indicates whether the results should be sorted in ascending or descending order of the last_seen field.

Source

fn network_peer_stats<'life0, 'async_trait>( &'life0 self, quality_threshold: f64, ) -> Pin<Box<dyn Future<Output = Result<Stats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the statistics on the stored peers.

Implementors§