Network

Trait Network 

Source
pub trait Network:
    Send
    + Sync
    + 'static {
    // Required methods
    fn broadcast<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg: &'life1 Message,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn flood_request<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg_inv: &'life1 Inv,
        ttl_as_sec: Option<u64>,
        hops_limit: u16,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn send_to_peer<'life0, 'async_trait>(
        &'life0 self,
        msg: Message,
        peer_addr: SocketAddr,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn send_to_alive_peers<'life0, 'async_trait>(
        &'life0 self,
        msg: Message,
        amount: usize,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_route<'life0, 'async_trait>(
        &'life0 mut self,
        msg_type: u8,
        queue: AsyncQueue<Message>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_filter<'life0, 'async_trait>(
        &'life0 mut self,
        msg_type: u8,
        filter: BoxedFilter,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_info(&self) -> Result<String>;
    fn public_addr(&self) -> &SocketAddr;
    fn alive_nodes_count<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn wait_for_alive_nodes<'life0, 'async_trait>(
        &'life0 self,
        amount: usize,
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}

Required Methods§

Source

fn broadcast<'life0, 'life1, 'async_trait>( &'life0 self, msg: &'life1 Message, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Broadcasts a fire-and-forget message.

Source

fn flood_request<'life0, 'life1, 'async_trait>( &'life0 self, msg_inv: &'life1 Inv, ttl_as_sec: Option<u64>, hops_limit: u16, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Broadcasts a request message

Source

fn send_to_peer<'life0, 'async_trait>( &'life0 self, msg: Message, peer_addr: SocketAddr, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends a message to a specified peer.

Source

fn send_to_alive_peers<'life0, 'async_trait>( &'life0 self, msg: Message, amount: usize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends to random set of alive peers.

Source

fn add_route<'life0, 'async_trait>( &'life0 mut self, msg_type: u8, queue: AsyncQueue<Message>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Routes any message of the specified type to this queue.

Source

fn add_filter<'life0, 'async_trait>( &'life0 mut self, msg_type: u8, filter: BoxedFilter, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Moves a filter of a specified topic to Network.

Source

fn get_info(&self) -> Result<String>

Retrieves information about the network.

Source

fn public_addr(&self) -> &SocketAddr

Returns public address in Kadcast

Source

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

Retrieves number of alive nodes

Provided Methods§

Source

fn wait_for_alive_nodes<'life0, 'async_trait>( &'life0 self, amount: usize, timeout: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§

Source§

impl<const N: usize> Network for Kadcast<N>