Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug iroh 2 #5602

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deltachat-rpc-client/src/deltachat_rpc_client/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def events_loop(self) -> None:
account_id = event["contextId"]
queue = self.get_queue(account_id)
event = event["event"]
logging.debug("account_id=%d got an event %s", account_id, event)
# logging.debug("account_id=%d got an event %s", account_id, event)
print("account_id=%d got an event %s" % (account_id, event))
queue.put(event)
except Exception:
# Log an exception if the event loop dies.
Expand Down
24 changes: 17 additions & 7 deletions src/peer_channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

use anyhow::{anyhow, Context as _, Result};
use email::Header;
use futures_lite::StreamExt;
use iroh_gossip::net::{Gossip, JoinTopicFut, GOSSIP_ALPN};
use iroh_gossip::proto::{Event as IrohEvent, TopicId};
use iroh_net::relay::{RelayMap, RelayUrl};
Expand Down Expand Up @@ -157,10 +158,6 @@ impl Iroh {

self.gossip.broadcast(topic, data.into()).await?;

if env::var("REALTIME_DEBUG").is_ok() {
info!(ctx, "Sent realtime data");
}

Ok(())
}

Expand Down Expand Up @@ -246,6 +243,15 @@ impl Context {
// Shuts down on deltachat shutdown
tokio::spawn(endpoint_loop(context, endpoint.clone(), gossip.clone()));

let endp = endpoint.clone();
let gsp = gossip.clone();
tokio::spawn(async move {
let mut stream = endp.local_endpoints();
while let Some(endpoints) = stream.next().await {
gsp.update_endpoints(&endpoints)?;
}
anyhow::Ok(())
});
Ok(Iroh {
endpoint,
gossip,
Expand Down Expand Up @@ -347,7 +353,9 @@ pub async fn send_webxdc_realtime_advertisement(
msg.param.set_cmd(SystemMessage::IrohNodeAddr);
msg.in_reply_to = Some(webxdc.rfc724_mid.clone());
send_msg(ctx, webxdc.chat_id, &mut msg).await?;
info!(ctx, "IROH_REALTIME: Sent realtime advertisement");
if env::var("REALTIME_DEBUG").is_ok() {
info!(ctx, "IROH_REALTIME: Sent realtime advertisement");
}
Ok(conn)
}

Expand All @@ -363,6 +371,7 @@ pub async fn leave_webxdc_realtime(ctx: &Context, msg_id: MsgId) -> Result<()> {
let iroh = ctx.get_or_try_init_peer_channel().await?;
iroh.leave_realtime(get_iroh_topic_for_msg(ctx, msg_id).await?)
.await?;

info!(ctx, "IROH_REALTIME: Left gossip for message {msg_id}");

Ok(())
Expand Down Expand Up @@ -430,11 +439,12 @@ async fn subscribe_loop(
let event = stream.recv().await?;
match event {
IrohEvent::NeighborUp(node) => {
info!(context, "IROH_REALTIME: NeighborUp: {}", node.to_string());
iroh_add_peer_for_topic(context, msg_id, topic, node, None).await?;
}
IrohEvent::Received(event) => {
info!(context, "IROH_REALTIME: Received realtime data");
if env::var("REALTIME_DEBUG").is_ok() {
info!(context, "IROH_REALTIME: Received realtime data");
}
context.emit_event(EventType::WebxdcRealtimeData {
msg_id,
data: event
Expand Down
Loading