Skip to main content

PeerBehavior

Trait PeerBehavior 

Source
pub trait PeerBehavior {
    // Required methods
    fn on_message<'life0, 'life1, 'async_trait>(
        &'life0 self,
        message: Message,
        peer: &'life1 PeerHandle,
    ) -> Pin<Box<dyn Future<Output = Result<Message, PeerError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_kill<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer: &'life1 PeerHandle,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_height<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}

Required Methods§

Source

fn on_message<'life0, 'life1, 'async_trait>( &'life0 self, message: Message, peer: &'life1 PeerHandle, ) -> Pin<Box<dyn Future<Output = Result<Message, PeerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handles what this peer does when it receives a message, and creates this peers response

Source

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

Handles what happens when this peer gets killed (apart from peer process’ being killed)

Source

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

Return current blockchain height

Implementors§