hopr_transport_network

Trait HoprDbPeersOperations

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<(), DbError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn remove_network_peer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer: &'life1 PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn update_network_peer<'life0, 'async_trait>(
        &'life0 self,
        new_status: PeerStatus,
    ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get_network_peer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer: &'life1 PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<PeerStatus>, DbError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn get_network_peers<'a, 'async_trait>(
        &'a self,
        selector: PeerSelector,
        sort_last_seen_asc: bool,
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = PeerStatus> + Send + 'a>>, DbError>> + Send + 'async_trait>>
       where 'a: 'async_trait,
             Self: 'async_trait;
    fn network_peer_stats<'life0, 'async_trait>(
        &'life0 self,
        quality_threshold: f64,
    ) -> Pin<Box<dyn Future<Output = Result<Stats, DbError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}

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<(), DbError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Adds a peer to the backend.

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

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

Removes the peer from the backend.

Should fail if the given peer id does not exist.

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

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

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

Gets stored information about the peer.

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

fn get_network_peers<'a, 'async_trait>( &'a self, selector: PeerSelector, sort_last_seen_asc: bool, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = PeerStatus> + Send + 'a>>, DbError>> + Send + 'async_trait>>
where 'a: 'async_trait, Self: '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.

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

Returns the statistics on the stored peers.

Implementors§