Skip to content

Commit de55d99

Browse files
committed
Remove .preset(presets::N0) since it is implied by .builder()
1 parent 7592271 commit de55d99

File tree

6 files changed

+25
-37
lines changed

6 files changed

+25
-37
lines changed

examples/compression.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{fmt::Debug, path::PathBuf};
88
use anyhow::Result;
99
use clap::Parser;
1010
use common::setup_logging;
11-
use iroh::{endpoint::presets, protocol::ProtocolHandler};
11+
use iroh::protocol::ProtocolHandler;
1212
use iroh_blobs::{
1313
api::Store,
1414
get::StreamPair,
@@ -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-
.preset(presets::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 } => {

examples/custom-protocol.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use anyhow::Result;
4444
use clap::Parser;
4545
use iroh::{
4646
discovery::pkarr::PkarrResolver,
47-
endpoint::{presets, Connection},
47+
endpoint::Connection,
4848
protocol::{AcceptError, ProtocolHandler, Router},
4949
Endpoint, EndpointId,
5050
};
@@ -87,11 +87,7 @@ async fn listen(text: Vec<String>) -> Result<()> {
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-
.preset(presets::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);
@@ -124,7 +120,10 @@ async fn query(endpoint_id: EndpointId, query: String) -> Result<()> {
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().preset(presets::N0).bind().await?;
123+
let endpoint = Endpoint::empty_builder(iroh::RelayMode::Default)
124+
.discovery(PkarrResolver::n0_dns())
125+
.bind()
126+
.await?;
128127
// Query the remote node.
129128
// This will send the query over our custom protocol, read hashes on the reply stream,
130129
// and download each hash over iroh-blobs.

examples/limit.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::{
2121
use anyhow::Result;
2222
use clap::Parser;
2323
use common::setup_logging;
24-
use iroh::{endpoint::presets, protocol::Router, EndpointAddr, EndpointId, SecretKey};
24+
use iroh::{protocol::Router, EndpointAddr, EndpointId, SecretKey};
2525
use iroh_blobs::{
2626
provider::events::{
2727
AbortReason, ConnectMode, EventMask, EventSender, ProviderMessage, RequestMode,
@@ -231,11 +231,7 @@ async fn main() -> Result<()> {
231231
setup_logging();
232232
let args = Args::parse();
233233
let secret = get_or_generate_secret_key()?;
234-
let endpoint = iroh::Endpoint::builder()
235-
.secret_key(secret)
236-
.preset(presets::N0)
237-
.bind()
238-
.await?;
234+
let endpoint = iroh::Endpoint::builder().secret_key(secret).bind().await?;
239235
match args {
240236
Args::Get { ticket } => {
241237
let connection = endpoint
@@ -352,11 +348,7 @@ async fn add_paths(store: &MemStore, paths: Vec<PathBuf>) -> Result<HashMap<Path
352348

353349
async fn setup(store: MemStore, events: EventSender) -> Result<(Router, EndpointAddr)> {
354350
let secret = get_or_generate_secret_key()?;
355-
let endpoint = iroh::Endpoint::builder()
356-
.preset(presets::N0)
357-
.secret_key(secret)
358-
.bind()
359-
.await?;
351+
let endpoint = iroh::Endpoint::builder().secret_key(secret).bind().await?;
360352
endpoint.online().await;
361353
let addr = endpoint.addr();
362354
let blobs = BlobsProtocol::new(&store, Some(events));

examples/mdns-discovery.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ async fn main() -> anyhow::Result<()> {
136136
Commands::Accept { path } => {
137137
accept(path).await?;
138138
}
139-
Commands::Connect { endpoint_id, hash, out } => {
139+
Commands::Connect {
140+
endpoint_id,
141+
hash,
142+
out,
143+
} => {
140144
connect(*endpoint_id, *hash, out.clone()).await?;
141145
}
142146
}

examples/transfer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::path::PathBuf;
22

3-
use iroh::{endpoint::presets, protocol::Router, Endpoint};
3+
use iroh::{protocol::Router, Endpoint};
44
use iroh_blobs::{store::mem::MemStore, ticket::BlobTicket, BlobsProtocol};
55

66
#[tokio::main]
77
async fn main() -> anyhow::Result<()> {
88
// Create an endpoint, it allows creating and accepting
99
// connections in the iroh p2p world
10-
let endpoint = Endpoint::builder().preset(presets::N0).bind().await?;
10+
let endpoint = Endpoint::builder().bind().await?;
1111

1212
// We initialize an in-memory backing store for iroh-blobs
1313
let store = MemStore::new();

src/tests.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ use std::{collections::HashSet, io, ops::Range, path::PathBuf};
22

33
use bao_tree::ChunkRanges;
44
use bytes::Bytes;
5-
use iroh::{
6-
discovery::static_provider::StaticProvider, endpoint::presets, protocol::Router, Endpoint,
7-
EndpointId,
8-
};
5+
use iroh::{discovery::static_provider::StaticProvider, protocol::Router, Endpoint, EndpointId};
96
use irpc::RpcMessage;
107
use n0_future::{task::AbortOnDropHandle, StreamExt};
118
use tempfile::TempDir;
@@ -615,14 +612,14 @@ async fn node_serve_hash_seq() -> TestResult<()> {
615612
let hash_seq = tts.iter().map(|x| x.hash).collect::<HashSeq>();
616613
let root_tt = store.add_bytes(hash_seq).await?;
617614
let root = root_tt.hash;
618-
let endpoint = Endpoint::builder().preset(presets::N0).bind().await?;
615+
let endpoint = Endpoint::builder().bind().await?;
619616
let blobs = crate::net_protocol::BlobsProtocol::new(&store, None);
620617
let r1 = Router::builder(endpoint)
621618
.accept(crate::protocol::ALPN, blobs)
622619
.spawn();
623620
let addr1 = r1.endpoint().addr();
624621
info!("node addr: {addr1:?}");
625-
let endpoint2 = Endpoint::builder().preset(presets::N0).bind().await?;
622+
let endpoint2 = Endpoint::builder().bind().await?;
626623
let conn = endpoint2.connect(addr1, crate::protocol::ALPN).await?;
627624
let (hs, sizes) = get::request::get_hash_seq_and_sizes(&conn, &root, 1024, None).await?;
628625
println!("hash seq: {hs:?}");
@@ -646,14 +643,14 @@ async fn node_serve_blobs() -> TestResult<()> {
646643
for size in sizes {
647644
tts.push(store.add_bytes(test_data(size)).await?);
648645
}
649-
let endpoint = Endpoint::builder().preset(presets::N0).bind().await?;
646+
let endpoint = Endpoint::builder().bind().await?;
650647
let blobs = crate::net_protocol::BlobsProtocol::new(&store, None);
651648
let r1 = Router::builder(endpoint)
652649
.accept(crate::protocol::ALPN, blobs)
653650
.spawn();
654651
let addr1 = r1.endpoint().addr();
655652
info!("node addr: {addr1:?}");
656-
let endpoint2 = Endpoint::builder().preset(presets::N0).bind().await?;
653+
let endpoint2 = Endpoint::builder().bind().await?;
657654
let conn = endpoint2.connect(addr1, crate::protocol::ALPN).await?;
658655
for size in sizes {
659656
let expected = test_data(size);
@@ -686,14 +683,14 @@ async fn node_smoke_mem() -> TestResult<()> {
686683
async fn node_smoke(store: &Store) -> TestResult<()> {
687684
let tt = store.add_bytes(b"hello world".to_vec()).temp_tag().await?;
688685
let hash = tt.hash();
689-
let endpoint = Endpoint::builder().preset(presets::N0).bind().await?;
686+
let endpoint = Endpoint::builder().bind().await?;
690687
let blobs = crate::net_protocol::BlobsProtocol::new(store, None);
691688
let r1 = Router::builder(endpoint)
692689
.accept(crate::protocol::ALPN, blobs)
693690
.spawn();
694691
let addr1 = r1.endpoint().addr();
695692
info!("node addr: {addr1:?}");
696-
let endpoint2 = Endpoint::builder().preset(presets::N0).bind().await?;
693+
let endpoint2 = Endpoint::builder().bind().await?;
697694
let conn = endpoint2.connect(addr1, crate::protocol::ALPN).await?;
698695
let (size, stats) = get::request::get_unverified_size(&conn, &hash).await?;
699696
info!("size: {} stats: {:?}", size, stats);

0 commit comments

Comments
 (0)