Trait swarm_nl::core::EventHandler
source · pub trait EventHandler {
Show 26 methods
// Required methods
fn rpc_incoming_message_handled(
&mut self,
data: Vec<Vec<u8>>
) -> Vec<Vec<u8>>;
fn gossipsub_incoming_message_handled(
&mut self,
_source: PeerId,
_data: Vec<String>
);
// Provided methods
fn new_listen_addr(
&mut self,
_local_peer_id: PeerId,
_listener_id: ListenerId,
_addr: Multiaddr
) { ... }
fn routing_table_updated(&mut self, _peer_id: PeerId) { ... }
fn connection_established(
&mut self,
_peer_id: PeerId,
_connection_id: ConnectionId,
_endpoint: &ConnectedPoint,
_num_established: NonZeroU32,
_established_in: Duration
) { ... }
fn connection_closed(
&mut self,
_peer_id: PeerId,
_connection_id: ConnectionId,
_endpoint: &ConnectedPoint,
_num_established: u32,
_cause: Option<ConnectionError>
) { ... }
fn expired_listen_addr(
&mut self,
_listener_id: ListenerId,
_address: Multiaddr
) { ... }
fn listener_closed(
&mut self,
_listener_id: ListenerId,
_addresses: Vec<Multiaddr>
) { ... }
fn listener_error(&mut self, _listener_id: ListenerId) { ... }
fn dialing(
&mut self,
_peer_id: Option<PeerId>,
_connection_id: ConnectionId
) { ... }
fn new_external_addr_candidate(&mut self, _address: Multiaddr) { ... }
fn external_addr_confirmed(&mut self, _address: Multiaddr) { ... }
fn external_addr_expired(&mut self, _address: Multiaddr) { ... }
fn incoming_connection(
&mut self,
_connection_id: ConnectionId,
_local_addr: Multiaddr,
_send_back_addr: Multiaddr
) { ... }
fn incoming_connection_error(
&mut self,
_connection_id: ConnectionId,
_local_addr: Multiaddr,
_send_back_addr: Multiaddr
) { ... }
fn outgoing_connection_error(
&mut self,
_connection_id: ConnectionId,
_peer_id: Option<PeerId>
) { ... }
fn outbound_ping_success(&mut self, _peer_id: PeerId, _duration: Duration) { ... }
fn outbound_ping_error(&mut self, _peer_id: PeerId, _err_type: Failure) { ... }
fn identify_info_recieved(&mut self, _peer_id: PeerId, _info: Info) { ... }
fn kademlia_put_record_success(&mut self, _key: Vec<u8>) { ... }
fn kademlia_put_record_error(&mut self) { ... }
fn kademlia_start_providing_success(&mut self, _key: Vec<u8>) { ... }
fn kademlia_start_providing_error(&mut self) { ... }
fn gossipsub_unsubscribe_message_recieved(
&mut self,
_peer_id: PeerId,
_topic: String
) { ... }
fn gossipsub_subscribe_message_recieved(
&mut self,
_peer_id: PeerId,
_topic: String
) { ... }
fn gossipsub_incoming_message_filtered(
&mut self,
_propagation_source: PeerId,
_message_id: MessageId,
_source: Option<PeerId>,
_topic: String,
_data: Vec<String>
) -> bool { ... }
}
Expand description
The high level trait that provides an interface for the application layer to respond to network events.
Required Methods§
sourcefn rpc_incoming_message_handled(&mut self, data: Vec<Vec<u8>>) -> Vec<Vec<u8>>
fn rpc_incoming_message_handled(&mut self, data: Vec<Vec<u8>>) -> Vec<Vec<u8>>
Event that announces the arrival of an RPC message.
sourcefn gossipsub_incoming_message_handled(
&mut self,
_source: PeerId,
_data: Vec<String>
)
fn gossipsub_incoming_message_handled( &mut self, _source: PeerId, _data: Vec<String> )
Event that announces the arrival of a gossip message.
Provided Methods§
sourcefn new_listen_addr(
&mut self,
_local_peer_id: PeerId,
_listener_id: ListenerId,
_addr: Multiaddr
)
fn new_listen_addr( &mut self, _local_peer_id: PeerId, _listener_id: ListenerId, _addr: Multiaddr )
Event that informs the application that we have started listening on a new multiaddr.
sourcefn routing_table_updated(&mut self, _peer_id: PeerId)
fn routing_table_updated(&mut self, _peer_id: PeerId)
Event that informs the application that a new peer (with its location details) has just been added to the routing table.
sourcefn connection_established(
&mut self,
_peer_id: PeerId,
_connection_id: ConnectionId,
_endpoint: &ConnectedPoint,
_num_established: NonZeroU32,
_established_in: Duration
)
fn connection_established( &mut self, _peer_id: PeerId, _connection_id: ConnectionId, _endpoint: &ConnectedPoint, _num_established: NonZeroU32, _established_in: Duration )
Event that informs the application about a newly established connection to a peer.
sourcefn connection_closed(
&mut self,
_peer_id: PeerId,
_connection_id: ConnectionId,
_endpoint: &ConnectedPoint,
_num_established: u32,
_cause: Option<ConnectionError>
)
fn connection_closed( &mut self, _peer_id: PeerId, _connection_id: ConnectionId, _endpoint: &ConnectedPoint, _num_established: u32, _cause: Option<ConnectionError> )
Event that informs the application about a closed connection to a peer.
sourcefn expired_listen_addr(&mut self, _listener_id: ListenerId, _address: Multiaddr)
fn expired_listen_addr(&mut self, _listener_id: ListenerId, _address: Multiaddr)
Event that announces expired listen address.
sourcefn listener_closed(
&mut self,
_listener_id: ListenerId,
_addresses: Vec<Multiaddr>
)
fn listener_closed( &mut self, _listener_id: ListenerId, _addresses: Vec<Multiaddr> )
Event that announces a closed listener.
sourcefn listener_error(&mut self, _listener_id: ListenerId)
fn listener_error(&mut self, _listener_id: ListenerId)
Event that announces a listener error.
sourcefn dialing(&mut self, _peer_id: Option<PeerId>, _connection_id: ConnectionId)
fn dialing(&mut self, _peer_id: Option<PeerId>, _connection_id: ConnectionId)
Event that announces a dialing attempt.
sourcefn new_external_addr_candidate(&mut self, _address: Multiaddr)
fn new_external_addr_candidate(&mut self, _address: Multiaddr)
Event that announces a new external address candidate.
sourcefn external_addr_confirmed(&mut self, _address: Multiaddr)
fn external_addr_confirmed(&mut self, _address: Multiaddr)
Event that announces a confirmed external address.
sourcefn external_addr_expired(&mut self, _address: Multiaddr)
fn external_addr_expired(&mut self, _address: Multiaddr)
Event that announces an expired external address.
sourcefn incoming_connection(
&mut self,
_connection_id: ConnectionId,
_local_addr: Multiaddr,
_send_back_addr: Multiaddr
)
fn incoming_connection( &mut self, _connection_id: ConnectionId, _local_addr: Multiaddr, _send_back_addr: Multiaddr )
Event that announces new connection arriving on a listener and in the process of protocol negotiation.
sourcefn incoming_connection_error(
&mut self,
_connection_id: ConnectionId,
_local_addr: Multiaddr,
_send_back_addr: Multiaddr
)
fn incoming_connection_error( &mut self, _connection_id: ConnectionId, _local_addr: Multiaddr, _send_back_addr: Multiaddr )
Event that announces an error happening on an inbound connection during its initial handshake.
sourcefn outgoing_connection_error(
&mut self,
_connection_id: ConnectionId,
_peer_id: Option<PeerId>
)
fn outgoing_connection_error( &mut self, _connection_id: ConnectionId, _peer_id: Option<PeerId> )
Event that announces an error happening on an outbound connection during its initial handshake.
sourcefn outbound_ping_success(&mut self, _peer_id: PeerId, _duration: Duration)
fn outbound_ping_success(&mut self, _peer_id: PeerId, _duration: Duration)
Event that announces the arrival of a pong message from a peer. The duration it took for a round trip is also returned.
sourcefn outbound_ping_error(&mut self, _peer_id: PeerId, _err_type: Failure)
fn outbound_ping_error(&mut self, _peer_id: PeerId, _err_type: Failure)
Event that announces a Ping
error.
sourcefn identify_info_recieved(&mut self, _peer_id: PeerId, _info: Info)
fn identify_info_recieved(&mut self, _peer_id: PeerId, _info: Info)
Event that announces the arrival of a PeerInfo
via the Identify
protocol.
sourcefn kademlia_put_record_success(&mut self, _key: Vec<u8>)
fn kademlia_put_record_success(&mut self, _key: Vec<u8>)
Event that announces the successful write of a record to the DHT.
sourcefn kademlia_put_record_error(&mut self)
fn kademlia_put_record_error(&mut self)
Event that announces the failure of a node to save a record.
sourcefn kademlia_start_providing_success(&mut self, _key: Vec<u8>)
fn kademlia_start_providing_success(&mut self, _key: Vec<u8>)
Event that announces a node as a provider of a record in the DHT.
sourcefn kademlia_start_providing_error(&mut self)
fn kademlia_start_providing_error(&mut self)
Event that announces the failure of a node to become a provider of a record in the DHT.
sourcefn gossipsub_unsubscribe_message_recieved(
&mut self,
_peer_id: PeerId,
_topic: String
)
fn gossipsub_unsubscribe_message_recieved( &mut self, _peer_id: PeerId, _topic: String )
Event that announces that a peer has just left a network.
sourcefn gossipsub_subscribe_message_recieved(
&mut self,
_peer_id: PeerId,
_topic: String
)
fn gossipsub_subscribe_message_recieved( &mut self, _peer_id: PeerId, _topic: String )
Event that announces that a peer has just joined a network.
sourcefn gossipsub_incoming_message_filtered(
&mut self,
_propagation_source: PeerId,
_message_id: MessageId,
_source: Option<PeerId>,
_topic: String,
_data: Vec<String>
) -> bool
fn gossipsub_incoming_message_filtered( &mut self, _propagation_source: PeerId, _message_id: MessageId, _source: Option<PeerId>, _topic: String, _data: Vec<String> ) -> bool
Event that announces the beginning of the filtering and authentication of the incoming gossip message. It returns a boolean to specify whether the massage should be dropped or should reach the application. All incoming messages are allowed in by default.
Implementors§
impl EventHandler for DefaultHandler
Implement EventHandler
for DefaultHandler