diff --git a/src/peer_channels.rs b/src/peer_channels.rs index fba6c356e..3618116ab 100644 --- a/src/peer_channels.rs +++ b/src/peer_channels.rs @@ -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) -> 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, diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 28852a824..a181c2977 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1433,7 +1433,8 @@ async fn add_parts( let relay_server = node_addr.relay_url().map(|relay| relay.as_str()); let topic = get_iroh_topic_for_msg(context, instance_id).await?; iroh_add_peer_for_topic(context, instance_id, topic, node_id, relay_server).await?; - + let iroh = context.get_or_try_init_peer_channel().await?; + iroh.maybe_add_gossip_peers(topic, vec![node_addr]).await?; chat_id = DC_CHAT_ID_TRASH; } Err(err) => {