Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/docs/concepts/endpoint/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use iroh::Endpoint;

#[tokio::main]
async fn main() {
let endpoint = Endpoint::.bind().await.unwrap();
let endpoint = Endpoint::bind().await.unwrap();
// ...
}
```

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.
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.

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

Expand Down
6 changes: 3 additions & 3 deletions src/app/docs/tour/3-discovery/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ There are different implementations of the discovery service in iroh, the most p
Iroh endpoints come with some defaults that include using our public infrastructure to enable discovery:

```rust
use iroh::{Endpoint, RelayMode};
use iroh::Endpoint;

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

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

```rust
use iroh::{Endpoint, RelayMode, SecretKey};
use iroh::Endpoint;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/docs/tour/4-protocols/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Coming from the world of HTTP client/server models, protocols are kinda like req
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:

```
cargo add iroh-blobs --features=rpc
cargo add iroh-blobs
```

then adjust our code:
Expand Down
24 changes: 13 additions & 11 deletions src/app/docs/tour/5-routers/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@ Then we can setup gossip & add it to our router:

```rust
use iroh::{protocol::Router, Endpoint};
use iroh_blobs::net_protocol::Blobs;
use iroh_gossip::{net::Gossip, ALPN};
use iroh_blobs::{store::mem::MemStore, BlobsProtocol};
use iroh_gossip::Gossip;

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

let blobs = Blobs::memory().build(&endpoint);

let gossip = Gossip::builder().spawn(endpoint.clone()).await?;

// build the router
let store = MemStore::new();
let blobs = BlobsProtocol::new(&store,None);

let gossip = Gossip::builder().spawn(endpoint.clone());


//build the router
let router = Router::builder(endpoint)
.accept(iroh_blobs::ALPN, blobs.clone())
.accept(iroh_gossip::ALPN, gossip.clone())
.accept(iroh_blobs::ALPN, blobs)
.accept(iroh_gossip::ALPN, gossip)
.spawn();

router.shutdown().await?;

Ok(())
}
```
Expand Down
Loading