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§
Required Methods§
Sourcefn prepare_block_request(start: u32, end: u32) -> Self::Message
fn prepare_block_request(start: u32, end: u32) -> Self::Message
Generates the service-specific message for a block request.
Sourcefn 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 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.
Sourcefn ban_peer(&self, peer_ip: SocketAddr)
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.