fix: connect to peers that advertise to you

This commit is contained in:
Sebastian Klähn
2024-05-19 18:19:45 +00:00
committed by link2xt
parent 31d7b4f9ce
commit 8cb699290a
2 changed files with 17 additions and 1 deletions

View File

@@ -122,6 +122,21 @@ impl Iroh {
Ok(Some(connect_future))
}
/// Add gossip peers to realtime channel if it is already active.
pub async fn maybe_add_gossip_peers(&self, topic: TopicId, peers: Vec<NodeAddr>) -> Result<()> {
if let Some(state) = self.iroh_channels.read().await.get(&topic) {
if state.subscribe_loop.is_some() {
for peer in &peers {
self.endpoint.add_node_addr(peer.clone())?;
}
self.gossip
.join(topic, peers.into_iter().map(|peer| peer.node_id).collect())
.await?;
}
}
Ok(())
}
/// Send realtime data to the gossip swarm.
pub async fn send_webxdc_realtime_data(
&self,