Skip to content

Commit 411aa0b

Browse files
author
“ramfox”
committed
chore: remove git deps from deny, finish conversion to latest iroh api
1 parent 3da9930 commit 411aa0b

File tree

10 files changed

+116
-360
lines changed

10 files changed

+116
-360
lines changed

Cargo.lock

Lines changed: 77 additions & 306 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bytes = { version = "1", features = ["serde"] }
1818
derive_more = { version = "2.0.1", features = ["from", "try_from", "into", "debug", "display", "deref", "deref_mut"] }
1919
futures-lite = "2.6.0"
2020
quinn = { package = "iroh-quinn", version = "0.14.0" }
21-
n0-future = "0.2.0"
21+
n0-future = "0.3.0"
2222
n0-snafu = "0.2.2"
2323
range-collections = { version = "0.4.6", features = ["serde"] }
2424
smallvec = { version = "1", features = ["serde", "const_new"] }
@@ -36,11 +36,12 @@ chrono = "0.4.39"
3636
nested_enum_utils = "0.2.1"
3737
ref-cast = "1.0.24"
3838
arrayvec = "0.7.6"
39-
iroh = "0.93"
39+
iroh = "0.94"
4040
self_cell = "1.1.0"
4141
genawaiter = { version = "0.99.1", features = ["futures03"] }
42-
iroh-base = "0.93"
43-
irpc = { version = "0.9.0", features = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"], default-features = false }
42+
iroh-base = "0.94"
43+
iroh-tickets = "0.1"
44+
irpc = { version = "0.10.0", features = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"], default-features = false }
4445
iroh-metrics = { version = "0.36" }
4546
redb = { version = "2.6.3", optional = true }
4647
reflink-copy = { version = "0.1.24", optional = true }
@@ -59,7 +60,7 @@ tracing-subscriber = { version = "0.3.20", features = ["fmt"] }
5960
tracing-test = "0.2.5"
6061
walkdir = "2.5.0"
6162
atomic_refcell = "0.1.13"
62-
iroh = { version = "0.93", features = ["discovery-local-network"]}
63+
iroh = { version = "0.94", features = ["discovery-local-network"]}
6364
async-compression = { version = "0.4.30", features = ["lz4", "tokio"] }
6465
concat_const = "0.2.0"
6566

@@ -68,8 +69,3 @@ hide-proto-docs = []
6869
metrics = []
6970
default = ["hide-proto-docs", "fs-store"]
7071
fs-store = ["dep:redb", "dep:reflink-copy"]
71-
72-
[patch.crates-io]
73-
iroh = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }
74-
irpc = { git = "https://github.com/n0-computer/irpc.git", branch = "main" }
75-
iroh-base = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }

deny.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,3 @@ name = "ring"
3939
[[licenses.clarify.license-files]]
4040
hash = 3171872035
4141
path = "LICENSE"
42-
43-
[sources]
44-
allow-git = [
45-
"https://github.com/n0-computer/irpc.git",
46-
"https://github.com/n0-computer/iroh.git",
47-
]

