Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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-addr/page.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Endpoint Addresses

Endpoint Addresses or [`EndpointAddrs`](https://docs.rs/iroh/latest/iroh/struct.EndpointAddr.htm) are a common struct you'll interact when working with iroh to tell iroh what & where to dial. In rust they look like this:
Endpoint Addresses or [`EndpointAddrs`](https://docs.rs/iroh/latest/iroh/struct.EndpointAddr.html) are a common struct you'll interact when working with iroh to tell iroh what & where to dial. In rust they look like this:

```rust
pub struct Addr {
Expand All @@ -11,7 +11,7 @@ pub struct Addr {

You'll interact with `EndpointAddr`s a fair amount when working with iroh. It's also quite normal to construct addresses manually from, say, endpoint identifiers stored in your application database.

When we call [`connect`](https://docs.rs/iroh/latest/iroh/endpoint/struct.Endpoint.html#method.connect) on an [Endpoint](http://localhost:3000/docs/concepts/endpoint), we need to pass either a `EndpointAddr`, or something that can turn into a `EndpointAddr`. In iroh `Endpoint`s will have different fields populated depending on where they came from, and the discovery services you've configured your endpoint with.
When we call [`connect`](https://docs.rs/iroh/latest/iroh/endpoint/struct.Endpoint.html#method.connect) on an [Endpoint](https://www.iroh.computer/docs/concepts/endpoint), we need to pass either a `EndpointAddr`, or something that can turn into a `EndpointAddr`. In iroh `Endpoint`s will have different fields populated depending on where they came from, and the discovery services you've configured your endpoint with.

### Interaction with discovery
From the above struct, the only _required_ field is the `id`. And because of this, there's an implementation of `From` that can turn `EndpointIDs` directly into EndpointAddrs. _but this will only work if you have a discovery service that can resolve EndpointIDs enabled_. Thankfully, we enable discovery by default:
Expand Down
2 changes: 1 addition & 1 deletion src/app/docs/concepts/relay/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ number 0 provides a set of public relays that are free to use, and are configure

## Local Discovery

Relays aren't the only way to find other iroh endpoint. Iroh also supports local [discovery](/docs/concepts/discovery), where endpoints on the same local network can find each other & exchange dialing information without a relay using mDNS. This is useful for local networks, or for bootstrapping a network before a relay is available. For more info on configuring local discovery, see the [local discovery docs](https://docs.rs/iroh/latest/iroh/discovery/local_swarm_discovery/index.html).
Relays aren't the only way to find other iroh endpoint. Iroh also supports local [discovery](/docs/concepts/discovery), where endpoints on the same local network can find each other & exchange dialing information without a relay using mDNS. This is useful for local networks, or for bootstrapping a network before a relay is available. For more info on configuring local discovery, see the [local discovery docs](https://docs.rs/iroh/latest/iroh/discovery/mdns/index.html).
12 changes: 7 additions & 5 deletions src/app/docs/concepts/router/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ We use the term _router_ because it mimics what an HTTP server would do with an
use anyhow::Result;
use iroh::protocol::Router;
use iroh::Endpoint;
use iroh_blobs::net_protocol::Blobs;
use iroh_blobs::util::local_pool::LocalPool;
use iroh_blobs::{store::mem::MemStore,BlobsProtocol};


#[tokio::main]
async fn main() -> Result<()> {
// Build an endpoint, defaulting to the public n0 relay network
let endpoint = Endpoint::bind().await?;

// configure the blobs protocol to run in-memory
let blobs = Blobs::memory().build(&endpoint);
// We initialize an in-memory backing store for iroh-blobs
let store = MemStore::new();

// Then we initialize a struct that can accept blobs requests over iroh connections
let blobs = BlobsProtocol::new(&store,None);

// Build our router and add the blobs protocol,
// identified by its ALPN. Spawn the router to start listening.
Expand All @@ -30,7 +32,7 @@ async fn main() -> Result<()> {

// get our own address. At this point we have a running router
// that's ready to accept connections.
let addr = router.endpoint().addr().await?;
let addr = router.endpoint().addr();

// Wait for exit
tokio::signal::ctrl_c().await?;
Expand Down
Loading