Skip to content

Commit dd50fd8

Browse files
committed
Merge remote-tracking branch 'origin/main' into Frando/wasm
2 parents ce43f1c + 1f79c18 commit dd50fd8

File tree

19 files changed

+487
-810
lines changed

19 files changed

+487
-810
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iroh-blobs"
3-
version = "0.95.0"
3+
version = "0.96.0"
44
edition = "2021"
55
description = "content-addressed blobs for iroh"
66
license = "MIT OR Apache-2.0"
@@ -18,7 +18,7 @@ bytes = { version = "1", features = ["serde"] }
1818
derive_more = { version = "2.0.1", features = ["from", "try_from", "into", "debug", "display", "deref", "deref_mut"] }
1919
futures-lite = "2.6.0"
2020
quinn = { package = "iroh-quinn", version = "0.14.0", optional = true }
21-
n0-future = "0.3"
21+
n0-future = "0.3.0"
2222
n0-snafu = "0.2.2"
2323
range-collections = { version = "0.4.6", features = ["serde"] }
2424
smallvec = { version = "1", features = ["serde", "const_new"] }
@@ -35,11 +35,12 @@ chrono = "0.4.39"
3535
nested_enum_utils = "0.2.1"
3636
ref-cast = "1.0.24"
3737
arrayvec = "0.7.6"
38-
iroh = { version = "0.93", default-features = false }
38+
iroh = { version = "0.94", default-features = false }
3939
self_cell = "1.1.0"
4040
genawaiter = { version = "0.99.1", features = ["futures03"] }
41-
iroh-base = "0.93"
42-
irpc = { version = "0.9.0", features = ["spans", "stream", "derive", "varint-util"], default-features = false }
41+
iroh-base = "0.94"
42+
iroh-tickets = "0.1"
43+
irpc = { version = "0.10.0", features = ["spans", "stream", "derive", "varint-util"], default-features = false }
4344
iroh-metrics = { version = "0.36" }
4445
redb = { version = "2.6.3", optional = true }
4546
reflink-copy = { version = "0.1.24", optional = true }
@@ -58,7 +59,7 @@ tracing-subscriber = { version = "0.3.20", features = ["fmt"] }
5859
tracing-test = "0.2.5"
5960
walkdir = "2.5.0"
6061
atomic_refcell = "0.1.13"
61-
iroh = { version = "0.93", features = ["discovery-local-network"]}
62+
iroh = { version = "0.94", features = ["discovery-local-network"]}
6263
async-compression = { version = "0.4.30", features = ["lz4", "tokio"] }
6364
concat_const = "0.2.0"
6465

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ use iroh_blobs::{store::mem::MemStore, BlobsProtocol, ticket::BlobTicket};
4040
async fn main() -> anyhow::Result<()> {
4141
// create an iroh endpoint that includes the standard discovery mechanisms
4242
// we've built at number0
43-
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
43+
let endpoint = Endpoint::bind().await?;
4444
4545
// create a protocol handler using an in-memory blob store.
4646
let store = MemStore::new();
4747
let tag = store.add_slice(b"Hello world").await?;
4848
4949
let _ = endpoint.online().await;
50-
let addr = endpoint.node_addr();
50+
let addr = endpoint.addr();
5151
let ticket = BlobTicket::new(addr, tag.hash, tag.format);
5252
5353
// build the router

examples/compression.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::common::get_or_generate_secret_key;
2727
#[derive(Debug, Parser)]
2828
#[command(version, about)]
2929
pub enum Args {
30-
/// Limit requests by node id
30+
/// Limit requests by endpoint id
3131
Provide {
3232
/// Path for files to add.
3333
path: PathBuf,
@@ -160,7 +160,7 @@ impl<C: Compression> ProtocolHandler for CompressedBlobsProtocol<C> {
160160
.events
161161
.client_connected(|| ClientConnected {
162162
connection_id,
163-
node_id: connection.remote_node_id().ok(),
163+
endpoint_id: connection.remote_id().ok(),
164164
})
165165
.await
166166
{
@@ -184,11 +184,7 @@ async fn main() -> Result<()> {
184184
setup_logging();
185185
let args = Args::parse();
186186
let secret = get_or_generate_secret_key()?;
187-
let endpoint = iroh::Endpoint::builder()
188-
.secret_key(secret)
189-
.discovery_n0()
190-
.bind()
191-
.await?;
187+
let endpoint = iroh::Endpoint::builder().secret_key(secret).bind().await?;
192188
let compression = lz4::Compression;
193189
match args {
194190
Args::Provide { path } => {
@@ -198,7 +194,7 @@ async fn main() -> Result<()> {
198194
let router = iroh::protocol::Router::builder(endpoint.clone())
199195
.accept(lz4::Compression::ALPN, blobs)
200196
.spawn();
201-
let ticket = BlobTicket::new(endpoint.node_id().into(), tag.hash, tag.format);
197+
let ticket = BlobTicket::new(endpoint.id().into(), tag.hash, tag.format);
202198
println!("Serving blob with hash {}", tag.hash);
203199
println!("Ticket: {ticket}");
204200
println!("Node is running. Press Ctrl-C to exit.");
@@ -209,7 +205,7 @@ async fn main() -> Result<()> {
209205
Args::Get { ticket, target } => {
210206
let store = MemStore::new();
211207
let conn = endpoint
212-
.connect(ticket.node_addr().clone(), lz4::Compression::ALPN)
208+
.connect(ticket.addr().clone(), lz4::Compression::ALPN)
213209
.await?;
214210
let connection_id = conn.stable_id() as u64;
215211
let (send, recv) = conn.open_bi().await?;

examples/custom-protocol.rs

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
//!
1818
//! cargo run --example custom-protocol -- listen "hello-world" "foo-bar" "hello-moon"
1919
//!
20-
//! This spawns an iroh nodes with three blobs. It will print the node's node id.
20+
//! This spawns an iroh node with three blobs. It will print the node's endpoint id.
2121
//!
2222
//! In another terminal, run
2323
//!
24-
//! cargo run --example custom-protocol -- query <node-id> hello
24+
//! cargo run --example custom-protocol -- query <endpoint-id> hello
2525
//!
26-
//! Replace <node-id> with the node id from above. This will connect to the listening node with our
26+
//! Replace <endpoint-id> with the endpoint id from above. This will connect to the listening node with our
2727
//! custom protocol and query for the string `hello`. The listening node will return a list of
2828
//! blob hashes that contain `hello`. We will then download all these blobs with iroh-blobs,
2929
//! and then print a list of the hashes with their content.
@@ -46,7 +46,7 @@ use iroh::{
4646
discovery::pkarr::PkarrResolver,
4747
endpoint::Connection,
4848
protocol::{AcceptError, ProtocolHandler, Router},
49-
Endpoint, NodeId,
49+
Endpoint, EndpointId,
5050
};
5151
use iroh_blobs::{api::Store, store::mem::MemStore, BlobsProtocol, Hash};
5252
mod common;
@@ -67,8 +67,8 @@ pub enum Command {
6767
},
6868
/// Query a remote node for data and print the results.
6969
Query {
70-
/// The node id of the node we want to query.
71-
node_id: NodeId,
70+
/// The endpoint id of the node we want to query.
71+
endpoint_id: EndpointId,
7272
/// The text we want to match.
7373
query: String,
7474
},
@@ -81,17 +81,13 @@ pub enum Command {
8181
const ALPN: &[u8] = b"iroh-example/text-search/0";
8282

8383
async fn listen(text: Vec<String>) -> Result<()> {
84-
// allow the user to provide a secret so we can have a stable node id.
84+
// allow the user to provide a secret so we can have a stable endpoint id.
8585
// This is only needed for the listen side.
8686
let secret_key = get_or_generate_secret_key()?;
8787
// Use an in-memory store for this example. You would use a persistent store in production code.
8888
let store = MemStore::new();
8989
// Create an endpoint with the secret key and discovery publishing to the n0 dns server enabled.
90-
let endpoint = Endpoint::builder()
91-
.secret_key(secret_key)
92-
.discovery_n0()
93-
.bind()
94-
.await?;
90+
let endpoint = Endpoint::builder().secret_key(secret_key).bind().await?;
9591
// Build our custom protocol handler. The `builder` exposes access to various subsystems in the
9692
// iroh node. In our case, we need a blobs client and the endpoint.
9793
let proto = BlobSearch::new(&store);
@@ -108,30 +104,30 @@ async fn listen(text: Vec<String>) -> Result<()> {
108104
.accept(iroh_blobs::ALPN, blobs.clone())
109105
.spawn();
110106

111-
// Print our node id, so clients know how to connect to us.
112-
let node_id = node.endpoint().node_id();
113-
println!("our node id: {node_id}");
107+
// Print our endpoint id, so clients know how to connect to us.
108+
let node_id = node.endpoint().id();
109+
println!("our endpoint id: {node_id}");
114110

115111
// Wait for Ctrl-C to be pressed.
116112
tokio::signal::ctrl_c().await?;
117113
node.shutdown().await?;
118114
Ok(())
119115
}
120116

121-
async fn query(node_id: NodeId, query: String) -> Result<()> {
117+
async fn query(endpoint_id: EndpointId, query: String) -> Result<()> {
122118
// Build a in-memory node. For production code, you'd want a persistent node instead usually.
123119
let store = MemStore::new();
124120
// Create an endpoint with a random secret key and no discovery publishing.
125121
// For a client we just need discovery resolution via the n0 dns server, which
126122
// the PkarrResolver provides.
127-
let endpoint = Endpoint::builder()
128-
.add_discovery(PkarrResolver::n0_dns())
123+
let endpoint = Endpoint::empty_builder(iroh::RelayMode::Default)
124+
.discovery(PkarrResolver::n0_dns())
129125
.bind()
130126
.await?;
131127
// Query the remote node.
132128
// This will send the query over our custom protocol, read hashes on the reply stream,
133129
// and download each hash over iroh-blobs.
134-
let hashes = query_remote(&endpoint, &store, node_id, &query).await?;
130+
let hashes = query_remote(&endpoint, &store, endpoint_id, &query).await?;
135131

136132
// Print out our query results.
137133
for hash in hashes {
@@ -157,10 +153,10 @@ async fn main() -> Result<()> {
157153
listen(text).await?;
158154
}
159155
Command::Query {
160-
node_id,
156+
endpoint_id,
161157
query: query_text,
162158
} => {
163-
query(node_id, query_text).await?;
159+
query(endpoint_id, query_text).await?;
164160
}
165161
}
166162

@@ -180,8 +176,8 @@ impl ProtocolHandler for BlobSearch {
180176
/// the connection lasts.
181177
async fn accept(&self, connection: Connection) -> std::result::Result<(), AcceptError> {
182178
let this = self.clone();
183-
// We can get the remote's node id from the connection.
184-
let node_id = connection.remote_node_id()?;
179+
// We can get the remote's endpoint id from the connection.
180+
let node_id = connection.remote_id()?;
185181
println!("accepted connection from {node_id}");
186182

187183
// Our protocol is a simple request-response protocol, so we expect the
@@ -269,14 +265,14 @@ impl BlobSearch {
269265
pub async fn query_remote(
270266
endpoint: &Endpoint,
271267
store: &Store,
272-
node_id: NodeId,
268+
endpoint_id: EndpointId,
273269
query: &str,
274270
) -> Result<Vec<Hash>> {
275271
// Establish a connection to our node.
276-
// We use the default node discovery in iroh, so we can connect by node id without
272+
// We use the default node discovery in iroh, so we can connect by endpoint id without
277273
// providing further information.
278-
let conn = endpoint.connect(node_id, ALPN).await?;
279-
let blobs_conn = endpoint.connect(node_id, iroh_blobs::ALPN).await?;
274+
let conn = endpoint.connect(endpoint_id, ALPN).await?;
275+
let blobs_conn = endpoint.connect(endpoint_id, iroh_blobs::ALPN).await?;
280276

281277
// Open a bi-directional in our connection.
282278
let (mut send, mut recv) = conn.open_bi().await?;

examples/get-blob.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@ async fn main() -> anyhow::Result<()> {
2929
setup_logging();
3030
let cli = Cli::parse();
3131
let ticket = cli.ticket;
32-
let endpoint = iroh::Endpoint::builder()
32+
let endpoint = iroh::Endpoint::empty_builder(iroh::RelayMode::Default)
3333
.discovery(PkarrResolver::n0_dns())
3434
.bind()
3535
.await?;
3636
anyhow::ensure!(
3737
ticket.format() == BlobFormat::Raw,
3838
"This example only supports raw blobs."
3939
);
40-
let connection = endpoint
41-
.connect(ticket.node_addr().node_id, iroh_blobs::ALPN)
42-
.await?;
40+
let connection = endpoint.connect(ticket.addr().id, iroh_blobs::ALPN).await?;
4341
let mut progress = iroh_blobs::get::request::get_blob(connection, ticket.hash());
4442
let stats = if cli.progress {
4543
loop {

0 commit comments

Comments
 (0)