Trait CommunicationService

Source
pub trait CommunicationService: Send + Sync {
    type Message: Clone;

    // Required methods
    fn prepare_block_request(start: u32, end: u32) -> Self::Message;
    fn send<'life0, 'async_trait>(
        &'life0 self,
        peer_ip: SocketAddr,
        message: Self::Message,
    ) -> Pin<Box<dyn Future<Output = Option<Receiver<Result<()>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn ban_peer(&self, peer_ip: SocketAddr);
}
Expand description

Abstract communication service.

Implemented by Gateway and Client.

Required Associated Types§

Source

type Message: Clone

The message type used by this communication service.

Required Methods§

Source

fn prepare_block_request(start: u32, end: u32) -> Self::Message

Generates the service-specific message for a block request.

Source

fn send<'life0, 'async_trait>( &'life0 self, peer_ip: SocketAddr, message: Self::Message, ) -> Pin<Box<dyn Future<Output = Option<Receiver<Result<()>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends the given message to specified peer.

This function returns as soon as the message is queued to be sent, without waiting for the actual delivery; instead, the caller is provided with a oneshot::Receiver which can be used to determine when and whether the message has been delivered. If no peer with the given IP exists, this function returns None.

Source

fn ban_peer(&self, peer_ip: SocketAddr)

Mark a peer to be removed and (temporarily) banned.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§