mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-27 16:51:34 +00:00
swarm/src/behaviour: Merge inject_* paired methods (#2445)
Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@ -226,6 +226,7 @@ impl NetworkBehaviour for Identify {
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
failed_addresses: Option<&Vec<Multiaddr>>,
|
||||
_other_established: usize,
|
||||
) {
|
||||
let addr = match endpoint {
|
||||
ConnectedPoint::Dialer { address, .. } => address.clone(),
|
||||
@ -254,8 +255,12 @@ impl NetworkBehaviour for Identify {
|
||||
conn: &ConnectionId,
|
||||
_: &ConnectedPoint,
|
||||
_: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
|
||||
remaining_established: usize,
|
||||
) {
|
||||
if let Some(addrs) = self.connected.get_mut(peer_id) {
|
||||
if remaining_established == 0 {
|
||||
self.connected.remove(peer_id);
|
||||
self.pending_push.remove(peer_id);
|
||||
} else if let Some(addrs) = self.connected.get_mut(peer_id) {
|
||||
addrs.remove(conn);
|
||||
}
|
||||
}
|
||||
@ -281,11 +286,6 @@ impl NetworkBehaviour for Identify {
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_disconnected(&mut self, peer_id: &PeerId) {
|
||||
self.connected.remove(peer_id);
|
||||
self.pending_push.remove(peer_id);
|
||||
}
|
||||
|
||||
fn inject_new_listen_addr(&mut self, _id: ListenerId, _addr: &Multiaddr) {
|
||||
if self.config.push_listen_addr_updates {
|
||||
self.pending_push.extend(self.connected.keys());
|
||||
|
Reference in New Issue
Block a user