From 4914420a379c57a1f2fd5f8da3a1e832a40e0d80 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 22 Mar 2024 23:51:51 -0400 Subject: [PATCH] Don't add as an explicit peer if already connected --- coordinator/src/p2p.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/coordinator/src/p2p.rs b/coordinator/src/p2p.rs index f64834eee..d840fea81 100644 --- a/coordinator/src/p2p.rs +++ b/coordinator/src/p2p.rs @@ -435,18 +435,18 @@ impl LibP2p { Some(SwarmEvent::Dialing { connection_id, .. }) => { log::debug!("dialing to peer in connection ID {}", &connection_id); } - Some(SwarmEvent::ConnectionEstablished { peer_id, connection_id, .. }) => { - if &peer_id == swarm.local_peer_id() { - swarm.close_connection(connection_id); - } else { - log::debug!( - "connection established to peer {} in connection ID {}", - &peer_id, - &connection_id, - ); - swarm.behaviour_mut().gossipsub.add_explicit_peer(&peer_id) - } + Some(SwarmEvent::ConnectionEstablished { peer_id, connection_id, .. }) => { + if &peer_id == swarm.local_peer_id() { + swarm.close_connection(connection_id); + } else if swarm.is_connected(&peer_id) {} else { + log::debug!( + "connection established to peer {} in connection ID {}", + &peer_id, + &connection_id, + ); + swarm.behaviour_mut().gossipsub.add_explicit_peer(&peer_id) } + } Some(SwarmEvent::Behaviour(BehaviorEvent::Gossipsub( GsEvent::Message { propagation_source, message, .. }, ))) => {