examples/get-blob.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ async fn main() -> anyhow::Result<()> {
3737
ticket.format() == BlobFormat::Raw,
3838
"This example only supports raw blobs."
3939
);
40-
let connection = endpoint
41-
.connect(ticket.addr().endpoint_id, iroh_blobs::ALPN)
42-
.await?;
40+
let connection = endpoint.connect(ticket.addr().id, iroh_blobs::ALPN).await?;
4341
let mut progress = iroh_blobs::get::request::get_blob(connection, ticket.hash());
4442
let stats = if cli.progress {
4543
loop {

examples/random_store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use std::{env, path::PathBuf, str::FromStr};
33
use anyhow::{Context, Result};
44
use clap::{Parser, Subcommand};
55
use iroh::{discovery::static_provider::StaticProvider, SecretKey};
6-
use iroh_base::ticket::EndpointTicket;
76
use iroh_blobs::{
87
api::downloader::Shuffled,
98
provider::events::{AbortReason, EventMask, EventSender, ProviderMessage},
109
store::fs::FsStore,
1110
test::{add_hash_sequences, create_random_blobs},
1211
HashAndFormat,
1312
};
13+
use iroh_tickets::endpoint::EndpointTicket;
1414
use irpc::RpcMessage;
1515
use n0_future::StreamExt;
1616
use rand::{rngs::StdRng, Rng, SeedableRng};
@@ -277,7 +277,7 @@ async fn request(args: RequestArgs) -> anyhow::Result<()> {
277277
let nodes = args
278278
.nodes
279279
.iter()
280-
.map(|ticket| ticket.endpoint_addr().endpoint_id)
280+
.map(|ticket| ticket.endpoint_addr().id)
281281
.collect::<Vec<_>>();
282282
for content in args.content {
283283
let mut progress = downloader

examples/transfer-collection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl Node {
9494
/// retrieve an entire collection from a given hash and provider
9595
async fn get_collection(&self, hash: Hash, provider: EndpointAddr) -> Result<()> {
9696
let req = HashAndFormat::hash_seq(hash);
97-
let addrs = Shuffled::new(vec![provider.endpoint_id]);
97+
let addrs = Shuffled::new(vec![provider.id]);
9898
self.store
9999
.downloader(self.router.endpoint())
100100
.download(req, addrs)

examples/transfer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async fn main() -> anyhow::Result<()> {
6363
println!("Starting download.");
6464

6565
downloader
66-
.download(ticket.hash(), Some(ticket.addr().endpoint_id))
66+
.download(ticket.hash(), Some(ticket.addr().id))
6767
.await?;
6868

6969
println!("Finished download.");

src/api/downloader.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,9 @@ mod tests {
549549
let tt1 = store1.add_slice("hello world").await?;
550550
let tt2 = store2.add_slice("hello world 2").await?;
551551
let node1_addr = r1.endpoint().addr();
552-
let node1_id = node1_addr.endpoint_id;
552+
let node1_id = node1_addr.id;
553553
let node2_addr = r2.endpoint().addr();
554-
let node2_id = node2_addr.endpoint_id;
554+
let node2_id = node2_addr.id;
555555
let swarm = Downloader::new(&store3, r3.endpoint());
556556
sp3.add_endpoint_info(node1_addr.clone());
557557
sp3.add_endpoint_info(node2_addr.clone());
@@ -586,9 +586,9 @@ mod tests {
586586
})
587587
.await?;
588588
let node1_addr = r1.endpoint().addr();
589-
let node1_id = node1_addr.endpoint_id;
589+
let node1_id = node1_addr.id;
590590
let node2_addr = r2.endpoint().addr();
591-
let node2_id = node2_addr.endpoint_id;
591+
let node2_id = node2_addr.id;
592592
let swarm = Downloader::new(&store3, r3.endpoint());
593593
sp3.add_endpoint_info(node1_addr.clone());
594594
sp3.add_endpoint_info(node2_addr.clone());
@@ -653,9 +653,9 @@ mod tests {
653653
})
654654
.await?;
655655
let node1_addr = r1.endpoint().addr();
656-
let node1_id = node1_addr.endpoint_id;
656+
let node1_id = node1_addr.id;
657657
let node2_addr = r2.endpoint().addr();
658-
let node2_id = node2_addr.endpoint_id;
658+
let node2_id = node2_addr.id;
659659
let swarm = Downloader::new(&store3, r3.endpoint());
660660
sp3.add_endpoint_info(node1_addr.clone());
661661
sp3.add_endpoint_info(node2_addr.clone());

src/ticket.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{collections::BTreeSet, net::SocketAddr, str::FromStr};
33

44
use anyhow::Result;
55
use iroh::{EndpointAddr, EndpointId, RelayUrl};
6-
use iroh_base::ticket::{self, Ticket};
6+
use iroh_tickets::{ParseError, Ticket};
77
use serde::{Deserialize, Serialize};
88

99
use crate::{BlobFormat, Hash, HashAndFormat};
@@ -67,10 +67,10 @@ impl Ticket for BlobTicket {
6767
fn to_bytes(&self) -> Vec<u8> {
6868
let data = TicketWireFormat::Variant0(Variant0BlobTicket {
6969
node: Variant0NodeAddr {
70-
endpoint_id: self.addr.endpoint_id,
70+
endpoint_id: self.addr.id,
7171
info: Variant0AddrInfo {
72-
relay_url: self.addr.relay_url.clone(),
73-
direct_addresses: self.addr.direct_addresses.clone(),
72+
relay_url: self.addr.relay_urls().next().cloned(),
73+
direct_addresses: self.addr.ip_addrs().cloned().collect(),
7474
},
7575
},
7676
format: self.format,
@@ -79,23 +79,22 @@ impl Ticket for BlobTicket {
7979
postcard::to_stdvec(&data).expect("postcard serialization failed")
8080
}
8181

82-
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, ticket::ParseError> {
82+
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, ParseError> {
8383
let res: TicketWireFormat = postcard::from_bytes(bytes)?;
8484
let TicketWireFormat::Variant0(Variant0BlobTicket { node, format, hash }) = res;
85-
Ok(Self {
86-
addr: EndpointAddr {
87-
endpoint_id: node.endpoint_id,
88-
relay_url: node.info.relay_url,
89-
direct_addresses: node.info.direct_addresses,
90-
},
91-
format,
92-
hash,
93-
})
85+
let mut addr = EndpointAddr::new(node.endpoint_id);
86+
if let Some(relay_url) = node.info.relay_url {
87+
addr = addr.with_relay_url(relay_url);
88+
}
89+
for ip_addr in node.info.direct_addresses {
90+
addr = addr.with_ip_addr(ip_addr);
91+
}
92+
Ok(Self { addr, format, hash })
9493
}
9594
}
9695

9796
impl FromStr for BlobTicket {
98-
type Err = ticket::ParseError;
97+
type Err = ParseError;
9998

10099
fn from_str(s: &str) -> Result<Self, Self::Err> {
101100
Ticket::deserialize(s)
@@ -173,7 +172,7 @@ impl<'de> Deserialize<'de> for BlobTicket {
173172
mod tests {
174173
use std::net::SocketAddr;
175174

176-
use iroh::{PublicKey, SecretKey};
175+
use iroh::{PublicKey, SecretKey, TransportAddr};
177176
use iroh_test::{assert_eq_hex, hexdump::parse_hexdump};
178177

179178
use super::*;
@@ -182,10 +181,9 @@ mod tests {
182181
let hash = Hash::new(b"hi there");
183182
let peer = SecretKey::generate(&mut rand::rng()).public();
184183
let addr = SocketAddr::from_str("127.0.0.1:1234").unwrap();
185-
let relay_url = None;
186184
BlobTicket {
187185
hash,
188-
addr: EndpointAddr::from_parts(peer, relay_url, [addr]),
186+
addr: EndpointAddr::from_parts(peer, [TransportAddr::Ip(addr)]),
189187
format: BlobFormat::HashSeq,
190188
}
191189
}
@@ -211,12 +209,12 @@ mod tests {
211209
let hash =
212210
Hash::from_str("0b84d358e4c8be6c38626b2182ff575818ba6bd3f4b90464994be14cb354a072")
213211
.unwrap();
214-
let node_id =
212+
let endpoint_id =
215213
PublicKey::from_str("ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6")
216214
.unwrap();
217215

218216
let ticket = BlobTicket {
219-
addr: EndpointAddr::from_parts(node_id, None, []),
217+
addr: EndpointAddr::new(endpoint_id),
220218
format: BlobFormat::Raw,
221219
hash,
222220
};

src/util/connection_pool.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ mod tests {
545545
discovery::static_provider::StaticProvider,
546546
endpoint::{Connection, ConnectionType},
547547
protocol::{AcceptError, ProtocolHandler, Router},
548-
Endpoint, EndpointAddr, EndpointId, RelayMode, SecretKey, Watcher,
548+
Endpoint, EndpointAddr, EndpointId, RelayMode, SecretKey, TransportAddr, Watcher,
549549
};
550550
use n0_future::{io, stream, BufferedStreamExt, StreamExt};
551551
use n0_snafu::ResultExt;
@@ -616,7 +616,7 @@ mod tests {
616616
.await;
617617
let res: Vec<(EndpointAddr, Router)> = res.into_iter().collect::<TestResult<Vec<_>>>()?;
618618
let (addrs, routers): (Vec<_>, Vec<_>) = res.into_iter().unzip();
619-
let ids = addrs.iter().map(|a| a.endpoint_id).collect::<Vec<_>>();
619+
let ids = addrs.iter().map(|a| a.id).collect::<Vec<_>>();
620620
let discovery = StaticProvider::from_endpoint_info(addrs);
621621
Ok((ids, routers, discovery))
622622
}
@@ -679,9 +679,8 @@ mod tests {
679679
let non_listening = SecretKey::from_bytes(&[0; 32]).public();
680680
// make up fake node info
681681
discovery.add_endpoint_info(EndpointAddr {
682-
endpoint_id: non_listening,
683-
relay_url: None,
684-
direct_addresses: vec!["127.0.0.1:12121".parse().unwrap()]
682+
id: non_listening,
683+
addrs: vec![TransportAddr::Ip("127.0.0.1:12121".parse().unwrap())]
685684
.into_iter()
686685
.collect(),
687686
});

0 commit comments

Comments
 (0)