You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/fetch-fsm.rs
+37-39Lines changed: 37 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -3,20 +3,19 @@
3
3
//! Since this example does not use [`iroh-net::Endpoint`], it does not do any holepunching, and so will only work locally or between two processes that have public IP addresses.
4
4
//!
5
5
//! Run the provide-bytes example first. It will give instructions on how to run this example properly.
6
-
use std::net::SocketAddr;
6
+
use std::str::FromStr;
7
7
8
8
use anyhow::{Context,Result};
9
9
use iroh_blobs::{
10
10
get::fsm::{AtInitial,ConnectedNext,EndBlobNext},
11
11
hashseq::HashSeq,
12
12
protocol::GetRequest,
13
-
Hash,
13
+
BlobFormat,
14
14
};
15
15
use iroh_io::ConcatenateSliceWriter;
16
16
use tracing_subscriber::{prelude::*,EnvFilter};
17
17
18
18
mod connect;
19
-
use connect::{load_certs, make_client_endpoint};
20
19
21
20
// set the RUST_LOG env var to one of {debug,info,warn} to see logging info
Copy file name to clipboardExpand all lines: examples/fetch-stream.rs
+35-37Lines changed: 35 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
//! Since this example does not use [`iroh-net::Endpoint`], it does not do any holepunching, and so will only work locally or between two processes that have public IP addresses.
4
4
//!
5
5
//! Run the provide-bytes example first. It will give instructions on how to run this example properly.
// create an endpoint to listen for incoming connections
74
-
let endpoint = make_server_endpoint(key, cert)?;
75
-
let addr = endpoint.local_addr()?;
76
-
println!("\nlistening on {addr}");
70
+
let endpoint = iroh::Endpoint::builder()
71
+
.relay_mode(iroh::RelayMode::Disabled)
72
+
.alpns(vec![connect::EXAMPLE_ALPN.into()])
73
+
.bind()
74
+
.await?;
75
+
let addr = endpoint.node_addr().await?;
76
+
println!("\nlistening on {:?}", addr.direct_addresses);
77
77
println!("providing hash {hash}");
78
78
79
-
println!("\nfetch the content using a finite state machine by running the following example:\n\ncargo run --example fetch-fsm {hash} \"{addr}\" {format}");
80
-
println!("\nfetch the content using a stream by running the following example:\n\ncargo run --example fetch-stream {hash} \"{addr}\" {format}\n");
79
+
let ticket = iroh_blobs::ticket::BlobTicket::new(addr, hash, format)?;
80
+
81
+
println!("\nfetch the content using a finite state machine by running the following example:\n\ncargo run --example fetch-fsm {ticket}");
82
+
println!("\nfetch the content using a stream by running the following example:\n\ncargo run --example fetch-stream {ticket}\n");
81
83
82
84
// create a new local pool handle with 1 worker thread
0 commit comments