Skip to content

Commit fbd7e12

Browse files
Anonymous-AAAb5
andauthored
Update code examples and fix typo (#410)
* Update code and typo * update typo * update docs * Update src/app/docs/tour/5-routers/page.mdx Co-authored-by: Brendan O'Brien <[email protected]> * fix spaces --------- Co-authored-by: Brendan O'Brien <[email protected]>
1 parent 7d70ff0 commit fbd7e12

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/app/docs/concepts/endpoint/page.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use iroh::Endpoint;
1111

1212
#[tokio::main]
1313
async fn main() {
14-
let endpoint = Endpoint::.bind().await.unwrap();
14+
let endpoint = Endpoint::bind().await.unwrap();
1515
// ...
1616
}
1717
```
1818

19-
Breaking that down the `builder` sets up configuration for the endpoint, and `bind` creates the endpoint and starts listening for incoming connections. The `await` keyword is used to wait for the endpoint to be created in an asynchronous context.
19+
Breaking that down, `bind` creates the endpoint and starts listening for incoming connections, while the `await` keyword is used to wait for the endpoint to be created in an asynchronous context.
2020

2121
Once you have an endpoint, you can use it to create connections to other endpoints, or accept incoming connections from other endpoints.
2222

src/app/docs/tour/3-discovery/page.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ There are different implementations of the discovery service in iroh, the most p
1111
Iroh endpoints come with some defaults that include using our public infrastructure to enable discovery:
1212

1313
```rust
14-
use iroh::{Endpoint, RelayMode};
14+
use iroh::Endpoint;
1515

1616
#[tokio::main]
1717
async fn main() -> anyhow::Result<()> {
18-
let builder = Endpoint::.bind().await?;
18+
let endpoint = Endpoint::bind().await?;
1919

2020
println!("endpoint id: {:?}", endpoint.id());
2121
Ok(())
@@ -45,7 +45,7 @@ tokio = "1.43.0"
4545
And with that we can set up local discovery, alongside our default discovery:
4646

4747
```rust
48-
use iroh::{Endpoint, RelayMode, SecretKey};
48+
use iroh::Endpoint;
4949

5050
#[tokio::main]
5151
async fn main() -> anyhow::Result<()> {

src/app/docs/tour/4-protocols/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Coming from the world of HTTP client/server models, protocols are kinda like req
1111
Protocols are an ever-growing topic, but to give you a basic idea, let's add the [blobs](/proto/iroh-blobs) protocol. First we need to add it to our dependencies:
1212

1313
```
14-
cargo add iroh-blobs --features=rpc
14+
cargo add iroh-blobs
1515
```
1616

1717
then adjust our code:

src/app/docs/tour/5-routers/page.mdx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,26 @@ Then we can setup gossip & add it to our router:
1414

1515
```rust
1616
use iroh::{protocol::Router, Endpoint};
17-
use iroh_blobs::net_protocol::Blobs;
18-
use iroh_gossip::{net::Gossip, ALPN};
17+
use iroh_blobs::{store::mem::MemStore, BlobsProtocol};
18+
use iroh_gossip::Gossip;
1919

2020
#[tokio::main]
2121
async fn main() -> anyhow::Result<()> {
2222
let endpoint = Endpoint::bind().await?;
23-
24-
let blobs = Blobs::memory().build(&endpoint);
25-
26-
let gossip = Gossip::builder().spawn(endpoint.clone()).await?;
27-
28-
// build the router
23+
let store = MemStore::new();
24+
let blobs = BlobsProtocol::new(&store,None);
25+
26+
let gossip = Gossip::builder().spawn(endpoint.clone());
27+
28+
29+
//build the router
2930
let router = Router::builder(endpoint)
30-
.accept(iroh_blobs::ALPN, blobs.clone())
31-
.accept(iroh_gossip::ALPN, gossip.clone())
31+
.accept(iroh_blobs::ALPN, blobs)
32+
.accept(iroh_gossip::ALPN, gossip)
3233
.spawn();
33-
34+
3435
router.shutdown().await?;
36+
3537
Ok(())
3638
}
3739
```

0 commit comments

Comments
 (0)