Skip to content

Commit

Permalink
Don't add as an explicit peer if already connected
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Mar 23, 2024
1 parent f11a08c commit 4914420
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions coordinator/src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, .. },
))) => {
Expand Down

0 comments on commit 4914420

Please sign in to comment.