mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-28 01:01:34 +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:
@ -201,13 +201,6 @@ impl NetworkBehaviour for Identify {
|
||||
IdentifyHandler::new(self.config.initial_delay, self.config.interval)
|
||||
}
|
||||
|
||||
fn addresses_of_peer(&mut self, _: &PeerId) -> Vec<Multiaddr> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn inject_connected(&mut self, _: &PeerId) {
|
||||
}
|
||||
|
||||
fn inject_connection_established(&mut self, peer_id: &PeerId, conn: &ConnectionId, endpoint: &ConnectedPoint) {
|
||||
let addr = match endpoint {
|
||||
ConnectedPoint::Dialer { address } => address.clone(),
|
||||
@ -517,8 +510,8 @@ mod tests {
|
||||
pin_mut!(swarm2_fut);
|
||||
|
||||
match future::select(swarm1_fut, swarm2_fut).await.factor_second().0 {
|
||||
future::Either::Left(SwarmEvent::Behaviour(IdentifyEvent::Received {
|
||||
info,
|
||||
future::Either::Left(SwarmEvent::Behaviour(IdentifyEvent::Received {
|
||||
info,
|
||||
..
|
||||
})) => {
|
||||
assert_eq!(info.public_key, pubkey2);
|
||||
@ -528,8 +521,8 @@ mod tests {
|
||||
assert!(info.listen_addrs.is_empty());
|
||||
return;
|
||||
}
|
||||
future::Either::Right(SwarmEvent::Behaviour(IdentifyEvent::Received {
|
||||
info,
|
||||
future::Either::Right(SwarmEvent::Behaviour(IdentifyEvent::Received {
|
||||
info,
|
||||
..
|
||||
})) => {
|
||||
assert_eq!(info.public_key, pubkey1);
|
||||
|
Reference in New Issue
Block a user