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

feat(iroh-gossip)!: dispatch gossip events and updates by topic #2570

Merged
merged 14 commits into from
Aug 5, 2024
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions iroh-cli/src/commands/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ impl GossipCommands {
line = input_lines.next_line() => {
let line = line.context("failed to read from stdin")?;
if let Some(line) = line {
sink.send(iroh_gossip::dispatcher::Command::Broadcast(line.into())).await?;
sink.send(iroh_gossip::net::Command::Broadcast(line.into())).await?;
} else {
break;
}
}
res = stream.next() => {
let res = res.context("gossip stream ended")?.context("failed to read gossip stream")?;
match res {
iroh_gossip::dispatcher::Event::Gossip(event) => {
iroh_gossip::net::Event::Gossip(event) => {
if verbose {
println!("{:?}", event);
} else if let iroh_gossip::dispatcher::GossipEvent::Received(iroh_gossip::dispatcher::Message { content, .. }) = event {
} else if let iroh_gossip::net::GossipEvent::Received(iroh_gossip::net::Message { content, .. }) = event {
println!("{:?}", content);
}
}
iroh_gossip::dispatcher::Event::Lagged => {
iroh_gossip::net::Event::Lagged => {
anyhow::bail!("gossip stream lagged");
}
};
Expand Down
11 changes: 1 addition & 10 deletions iroh-docs/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use tracing::{error, error_span, Instrument};
use crate::{actor::SyncHandle, ContentStatus, ContentStatusCallback, Entry, NamespaceId};
use crate::{Author, AuthorId};

use self::gossip::GossipActor;
use self::live::{LiveActor, ToLiveActor};

pub use self::live::SyncEvent;
Expand Down Expand Up @@ -69,7 +68,6 @@ impl Engine {
default_author_storage: DefaultAuthorStorage,
) -> anyhow::Result<Self> {
let (live_actor_tx, to_live_actor_recv) = mpsc::channel(ACTOR_CHANNEL_CAP);
let (to_gossip_actor, to_gossip_actor_recv) = mpsc::channel(ACTOR_CHANNEL_CAP);
let me = endpoint.node_id().fmt_short();

let content_status_cb = {
Expand All @@ -86,17 +84,10 @@ impl Engine {
downloader,
to_live_actor_recv,
live_actor_tx.clone(),
to_gossip_actor,
);
let gossip_actor = GossipActor::new(
to_gossip_actor_recv,
sync.clone(),
gossip,
live_actor_tx.clone(),
);
let actor_handle = tokio::task::spawn(
async move {
if let Err(err) = actor.run(gossip_actor).await {
if let Err(err) = actor.run().await {
error!("sync actor failed: {err:?}");
}
}
Expand Down
Loading
Loading