mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 18:11:22 +00:00
swarm/: Provide additional default impls on NetworkBehaviour
(#2150)
Not all implementations of `NetworkBehaviour` need all callbacks. We've have been adding new callbacks with default implementations for a while now. There is no reason the initial ones cannot also be defaulted, thus making it easier create new implementations. Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@ -605,7 +605,7 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
}
|
||||
this.behaviour.inject_new_listen_addr(listener_id, &listen_addr);
|
||||
return Poll::Ready(SwarmEvent::NewListenAddr {
|
||||
listener_id,
|
||||
listener_id,
|
||||
address: listen_addr
|
||||
});
|
||||
}
|
||||
@ -1156,21 +1156,15 @@ impl NetworkBehaviour for DummyBehaviour {
|
||||
protocols_handler::DummyProtocolsHandler::default()
|
||||
}
|
||||
|
||||
fn addresses_of_peer(&mut self, _: &PeerId) -> Vec<Multiaddr> {
|
||||
Vec::new()
|
||||
fn inject_event(
|
||||
&mut self,
|
||||
_: PeerId,
|
||||
_: ConnectionId,
|
||||
event: <Self::ProtocolsHandler as ProtocolsHandler>::OutEvent
|
||||
) {
|
||||
void::unreachable(event)
|
||||
}
|
||||
|
||||
fn inject_connected(&mut self, _: &PeerId) {}
|
||||
|
||||
fn inject_connection_established(&mut self, _: &PeerId, _: &ConnectionId, _: &ConnectedPoint) {}
|
||||
|
||||
fn inject_disconnected(&mut self, _: &PeerId) {}
|
||||
|
||||
fn inject_connection_closed(&mut self, _: &PeerId, _: &ConnectionId, _: &ConnectedPoint) {}
|
||||
|
||||
fn inject_event(&mut self, _: PeerId, _: ConnectionId,
|
||||
_: <Self::ProtocolsHandler as ProtocolsHandler>::OutEvent) {}
|
||||
|
||||
fn poll(&mut self, _: &mut Context<'_>, _: &mut impl PollParameters) ->
|
||||
Poll<NetworkBehaviourAction<<Self::ProtocolsHandler as
|
||||
ProtocolsHandler>::InEvent, Self::OutEvent>>
|
||||
|
Reference in New Issue
Block a user