From 4fb000228323fd31b1e9faf5ff1c17d4441612c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kl=C3=A4hn?= Date: Mon, 29 Jan 2024 16:12:45 +0100 Subject: [PATCH] stufff --- src/peer_channels.rs | 2 ++ src/receive_imf.rs | 5 ----- src/webxdc.rs | 14 +++++++------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/peer_channels.rs b/src/peer_channels.rs index 29d61ccf9..59bd4539e 100644 --- a/src/peer_channels.rs +++ b/src/peer_channels.rs @@ -191,9 +191,11 @@ async fn subscribe_loop( let event = stream.recv().await?; match event { IrohEvent::NeighborUp(node) => { + info!(context, "NeighborUp: {:?}", node); context.add_peer_for_topic(msg_id, topic, node).await?; } IrohEvent::NeighborDown(node) => { + info!(context, "NeighborDown: {:?}", node); context.delete_peer_for_topic(topic, node).await?; } IrohEvent::Received(event) => { diff --git a/src/receive_imf.rs b/src/receive_imf.rs index bec730792..4913de263 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -441,11 +441,6 @@ pub(crate) async fn receive_imf_inner( // join advertised gossip topics Ok((topics, instance_id)) => { warn!(context, "Joining topics: {:#?}", topics); - warn!( - context, - "{:?}", - mime_parser.get_header(HeaderDef::IrohPublicGossip) - ); if let Some(node_addr) = mime_parser.get_header(HeaderDef::IrohPublicGossip) { match serde_json::from_str::(node_addr) .context("Failed to parse node address") diff --git a/src/webxdc.rs b/src/webxdc.rs index 8d8eddcba..357e52611 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -515,14 +515,13 @@ impl Context { let topic = TopicId::from_str(&iroh_base::base32::fmt( topic.get(0..32).context("Can't get 32 bytes from topic")?, ))?; - self.join_and_subscribe_topic(topic, instance_msg_id) - .await?; + if !topic_exists { info!( self, "Gossip topic {topic} does not exist, sending over smtp", ); - let addr = self + let node_id = self .endpoint .lock() .await @@ -530,9 +529,11 @@ impl Context { .unwrap() .my_addr() .await - .unwrap(); - - self.add_peer_for_topic(instance_msg_id, topic, addr.node_id) + .unwrap() + .node_id; + self.join_and_subscribe_topic(topic, instance_msg_id) + .await?; + self.add_peer_for_topic(instance_msg_id, topic, node_id) .await?; ephemeral = false; } else { @@ -940,7 +941,6 @@ pub async fn join_gossip_topic(ctx: &Context, msg_id: MsgId, topic: &str) -> Res let topic = TopicId::from_str(&iroh_base::base32::fmt( topic.get(0..32).context("Can't get 32 bytes from topic")?, ))?; - info!(ctx, "Received join request from frontend"); ctx.join_and_subscribe_topic(topic, msg_id).await }