Relay

Trait Relay 

Source
pub trait Relay: Send + Sync {
    // Required methods
    fn broadcast<'life0, 'life1, 'life2, 'async_trait, T>(
        &'life0 self,
        session_id: &'life1 SessionId,
        round: u32,
        message: &'life2 T,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where T: 'async_trait + Serialize + Send + Sync,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn send_direct<'life0, 'life1, 'life2, 'async_trait, T>(
        &'life0 self,
        session_id: &'life1 SessionId,
        round: u32,
        to: PartyId,
        message: &'life2 T,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where T: 'async_trait + Serialize + Send + Sync,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn collect_broadcasts<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        session_id: &'life1 SessionId,
        round: u32,
        count: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
       where T: 'async_trait + DeserializeOwned + Send,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn collect_direct<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        session_id: &'life1 SessionId,
        round: u32,
        my_id: PartyId,
        count: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
       where T: 'async_trait + DeserializeOwned + Send,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Message relay trait for MPC communication

Implementations of this trait handle the transport of messages between MPC protocol participants. The relay is responsible for:

  • Broadcasting messages to all parties
  • Sending direct (point-to-point) messages
  • Collecting and delivering messages by round

Required Methods§

Source

fn broadcast<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, session_id: &'life1 SessionId, round: u32, message: &'life2 T, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Broadcast a message to all parties in the session

§Arguments
  • session_id - Unique session identifier
  • round - Protocol round number
  • message - Message to broadcast (will be serialized)
Source

fn send_direct<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, session_id: &'life1 SessionId, round: u32, to: PartyId, message: &'life2 T, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send a direct message to a specific party

§Arguments
  • session_id - Unique session identifier
  • round - Protocol round number
  • to - Target party ID
  • message - Message to send (will be serialized)
Source

fn collect_broadcasts<'life0, 'life1, 'async_trait, T>( &'life0 self, session_id: &'life1 SessionId, round: u32, count: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Collect broadcast messages from all parties for a round

This method blocks until count messages have been received.

§Arguments
  • session_id - Unique session identifier
  • round - Protocol round number
  • count - Number of messages to collect
Source

fn collect_direct<'life0, 'life1, 'async_trait, T>( &'life0 self, session_id: &'life1 SessionId, round: u32, my_id: PartyId, count: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Collect direct messages sent to this party

This method blocks until count messages have been received.

§Arguments
  • session_id - Unique session identifier
  • round - Protocol round number
  • my_id - This party’s ID
  • count - Number of messages to collect

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§