Skip to content

Commit

Permalink
fix is_discovery bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ramfox committed Sep 11, 2024
1 parent e1d0d04 commit a625511
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions iroh-net/src/discovery/local_swarm_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
const N0_LOCAL_SWARM: &str = "iroh.local.swarm";

/// Provenance string
pub const SERVICE_NAME: &str = "local";
const PROVENANCE: &str = "local";

/// How long we will wait before we stop sending discovery items
const DISCOVERY_DURATION: Duration = Duration::from_secs(10);
Expand Down Expand Up @@ -270,7 +270,7 @@ impl From<&Peer> for DiscoveryItem {
.map(|(ip, port)| SocketAddr::new(*ip, *port))
.collect();
DiscoveryItem {
provenance: SERVICE_NAME,
provenance: PROVENANCE,
last_updated: None,
addr_info: AddrInfo {
relay_url: None,
Expand Down
8 changes: 4 additions & 4 deletions iroh-net/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,10 +767,10 @@ impl Endpoint {
.list_remote_infos()
.into_iter()
.filter(move |remote| {
remote.sources.iter().any(|(source, elapsed)| {
source.is_discovery(crate::discovery::local_swarm_discovery::SERVICE_NAME)
&& elapsed <= &duration
})
remote
.sources
.iter()
.any(|(source, elapsed)| source.is_discovery() && elapsed <= &duration)
})
}

Expand Down
10 changes: 5 additions & 5 deletions iroh-net/src/magicsock/node_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ impl Source {
false
}

/// Returns true if the [`Source::Discovery`] service is the same as the given string.
pub fn is_discovery(&self, s: &str) -> bool {
if let Source::Discovery { service } = self {
return service == s;
/// Returns true if the source is a [`Source::Discovery`]
pub fn is_discovery(&self) -> bool {
match self {
Source::Discovery { .. } => true,
_ => false,
}
false
}
}

Expand Down

0 comments on commit a625511

Please sign in to comment.