Skip to content

Commit

Permalink
feat(networking): dont add bootstrap ndoes as relay candidates
Browse files Browse the repository at this point in the history
Increase the potential pool of candidates
  • Loading branch information
joshuef committed Jun 9, 2024
1 parent 6042273 commit f5475df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion sn_networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,13 @@ impl SwarmDriver {

let has_relayed = is_a_relayed_peer(&addrs);

let is_bootstrap_peer = self
.bootstrap_peers
.iter()
.any(|(_ilog2, peers)| peers.contains(&peer_id));

// Do not use an `already relayed` peer as `potential relay candidate`.
if !has_relayed {
if !has_relayed && !is_bootstrap_peer {
self.relay_manager.add_potential_candidates(
&peer_id,
&addrs,
Expand Down
4 changes: 2 additions & 2 deletions sn_networking/src/relay_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use libp2p::{
use rand::Rng;
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};

const MAX_CONCURRENT_RELAY_CONNECTIONS: usize = 3;
const MAX_POTENTIAL_CANDIDATES: usize = 15;
const MAX_CONCURRENT_RELAY_CONNECTIONS: usize = 2;
const MAX_POTENTIAL_CANDIDATES: usize = 1000;

pub(crate) fn is_a_relayed_peer(addrs: &HashSet<Multiaddr>) -> bool {
addrs
Expand Down

0 comments on commit f5475df

Please sign in to comment.