Skip to content

Commit 27bebd8

Browse files
committed
refactor: move things around, use intermediate broadcast channel for events to track closed channels
1 parent 38f1f44 commit 27bebd8

File tree

7 files changed

+381
-259
lines changed

7 files changed

+381
-259
lines changed

Cargo.lock

Lines changed: 16 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,19 @@ tokio-util = { version = "0.7.12", optional = true, features = ["codec"] }
7070
tracing = "0.1"
7171
data-encoding = { version = "2.6.0", optional = true }
7272
thiserror = { version = "2.0", optional = true }
73-
irpc = { git = "https://github.com/n0-computer/irpc", branch = "Frando/wasm" }
74-
irpc-derive = { git = "https://github.com/n0-computer/irpc", branch = "Frando/wasm" }
73+
irpc = { git = "https://github.com/n0-computer/irpc", optional = true, default-features = false, features = [
74+
"stream",
75+
"message_spans",
76+
] }
77+
irpc-derive = { git = "https://github.com/n0-computer/irpc", optional = true }
78+
# irpc = { path = "../irpc", optional = true, default-features = false, features = [
79+
# "stream",
80+
# "message_spans",
81+
# ] }
82+
# irpc-derive = { path = "../irpc/irpc-derive", optional = true }
83+
84+
# rpc dependencies
85+
quinn = { package = "iroh-quinn", version = "0.13.0", optional = true }
7586

7687
# test-utils dependencies (optional)
7788
rand_chacha = { version = "0.3.1", optional = true }
@@ -87,6 +98,7 @@ serde_json = { version = "1", optional = true }
8798
rayon = { version = "1.10.0", optional = true }
8899
comfy-table = { version = "7.1.4", optional = true }
89100

101+
90102
[dev-dependencies]
91103
tokio = { version = "1", features = [
92104
"io-util",
@@ -111,6 +123,8 @@ url = "2.4.0"
111123
[features]
112124
default = ["net"]
113125
net = [
126+
"dep:irpc",
127+
"dep:irpc-derive",
114128
"dep:futures-lite",
115129
"dep:iroh",
116130
"dep:tokio",
@@ -121,6 +135,7 @@ net = [
121135
"dep:anyhow",
122136
"dep:thiserror",
123137
]
138+
rpc = ["net", "dep:quinn", "irpc/rpc", "irpc/quinn_endpoint_setup"]
124139
test-utils = ["dep:rand_chacha", "dep:humantime-serde"]
125140
simulator = [
126141
"test-utils",
@@ -132,6 +147,7 @@ simulator = [
132147
"dep:comfy-table",
133148
]
134149
examples = ["net", "dep:data-encoding"]
150+
quinn = ["dep:quinn"]
135151

136152
[[test]]
137153
name = "sim"
@@ -158,4 +174,4 @@ rustdoc-args = ["--cfg", "iroh_docsrs"]
158174
debug = true
159175

160176
[profile.release]
161-
debug = true
177+
debug = true

examples/chat.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use ed25519_dalek::Signature;
1212
use futures_lite::StreamExt;
1313
use iroh::{Endpoint, NodeAddr, PublicKey, RelayMap, RelayMode, RelayUrl, SecretKey};
1414
use iroh_gossip::{
15-
net::{Event, Gossip, GossipEvent, GossipReceiver, GOSSIP_ALPN},
15+
api::{Event, GossipEvent, GossipReceiver},
16+
net::{Gossip, GOSSIP_ALPN},
1617
proto::TopicId,
1718
};
1819
use n0_future::task;
@@ -138,7 +139,7 @@ async fn main() -> Result<()> {
138139
endpoint.add_node_addr(peer)?;
139140
}
140141
};
141-
let (sender, receiver) = gossip.subscribe_and_join(topic, peer_ids).await?.split();
142+
let (mut sender, receiver) = gossip.subscribe_and_join(topic, peer_ids).await?.split();
142143
println!("> connected!");
143144

144145
// broadcast our name, if set

0 commit comments

Comments
 (0)