Skip to content

Commit 6147f39

Browse files
committed
Add builder and use it in one example
1 parent cb8ad48 commit 6147f39

File tree

5 files changed

+8
-22
lines changed

5 files changed

+8
-22
lines changed

examples/custom-protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async fn main() -> Result<()> {
9999
builder.endpoint().clone(),
100100
local_pool.handle().clone(),
101101
);
102-
let blobs = Arc::new(Blobs::new_with_events(
102+
let blobs = Arc::new(Blobs::new(
103103
store,
104104
local_pool.handle().clone(),
105105
Default::default(),

examples/hello-world-fetch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async fn main() -> Result<()> {
4545
builder.endpoint().clone(),
4646
local_pool.handle().clone(),
4747
);
48-
let blobs = Arc::new(Blobs::new_with_events(
48+
let blobs = Arc::new(Blobs::new(
4949
store,
5050
local_pool.handle().clone(),
5151
Default::default(),

examples/hello-world-provide.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
//! This is using an in memory database and a random node id.
44
//! run this example from the project root:
55
//! $ cargo run --example hello-world-provide
6-
use std::sync::Arc;
7-
86
use iroh_base::{node_addr::AddrInfoOptions, ticket::BlobTicket};
9-
use iroh_blobs::{downloader::Downloader, net_protocol::Blobs, util::local_pool::LocalPool};
7+
use iroh_blobs::{net_protocol::Blobs, util::local_pool::LocalPool};
108
use tracing_subscriber::{prelude::*, EnvFilter};
119

1210
// set the RUST_LOG env var to one of {debug,info,warn} to see logging info
@@ -26,21 +24,9 @@ async fn main() -> anyhow::Result<()> {
2624
// create a new node
2725
let mut builder = iroh::node::Node::memory().build().await?;
2826
let local_pool = LocalPool::default();
29-
let store = iroh_blobs::store::mem::Store::new();
30-
let downloader = Downloader::new(
31-
store.clone(),
32-
builder.endpoint().clone(),
33-
local_pool.handle().clone(),
34-
);
35-
let blobs = Arc::new(Blobs::new_with_events(
36-
store,
37-
local_pool.handle().clone(),
38-
Default::default(),
39-
downloader,
40-
builder.endpoint().clone(),
41-
));
42-
let blobs_client = blobs.clone().client();
43-
builder = builder.accept(iroh_blobs::protocol::ALPN.to_vec(), blobs);
27+
let blobs = Blobs::memory().build(local_pool.handle(), builder.endpoint());
28+
builder = builder.accept(iroh_blobs::ALPN.to_vec(), blobs.clone());
29+
let blobs_client = blobs.client();
4430
let node = builder.spawn().await?;
4531

4632
// add some data and remember the hash

examples/local-swarm-discovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async fn main() -> anyhow::Result<()> {
8282
builder.endpoint().clone(),
8383
local_pool.handle().clone(),
8484
);
85-
let blobs = Arc::new(Blobs::new_with_events(
85+
let blobs = Arc::new(Blobs::new(
8686
store,
8787
local_pool.handle().clone(),
8888
Default::default(),

src/rpc/client/blobs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ mod tests {
10691069
// Setup blobs
10701070
let downloader =
10711071
Downloader::new(store.clone(), endpoint.clone(), local_pool.handle().clone());
1072-
let blobs = Arc::new(Blobs::new_with_events(
1072+
let blobs = Arc::new(Blobs::new(
10731073
store.clone(),
10741074
local_pool.handle().clone(),
10751075
events,

0 commit comments

Comments
 (0)