Trait snarkos_node_tcp::protocols::Disconnect

source ·
pub trait Disconnect: P2P
where Self: Clone + Send + Sync + 'static,
{ // Required method fn handle_disconnect<'life0, 'async_trait>( &'life0 self, peer_addr: SocketAddr, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided method fn enable_disconnect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait { ... } }
Expand description

Can be used to automatically perform some extra actions when the node disconnects from its peer, which is especially practical if the disconnect is triggered automatically, e.g. due to the peer exceeding the allowed number of failures or severing its connection with the node on its own.

Required Methods§

source

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

Any extra actions to be executed during a disconnect; in order to still be able to communicate with the peer in the usual manner (i.e. via Writing), only its SocketAddr (as opposed to the related Connection object) is provided as an argument.

Provided Methods§

source

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

Attaches the behavior specified in Disconnect::handle_disconnect to every occurrence of the node disconnecting from a peer.

Object Safety§

This trait is not object safe.

Implementors§