Skip to content

Commit

Permalink
Merge branch 'main' into matheus23/no-warn-progress
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus23 committed Sep 2, 2024
2 parents 8a913cf + fd56763 commit 833e3ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion iroh-blobs/src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ impl Downloader {
}
}

/// Declare that certains nodes can be used to download a hash.
/// Declare that certain nodes can be used to download a hash.
///
/// Note that this does not start a download, but only provides new nodes to already queued
/// downloads. Use [`Self::queue`] to queue a download.
Expand Down
21 changes: 15 additions & 6 deletions iroh-net/src/discovery/local_swarm_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,28 @@ impl LocalSwarmDiscovery {
continue;
}

if let Some(senders) = senders.get(&discovered_node_id) {
for sender in senders.values() {
let item: DiscoveryItem = (&peer_info).into();
trace!(?item, "sending DiscoveryItem");
sender.send(Ok(item)).await.ok();
let entry = node_addrs.entry(discovered_node_id);
if let std::collections::hash_map::Entry::Occupied(ref entry) = entry {
if entry.get() == &peer_info {
// this is a republish we already know about
continue;
}
}

debug!(
?discovered_node_id,
?peer_info,
"adding node to LocalSwarmDiscovery address book"
);
node_addrs.insert(discovered_node_id, peer_info);

if let Some(senders) = senders.get(&discovered_node_id) {
let item: DiscoveryItem = (&peer_info).into();
trace!(?item, senders = senders.len(), "sending DiscoveryItem");
for sender in senders.values() {
sender.send(Ok(item.clone())).await.ok();
}
}
entry.or_insert(peer_info);
}
Message::SendAddrs(node_id, sender) => {
let id = last_id + 1;
Expand Down

0 comments on commit 833e3ad

Please sign in to comment.