fedimint_core::net::peers

Trait IMuxPeerConnections

Source
pub trait IMuxPeerConnections<MuxKey, Msg>{
    // Required methods
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peers: &'life1 [PeerId],
        mux_key: MuxKey,
        msg: Msg,
    ) -> Pin<Box<dyn Future<Output = Cancellable<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn receive<'life0, 'async_trait>(
        &'life0 self,
        mux_key: MuxKey,
    ) -> Pin<Box<dyn Future<Output = Cancellable<(PeerId, Msg)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn ban_peer<'life0, 'async_trait>(
        &'life0 self,
        peer: PeerId,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn into_dyn(self) -> MuxPeerConnections<MuxKey, Msg>
       where Self: Sized + Send + Sync + Unpin + 'static { ... }
}
Expand description

Like IPeerConnections but with an ability to handle multiple destinations (like modules) per each peer-connection.

Notably, unlike IPeerConnections implementations need to be thread-safe, as the primary intended use should support multiple threads using multiplexed channel at the same time.

Required Methods§

Source

fn send<'life0, 'life1, 'async_trait>( &'life0 self, peers: &'life1 [PeerId], mux_key: MuxKey, msg: Msg, ) -> Pin<Box<dyn Future<Output = Cancellable<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a message to a specific destination at specific peer.

Source

fn receive<'life0, 'async_trait>( &'life0 self, mux_key: MuxKey, ) -> Pin<Box<dyn Future<Output = Cancellable<(PeerId, Msg)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Await receipt of a message from any connected peer.

Source

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

Removes a peer connection in case of misbehavior

Provided Methods§

Source

fn into_dyn(self) -> MuxPeerConnections<MuxKey, Msg>
where Self: Sized + Send + Sync + Unpin + 'static,

Converts the struct to a PeerConnection trait object

Implementors§