Skip to content

Commit ced7eaa

Browse files
refactor: Move iroh-router into iroh-net and rename iroh-net to iroh (#2973)
## Description <!-- A summary of what this pull request achieves and a rough list of changes. --> This merges `iroh-net`, `iroh-router` and `iroh` into simply one crate: `iroh`. Also adjusts README and documentation messages. ## Breaking Changes <!-- Optional, if there are any breaking changes document them, including how to migrate older code. --> - `iroh-net` got renamed to `iroh` - `iroh-router` moved into `iroh` - `iroh-router::ProtocolHandler` is now `iroh::protocol::ProtocolHandler` - `iroh-router::ProtocolMap` is now `iroh::protocol::ProtocolMap` - `iroh-router::Router` is now `iroh::router::Router` - `iroh-router::RouterBuilder` is now `iroh::router::RouterBuilder` ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> Minor Q: Do the `iroh::protocol` and `iroh::router` modules make sense? ## Change checklist - [ ] Fix "TODO(matheus23): docs" for `Router` etc. - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented. --------- Co-authored-by: dignifiedquire <[email protected]>
1 parent 2ae0409 commit ced7eaa

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iroh-node-util"
3-
description = "Utilities to build binaries containing an iroh-net endpoint"
3+
description = "Utilities to build binaries containing an iroh endpoint"
44
readme = "README.md"
55
license = "MIT OR Apache-2.0"
66
version = "0.28.0"
@@ -19,7 +19,7 @@ workspace = true
1919
anyhow = "1"
2020
clap = { version = "4", features = ["derive"], optional = true }
2121
tokio = "1"
22-
iroh-net = { path = "../iroh-net" }
22+
iroh = { path = "../iroh" }
2323
tempfile = "3"
2424
strum = "0.26"
2525
nested_enum_utils = "0.1.0"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# iroh-node-util
22

3-
This crate provides utilities to build binaries containing an iroh-net endpoint.
3+
This crate provides utilities to build binaries containing an iroh endpoint.
44

55
# License
66

src/cli/net.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use colored::Colorize;
77
use comfy_table::{presets::NOTHING, Cell, Table};
88
use futures_lite::{Stream, StreamExt};
99
use human_time::ToHumanTimeString;
10-
use iroh_net::{
10+
use iroh::{
1111
endpoint::{DirectAddrInfo, RemoteInfo},
1212
NodeAddr, NodeId, RelayUrl,
1313
};

src/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::path::PathBuf;
44

55
use anyhow::Context;
6-
use iroh_net::key::SecretKey;
6+
use iroh::key::SecretKey;
77
use tokio::io::AsyncWriteExt;
88

99
/// Loads a [`SecretKey`] from the provided file, or stores a newly generated one

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub mod fs;
1717
use std::path::PathBuf;
1818

1919
use anyhow::Context;
20-
use iroh_net::key::SecretKey;
20+
use iroh::key::SecretKey;
2121
use tokio::io::AsyncWriteExt;
2222

2323
/// Loads a [`SecretKey`] from the provided file, or stores a newly generated one

src/rpc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! RPC client, server and protocol to control iroh-net endpoints and iroh nodes
1+
//! RPC client, server and protocol to control iroh endpoints and iroh nodes
22
pub mod client;
33
pub mod proto;
44
pub mod server;

src/rpc/client/net.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::net::SocketAddr;
1111

1212
use anyhow::Result;
1313
use futures_lite::{Stream, StreamExt};
14-
use iroh_net::{endpoint::RemoteInfo, relay::RelayUrl, NodeAddr, NodeId};
14+
use iroh::{endpoint::RemoteInfo, relay::RelayUrl, NodeAddr, NodeId};
1515
use quic_rpc::RpcClient;
1616
use serde::{Deserialize, Serialize};
1717

@@ -49,47 +49,47 @@ impl Client {
4949
/// This streams a *current snapshot*. It does not keep the stream open after finishing
5050
/// transferring the snapshot.
5151
///
52-
/// See also [`Endpoint::remote_info_iter`](iroh_net::Endpoint::remote_info_iter).
52+
/// See also [`Endpoint::remote_info_iter`](iroh::Endpoint::remote_info_iter).
5353
pub async fn remote_info_iter(&self) -> Result<impl Stream<Item = Result<RemoteInfo>>> {
5454
let stream = self.rpc.server_streaming(RemoteInfosIterRequest {}).await?;
5555
Ok(flatten(stream).map(|res| res.map(|res| res.info)))
5656
}
5757

5858
/// Fetches node information about a remote iroh node identified by its [`NodeId`].
5959
///
60-
/// See also [`Endpoint::remote_info`](iroh_net::Endpoint::remote_info).
60+
/// See also [`Endpoint::remote_info`](iroh::Endpoint::remote_info).
6161
pub async fn remote_info(&self, node_id: NodeId) -> Result<Option<RemoteInfo>> {
6262
let RemoteInfoResponse { info } = self.rpc.rpc(RemoteInfoRequest { node_id }).await??;
6363
Ok(info)
6464
}
6565

6666
/// Fetches the node id of this node.
6767
///
68-
/// See also [`Endpoint::node_id`](iroh_net::Endpoint::node_id).
68+
/// See also [`Endpoint::node_id`](iroh::Endpoint::node_id).
6969
pub async fn node_id(&self) -> Result<NodeId> {
7070
let id = self.rpc.rpc(IdRequest).await??;
7171
Ok(id)
7272
}
7373

7474
/// Fetches the [`NodeAddr`] for this node.
7575
///
76-
/// See also [`Endpoint::node_addr`](iroh_net::Endpoint::node_addr).
76+
/// See also [`Endpoint::node_addr`](iroh::Endpoint::node_addr).
7777
pub async fn node_addr(&self) -> Result<NodeAddr> {
7878
let addr = self.rpc.rpc(AddrRequest).await??;
7979
Ok(addr)
8080
}
8181

8282
/// Adds a known node address to this node.
8383
///
84-
/// See also [`Endpoint::add_node_addr`](iroh_net::Endpoint::add_node_addr).
84+
/// See also [`Endpoint::add_node_addr`](iroh::Endpoint::add_node_addr).
8585
pub async fn add_node_addr(&self, addr: NodeAddr) -> Result<()> {
8686
self.rpc.rpc(AddAddrRequest { addr }).await??;
8787
Ok(())
8888
}
8989

9090
/// Returns the relay server we are connected to.
9191
///
92-
/// See also [`Endpoint::home_relay`](iroh_net::Endpoint::home_relay).
92+
/// See also [`Endpoint::home_relay`](iroh::Endpoint::home_relay).
9393
pub async fn home_relay(&self) -> Result<Option<RelayUrl>> {
9494
let relay = self.rpc.rpc(RelayRequest).await??;
9595
Ok(relay)

src/rpc/proto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! RPC protocol definitions for controlling iroh-net endpoints and iroh nodes
1+
//! RPC protocol definitions for controlling iroh endpoints and iroh nodes
22
use nested_enum_utils::enum_conversions;
33
use serde::{Deserialize, Serialize};
44

src/rpc/proto/net.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! RPC calls to control an iroh-net endpoint.
1+
//! RPC calls to control an iroh endpoint.
22
#![allow(missing_docs)]
3-
use iroh_net::{endpoint::RemoteInfo, key::PublicKey, relay::RelayUrl, NodeAddr, NodeId};
3+
use iroh::{endpoint::RemoteInfo, key::PublicKey, relay::RelayUrl, NodeAddr, NodeId};
44
use nested_enum_utils::enum_conversions;
55
use quic_rpc_derive::rpc_requests;
66
use serde::{Deserialize, Serialize};

src/rpc/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{collections::BTreeMap, net::SocketAddr, sync::Arc, time::Duration};
33

44
use anyhow::{anyhow, Result};
55
use futures_lite::{Stream, StreamExt};
6-
use iroh_net::{Endpoint, NodeAddr, NodeId, RelayUrl};
6+
use iroh::{Endpoint, NodeAddr, NodeId, RelayUrl};
77
use quic_rpc::server::{ChannelTypes, RpcChannel, RpcServerError};
88
use tracing::{debug, info};
99

0 commit comments

Comments
 (0)