Skip to content

Commit 75153a1

Browse files
committed
Remove last .discovery_n0() calls.
1 parent de55d99 commit 75153a1

File tree

8 files changed

+38
-26
lines changed

8 files changed

+38
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ 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();

examples/get-blob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ 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?;

examples/mdns-discovery.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async fn accept(path: &Path) -> Result<()> {
6060

6161
println!("Starting iroh node with mdns discovery...");
6262
// create a new node
63-
let endpoint = Endpoint::builder()
63+
let endpoint = Endpoint::empty_builder(RelayMode::Default)
6464
.secret_key(key)
6565
.discovery(MdnsDiscovery::builder())
6666
.relay_mode(RelayMode::Disabled)
@@ -93,10 +93,9 @@ async fn connect(node_id: PublicKey, hash: Hash, out: Option<PathBuf>) -> Result
9393

9494
println!("Starting iroh node with mdns discovery...");
9595
// create a new node
96-
let endpoint = Endpoint::builder()
96+
let endpoint = Endpoint::empty_builder(RelayMode::Disabled)
9797
.secret_key(key)
9898
.discovery(discovery)
99-
.relay_mode(RelayMode::Disabled)
10099
.bind()
101100
.await?;
102101
let store = MemStore::new();

examples/transfer-collection.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
use std::collections::HashMap;
99

1010
use anyhow::{Context, Result};
11-
use iroh::{discovery::static_provider::StaticProvider, protocol::Router, Endpoint, EndpointAddr};
11+
use iroh::{
12+
discovery::static_provider::StaticProvider, protocol::Router, Endpoint, EndpointAddr, RelayMode,
13+
};
1214
use iroh_blobs::{
1315
api::{downloader::Shuffled, Store, TempTag},
1416
format::collection::Collection,
@@ -27,7 +29,10 @@ struct Node {
2729

2830
impl Node {
2931
async fn new(disc: &StaticProvider) -> Result<Self> {
30-
let endpoint = Endpoint::builder().discovery(disc.clone()).bind().await?;
32+
let endpoint = Endpoint::empty_builder(RelayMode::Default)
33+
.discovery(disc.clone())
34+
.bind()
35+
.await?;
3136

3237
let store = MemStore::new();
3338

@@ -102,7 +107,7 @@ impl Node {
102107
async fn main() -> anyhow::Result<()> {
103108
// create a local provider for nodes to discover each other.
104109
// outside of a development environment, production apps would
105-
// use `Endpoint::builder().discovery_n0()` or a similar method
110+
// use `Endpoint::bind()` or a similar method
106111
let disc = StaticProvider::new();
107112

108113
// create a sending node

examples/transfer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use iroh_blobs::{store::mem::MemStore, ticket::BlobTicket, BlobsProtocol};
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().bind().await?;
10+
let endpoint = Endpoint::bind().await?;
1111

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

src/net_protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! let t = store.add_slice(b"hello world").await?;
1717
//!
1818
//! // create an iroh endpoint
19-
//! let endpoint = Endpoint::builder().discovery_n0().bind().await?;
19+
//! let endpoint = Endpoint::bind().await?;
2020
//! endpoint.online().await;
2121
//! let addr = endpoint.node_addr();
2222
//!

src/tests.rs

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

33
use bao_tree::ChunkRanges;
44
use bytes::Bytes;
5-
use iroh::{discovery::static_provider::StaticProvider, protocol::Router, Endpoint, EndpointId};
5+
use iroh::{
6+
discovery::static_provider::StaticProvider, protocol::Router, Endpoint, EndpointId, RelayMode,
7+
};
68
use irpc::RpcMessage;
79
use n0_future::{task::AbortOnDropHandle, StreamExt};
810
use tempfile::TempDir;
@@ -500,7 +502,10 @@ pub async fn node_test_setup_with_events_fs(
500502
) -> TestResult<(Router, FsStore, PathBuf, StaticProvider)> {
501503
let store = crate::store::fs::FsStore::load(&db_path).await?;
502504
let sp = StaticProvider::new();
503-
let ep = Endpoint::builder().discovery(sp.clone()).bind().await?;
505+
let ep = Endpoint::empty_builder(RelayMode::Default)
506+
.discovery(sp.clone())
507+
.bind()
508+
.await?;
504509
let blobs = BlobsProtocol::new(&store, Some(events));
505510
let router = Router::builder(ep).accept(crate::ALPN, blobs).spawn();
506511
Ok((router, store, db_path, sp))
@@ -515,7 +520,10 @@ pub async fn node_test_setup_with_events_mem(
515520
) -> TestResult<(Router, MemStore, StaticProvider)> {
516521
let store = MemStore::new();
517522
let sp = StaticProvider::new();
518-
let ep = Endpoint::builder().discovery(sp.clone()).bind().await?;
523+
let ep = Endpoint::empty_builder(RelayMode::Default)
524+
.discovery(sp.clone())
525+
.bind()
526+
.await?;
519527
let blobs = BlobsProtocol::new(&store, Some(events));
520528
let router = Router::builder(ep).accept(crate::ALPN, blobs).spawn();
521529
Ok((router, store, sp))
@@ -612,14 +620,14 @@ async fn node_serve_hash_seq() -> TestResult<()> {
612620
let hash_seq = tts.iter().map(|x| x.hash).collect::<HashSeq>();
613621
let root_tt = store.add_bytes(hash_seq).await?;
614622
let root = root_tt.hash;
615-
let endpoint = Endpoint::builder().bind().await?;
623+
let endpoint = Endpoint::bind().await?;
616624
let blobs = crate::net_protocol::BlobsProtocol::new(&store, None);
617625
let r1 = Router::builder(endpoint)
618626
.accept(crate::protocol::ALPN, blobs)
619627
.spawn();
620628
let addr1 = r1.endpoint().addr();
621629
info!("node addr: {addr1:?}");
622-
let endpoint2 = Endpoint::builder().bind().await?;
630+
let endpoint2 = Endpoint::bind().await?;
623631
let conn = endpoint2.connect(addr1, crate::protocol::ALPN).await?;
624632
let (hs, sizes) = get::request::get_hash_seq_and_sizes(&conn, &root, 1024, None).await?;
625633
println!("hash seq: {hs:?}");
@@ -643,14 +651,14 @@ async fn node_serve_blobs() -> TestResult<()> {
643651
for size in sizes {
644652
tts.push(store.add_bytes(test_data(size)).await?);
645653
}
646-
let endpoint = Endpoint::builder().bind().await?;
654+
let endpoint = Endpoint::bind().await?;
647655
let blobs = crate::net_protocol::BlobsProtocol::new(&store, None);
648656
let r1 = Router::builder(endpoint)
649657
.accept(crate::protocol::ALPN, blobs)
650658
.spawn();
651659
let addr1 = r1.endpoint().addr();
652660
info!("node addr: {addr1:?}");
653-
let endpoint2 = Endpoint::builder().bind().await?;
661+
let endpoint2 = Endpoint::bind().await?;
654662
let conn = endpoint2.connect(addr1, crate::protocol::ALPN).await?;
655663
for size in sizes {
656664
let expected = test_data(size);
@@ -683,14 +691,14 @@ async fn node_smoke_mem() -> TestResult<()> {
683691
async fn node_smoke(store: &Store) -> TestResult<()> {
684692
let tt = store.add_bytes(b"hello world".to_vec()).temp_tag().await?;
685693
let hash = tt.hash();
686-
let endpoint = Endpoint::builder().bind().await?;
694+
let endpoint = Endpoint::bind().await?;
687695
let blobs = crate::net_protocol::BlobsProtocol::new(store, None);
688696
let r1 = Router::builder(endpoint)
689697
.accept(crate::protocol::ALPN, blobs)
690698
.spawn();
691699
let addr1 = r1.endpoint().addr();
692700
info!("node addr: {addr1:?}");
693-
let endpoint2 = Endpoint::builder().bind().await?;
701+
let endpoint2 = Endpoint::bind().await?;
694702
let conn = endpoint2.connect(addr1, crate::protocol::ALPN).await?;
695703
let (size, stats) = get::request::get_unverified_size(&conn, &hash).await?;
696704
info!("size: {} stats: {:?}", size, stats);

src/util/connection_pool.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ mod tests {
545545
discovery::static_provider::StaticProvider,
546546
endpoint::{Connection, ConnectionType},
547547
protocol::{AcceptError, ProtocolHandler, Router},
548-
Endpoint, EndpointAddr, EndpointId, SecretKey, Watcher,
548+
Endpoint, EndpointAddr, EndpointId, RelayMode, SecretKey, Watcher,
549549
};
550550
use n0_future::{io, stream, BufferedStreamExt, StreamExt};
551551
use n0_snafu::ResultExt;
@@ -662,7 +662,7 @@ mod tests {
662662
async fn connection_pool_errors() -> TestResult<()> {
663663
// set up static discovery for all addrs
664664
let discovery = StaticProvider::new();
665-
let endpoint = iroh::Endpoint::builder()
665+
let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default)
666666
.discovery(discovery.clone())
667667
.bind()
668668
.await?;
@@ -699,7 +699,7 @@ mod tests {
699699
let n = 32;
700700
let (ids, routers, discovery) = echo_servers(n).await?;
701701
// build a client endpoint that can resolve all the endpoint ids
702-
let endpoint = iroh::Endpoint::builder()
702+
let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default)
703703
.discovery(discovery.clone())
704704
.bind()
705705
.await?;
@@ -734,7 +734,7 @@ mod tests {
734734
let n = 32;
735735
let (ids, routers, discovery) = echo_servers(n).await?;
736736
// build a client endpoint that can resolve all the endpoint ids
737-
let endpoint = iroh::Endpoint::builder()
737+
let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default)
738738
.discovery(discovery.clone())
739739
.bind()
740740
.await?;
@@ -765,7 +765,7 @@ mod tests {
765765
async fn on_connected_error() -> TestResult<()> {
766766
let n = 1;
767767
let (ids, routers, discovery) = echo_servers(n).await?;
768-
let endpoint = iroh::Endpoint::builder()
768+
let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default)
769769
.discovery(discovery)
770770
.bind()
771771
.await?;
@@ -795,7 +795,7 @@ mod tests {
795795
async fn on_connected_direct() -> TestResult<()> {
796796
let n = 1;
797797
let (ids, routers, discovery) = echo_servers(n).await?;
798-
let endpoint = iroh::Endpoint::builder()
798+
let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default)
799799
.discovery(discovery)
800800
.bind()
801801
.await?;
@@ -838,7 +838,7 @@ mod tests {
838838
async fn watch_close() -> TestResult<()> {
839839
let n = 1;
840840
let (ids, routers, discovery) = echo_servers(n).await?;
841-
let endpoint = iroh::Endpoint::builder()
841+
let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default)
842842
.discovery(discovery)
843843
.bind()
844844
.await?;

0 commit comments

Comments
 (0)