Skip to content

Commit

Permalink
refactor: use seperate actors for sync and gossip
Browse files Browse the repository at this point in the history
  • Loading branch information
Frando committed Oct 11, 2023
1 parent 6950056 commit cd84d25
Show file tree
Hide file tree
Showing 17 changed files with 1,253 additions and 675 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions iroh-gossip/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ impl Gossip {
///
/// TODO: Optionally resolve to an error once all connection attempts failed.
#[derive(Debug)]
pub struct JoinTopicFut(oneshot::Receiver<anyhow::Result<()>>);
pub struct JoinTopicFut(oneshot::Receiver<anyhow::Result<TopicId>>);
impl Future for JoinTopicFut {
type Output = anyhow::Result<()>;
type Output = anyhow::Result<TopicId>;

fn poll(
mut self: std::pin::Pin<&mut Self>,
Expand Down Expand Up @@ -293,7 +293,7 @@ enum ToActor {
Join(
TopicId,
Vec<PublicKey>,
#[debug(skip)] oneshot::Sender<anyhow::Result<()>>,
#[debug(skip)] oneshot::Sender<anyhow::Result<TopicId>>,
),
/// Leave a topic, send disconnect messages and drop all state.
Quit(TopicId),
Expand Down Expand Up @@ -453,12 +453,13 @@ impl Actor {
.await?;
if self.state.has_active_peers(&topic_id) {
// If the active_view contains at least one peer, reply now
reply.send(Ok(())).ok();
reply.send(Ok(topic_id)).ok();
} else {
// Otherwise, wait for any peer to come up as neighbor.
let sub = self.subscribe(topic_id);
tokio::spawn(async move {
let res = wait_for_neighbor_up(sub).await;
let res = res.map(|_| topic_id);
reply.send(res).ok();
});
}
Expand Down
1 change: 1 addition & 0 deletions iroh-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ postcard = { version = "1", default-features = false, features = ["alloc", "use-
rand = "0.8.5"
rand_core = "0.6.4"
serde = { version = "1.0.164", features = ["derive"] }
strum = { version = "0.25", features = ["derive"] }
url = "2.4"
bytes = "1"
parking_lot = "0.12.1"
Expand Down
Loading

0 comments on commit cd84d25

Please sign in to comment.