diff --git a/src/peer_channels.rs b/src/peer_channels.rs index 77ac977b0..29d61ccf9 100644 --- a/src/peer_channels.rs +++ b/src/peer_channels.rs @@ -67,7 +67,10 @@ impl Context { }; // restore old peers from db, if any - let peers = self.get_peers_for_topic(&topic.to_string()).await?; + let peers = self.get_peers_for_topic(topic).await?; + if peers.len() == 0 { + warn!(self, "joining gossip with zero peers: {peers:?}"); + } // TODO: add timeout as the returned future might be pending forever let connect_future = gossip.join(topic, peers).await?; @@ -81,11 +84,11 @@ impl Context { /// Get list of [NodeId]s for one topic. /// This is used to rejoin a gossip group when reopening the xdc. /// Only [NodeId] is needed because the magic endpoint caches region and derp server for [NodeId]s. - pub async fn get_peers_for_topic(&self, topic: &str) -> Result> { + pub async fn get_peers_for_topic(&self, topic: TopicId) -> Result> { self.sql .query_map( "SELECT public_key FROM iroh_gossip_peers WHERE topic = ?", - (topic,), + (topic.as_bytes(),), |row| { let data = row.get::<_, Vec>(0)?; Ok(data) diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 01e7c70f2..bec730792 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -460,8 +460,8 @@ pub(crate) async fn receive_imf_inner( .add_node_addr(node_addr.clone()) .context("Failed to add node address")?; + let node_id = node_addr.node_id; for topic in topics { - let node_id = node_addr.node_id; context .add_peer_for_topic(instance_id, topic, node_id) .await?;