diff --git a/content-discovery/Cargo.toml b/content-discovery/Cargo.toml index 57e24aa..fe2e191 100644 --- a/content-discovery/Cargo.toml +++ b/content-discovery/Cargo.toml @@ -26,6 +26,5 @@ missing_debug_implementations = "warn" unused-async = "warn" [workspace.dependencies] -iroh-net = "0.28" -iroh-blobs = "0.28" -iroh-base = "0.28" +iroh = "0.29" +iroh-blobs = "0.29" diff --git a/content-discovery/iroh-mainline-content-discovery-cli/Cargo.toml b/content-discovery/iroh-mainline-content-discovery-cli/Cargo.toml index 2a20c59..a5cf3c6 100644 --- a/content-discovery/iroh-mainline-content-discovery-cli/Cargo.toml +++ b/content-discovery/iroh-mainline-content-discovery-cli/Cargo.toml @@ -8,9 +8,8 @@ license = "MIT OR Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -iroh-net = { workspace = true } +iroh = { workspace = true } iroh-blobs = { workspace = true } -iroh-base = { workspace = true } iroh-mainline-content-discovery = { path = "../iroh-mainline-content-discovery" } mainline = { version = "2.0.0" } anyhow = { version = "1", features = ["backtrace"] } diff --git a/content-discovery/iroh-mainline-content-discovery-cli/src/args.rs b/content-discovery/iroh-mainline-content-discovery-cli/src/args.rs index 2288d2c..fe15190 100644 --- a/content-discovery/iroh-mainline-content-discovery-cli/src/args.rs +++ b/content-discovery/iroh-mainline-content-discovery-cli/src/args.rs @@ -1,8 +1,7 @@ //! Command line arguments. use clap::{Parser, Subcommand}; -use iroh_base::ticket::BlobTicket; +use iroh::{ticket::BlobTicket, NodeId}; use iroh_blobs::{Hash, HashAndFormat}; -use iroh_net::NodeId; use std::{ fmt::Display, net::{SocketAddr, SocketAddrV4}, diff --git a/content-discovery/iroh-mainline-content-discovery-cli/src/main.rs b/content-discovery/iroh-mainline-content-discovery-cli/src/main.rs index 117b457..40aa37e 100644 --- a/content-discovery/iroh-mainline-content-discovery-cli/src/main.rs +++ b/content-discovery/iroh-mainline-content-discovery-cli/src/main.rs @@ -5,17 +5,15 @@ use std::{ str::FromStr, }; -use anyhow::Context; use args::QueryDhtArgs; use clap::Parser; use futures::StreamExt; +use iroh::endpoint; use iroh_mainline_content_discovery::{ create_quinn_client, protocol::{AbsoluteTime, Announce, AnnounceKind, Query, QueryFlags, SignedAnnounce}, to_infohash, UdpDiscovery, }; -use iroh_net::endpoint; -use tokio::io::AsyncWriteExt; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; use crate::args::{AnnounceArgs, Args, Commands, QueryArgs}; @@ -26,7 +24,7 @@ async fn announce(args: AnnounceArgs) -> anyhow::Result<()> { eprintln!("ANNOUNCE_SECRET environment variable must be set to a valid secret key"); anyhow::bail!("ANNOUNCE_SECRET env var not set"); }; - let Ok(key) = iroh_net::key::SecretKey::from_str(&key) else { + let Ok(key) = iroh::key::SecretKey::from_str(&key) else { anyhow::bail!("ANNOUNCE_SECRET env var is not a valid secret key"); }; let content = args.content.hash_and_format(); @@ -165,43 +163,3 @@ async fn main() -> anyhow::Result<()> { Commands::QueryDht(args) => query_dht(args).await, } } - -/// Loads a [`SecretKey`] from the provided file. -pub async fn load_secret_key( - key_path: std::path::PathBuf, -) -> anyhow::Result { - if key_path.exists() { - let keystr = tokio::fs::read(key_path).await?; - let secret_key = - iroh_net::key::SecretKey::try_from_openssh(keystr).context("invalid keyfile")?; - Ok(secret_key) - } else { - let secret_key = iroh_net::key::SecretKey::generate(); - let ser_key = secret_key.to_openssh()?; - - // Try to canoncialize if possible - let key_path = key_path.canonicalize().unwrap_or(key_path); - let key_path_parent = key_path.parent().ok_or_else(|| { - anyhow::anyhow!("no parent directory found for '{}'", key_path.display()) - })?; - tokio::fs::create_dir_all(&key_path_parent).await?; - - // write to tempfile - let (file, temp_file_path) = tempfile::NamedTempFile::new_in(key_path_parent) - .context("unable to create tempfile")? - .into_parts(); - let mut file = tokio::fs::File::from_std(file); - file.write_all(ser_key.as_bytes()) - .await - .context("unable to write keyfile")?; - file.flush().await?; - drop(file); - - // move file - tokio::fs::rename(temp_file_path, key_path) - .await - .context("failed to rename keyfile")?; - - Ok(secret_key) - } -} diff --git a/content-discovery/iroh-mainline-content-discovery/Cargo.toml b/content-discovery/iroh-mainline-content-discovery/Cargo.toml index 0a01d88..9d34d5b 100644 --- a/content-discovery/iroh-mainline-content-discovery/Cargo.toml +++ b/content-discovery/iroh-mainline-content-discovery/Cargo.toml @@ -11,7 +11,7 @@ license = "MIT OR Apache-2.0" # Required features for the protocol types. # # The protocol is using postcard, but we don't need a postcard dependency for just the type definitions -iroh-net = { workspace = true } +iroh = { workspace = true } iroh-blobs = { workspace = true } serde = { version = "1", features = ["derive"] } derive_more = { version = "1.0.0-beta.1", features = ["debug", "display", "from", "try_into"] } diff --git a/content-discovery/iroh-mainline-content-discovery/src/client.rs b/content-discovery/iroh-mainline-content-discovery/src/client.rs index 6ebcc75..fd82d64 100644 --- a/content-discovery/iroh-mainline-content-discovery/src/client.rs +++ b/content-discovery/iroh-mainline-content-discovery/src/client.rs @@ -14,11 +14,11 @@ use futures::{ stream::FusedStream, FutureExt, Stream, StreamExt, }; -use iroh_blobs::HashAndFormat; -use iroh_net::{ +use iroh::{ discovery::{dns::DnsDiscovery, pkarr::PkarrPublisher, Discovery}, Endpoint, NodeId, }; +use iroh_blobs::HashAndFormat; use crate::protocol::{ AnnounceKind, Query, QueryResponse, Request, Response, SignedAnnounce, ALPN, REQUEST_SIZE_LIMIT, @@ -33,7 +33,7 @@ use crate::protocol::{ /// `content` is the content to announce. /// `kind` is the kind of the announcement. We can claim to have the complete data or only some of it. pub async fn announce( - connection: iroh_net::endpoint::Connection, + connection: iroh::endpoint::Connection, signed_announce: SignedAnnounce, ) -> anyhow::Result<()> { let (mut send, mut recv) = connection.open_bi().await?; @@ -186,7 +186,7 @@ pub fn announce_dht( /// Assume an existing connection to a tracker and query it for peers for some content. pub async fn query( - connection: iroh_net::endpoint::Connection, + connection: iroh::endpoint::Connection, args: Query, ) -> anyhow::Result { tracing::info!("connected to {:?}", connection.remote_address()); @@ -210,9 +210,9 @@ pub fn create_quinn_client( alpn_protocols: Vec>, keylog: bool, ) -> anyhow::Result { - let secret_key = iroh_net::key::SecretKey::generate(); + let secret_key = iroh::key::SecretKey::generate(); let tls_client_config = - iroh_net::tls::make_client_config(&secret_key, None, alpn_protocols, keylog)?; + iroh::tls::make_client_config(&secret_key, None, alpn_protocols, keylog)?; let mut client_config = iroh_quinn::ClientConfig::new(Arc::new(tls_client_config)); let mut endpoint = iroh_quinn::Endpoint::client(bind_addr)?; let mut transport_config = iroh_quinn::TransportConfig::default(); @@ -223,7 +223,7 @@ pub fn create_quinn_client( } async fn create_endpoint( - key: iroh_net::key::SecretKey, + key: iroh::key::SecretKey, ipv4_addr: SocketAddrV4, ipv6_addr: SocketAddrV6, publish: bool, @@ -233,7 +233,7 @@ async fn create_endpoint( } else { Box::new(DnsDiscovery::n0_dns()) }; - iroh_net::Endpoint::builder() + iroh::Endpoint::builder() .secret_key(key) .discovery(mainline_discovery) .alpns(vec![ALPN.to_vec()]) @@ -284,7 +284,7 @@ pub async fn connect( tracker: &TrackerId, local_ipv4_addr: SocketAddrV4, local_ipv6_addr: SocketAddrV6, -) -> anyhow::Result { +) -> anyhow::Result { match tracker { TrackerId::Quinn(tracker) => connect_socket(*tracker, local_ipv4_addr.into()).await, TrackerId::Iroh(tracker) => connect_iroh(*tracker, local_ipv4_addr, local_ipv6_addr).await, @@ -297,11 +297,11 @@ async fn connect_iroh( tracker: NodeId, local_ipv4_addr: SocketAddrV4, local_ipv6_addr: SocketAddrV6, -) -> anyhow::Result { +) -> anyhow::Result { // todo: uncomment once the connection problems are fixed // for now, a random node id is more reliable. // let key = load_secret_key(tracker_path(CLIENT_KEY)?).await?; - let key = iroh_net::key::SecretKey::generate(); + let key = iroh::key::SecretKey::generate(); let endpoint = create_endpoint(key, local_ipv4_addr, local_ipv6_addr, false).await?; tracing::info!("trying to connect to tracker at {:?}", tracker); let connection = endpoint.connect(tracker, ALPN).await?; @@ -312,7 +312,7 @@ async fn connect_iroh( async fn connect_socket( tracker: SocketAddr, local_addr: SocketAddr, -) -> anyhow::Result { +) -> anyhow::Result { let endpoint = create_quinn_client(local_addr, vec![ALPN.to_vec()], false)?; tracing::info!("trying to connect to tracker at {:?}", tracker); let connection = endpoint.connect(tracker, "localhost")?.await?; diff --git a/content-discovery/iroh-mainline-content-discovery/src/protocol.rs b/content-discovery/iroh-mainline-content-discovery/src/protocol.rs index 0cb27c8..a6fa2d9 100644 --- a/content-discovery/iroh-mainline-content-discovery/src/protocol.rs +++ b/content-discovery/iroh-mainline-content-discovery/src/protocol.rs @@ -4,8 +4,8 @@ use std::{ time::{Duration, SystemTime}, }; +use iroh::NodeId; use iroh_blobs::HashAndFormat; -use iroh_net::NodeId; use serde::{Deserialize, Serialize}; use serde_big_array::BigArray; @@ -118,7 +118,7 @@ impl Deref for SignedAnnounce { impl SignedAnnounce { /// Create a new signed announce. - pub fn new(announce: Announce, secret_key: &iroh_net::key::SecretKey) -> anyhow::Result { + pub fn new(announce: Announce, secret_key: &iroh::key::SecretKey) -> anyhow::Result { let announce_bytes = postcard::to_allocvec(&announce)?; let signature = secret_key.sign(&announce_bytes).to_bytes(); Ok(Self { @@ -130,7 +130,7 @@ impl SignedAnnounce { /// Verify the announce, and return the announce if it's valid. pub fn verify(&self) -> anyhow::Result<()> { let announce_bytes = postcard::to_allocvec(&self.announce)?; - let signature = iroh_net::key::Signature::from_bytes(&self.signature); + let signature = iroh::key::Signature::from_bytes(&self.signature); self.announce.host.verify(&announce_bytes, &signature)?; Ok(()) } diff --git a/content-discovery/iroh-mainline-tracker/Cargo.toml b/content-discovery/iroh-mainline-tracker/Cargo.toml index ac8ba8c..6641751 100644 --- a/content-discovery/iroh-mainline-tracker/Cargo.toml +++ b/content-discovery/iroh-mainline-tracker/Cargo.toml @@ -18,7 +18,7 @@ ed25519-dalek = "2.1.0" futures = "0.3.25" hex = "0.4.3" humantime = "2.1.0" -iroh-net = { workspace = true } +iroh = { workspace = true } iroh-blobs = { workspace = true } mainline = { version = "2.0.0", features = ["async"] } pkarr = { version = "1.0.1", features = ["async"] } diff --git a/content-discovery/iroh-mainline-tracker/src/io.rs b/content-discovery/iroh-mainline-tracker/src/io.rs index 27dcfb3..36b0fbc 100644 --- a/content-discovery/iroh-mainline-tracker/src/io.rs +++ b/content-discovery/iroh-mainline-tracker/src/io.rs @@ -8,9 +8,9 @@ use std::{ }; use anyhow::Context; +use iroh::NodeId; use iroh_blobs::{get::Stats, HashAndFormat}; use iroh_mainline_content_discovery::protocol::{AnnounceKind, SignedAnnounce}; -use iroh_net::NodeId; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use tracing_subscriber::{prelude::*, EnvFilter}; diff --git a/content-discovery/iroh-mainline-tracker/src/main.rs b/content-discovery/iroh-mainline-tracker/src/main.rs index e14cc6b..1b32fc8 100644 --- a/content-discovery/iroh-mainline-tracker/src/main.rs +++ b/content-discovery/iroh-mainline-tracker/src/main.rs @@ -9,8 +9,9 @@ use std::{ time::{Duration, Instant}, }; -use anyhow::Context; use clap::Parser; +use iroh::{discovery::pkarr::dht::DhtDiscovery, endpoint::get_remote_node_id, Endpoint, NodeId}; +use iroh_blobs::util::fs::load_secret_key; use iroh_mainline_content_discovery::protocol::ALPN; use iroh_mainline_tracker::{ io::{ @@ -20,11 +21,6 @@ use iroh_mainline_tracker::{ options::Options, tracker::Tracker, }; -use iroh_net::{ - discovery::pkarr::dht::DhtDiscovery, endpoint::get_remote_node_id, Endpoint, NodeId, -}; - -use tokio::io::AsyncWriteExt; use crate::args::Args; @@ -66,7 +62,7 @@ async fn await_relay_region(endpoint: &Endpoint) -> anyhow::Result<()> { } async fn create_endpoint( - key: iroh_net::key::SecretKey, + key: iroh::key::SecretKey, ipv4_addr: SocketAddrV4, publish: bool, ) -> anyhow::Result { @@ -75,7 +71,7 @@ async fn create_endpoint( } else { DhtDiscovery::default() }; - iroh_net::Endpoint::builder() + iroh::Endpoint::builder() .secret_key(key) .discovery(Box::new(mainline_discovery)) .alpns(vec![ALPN.to_vec()]) @@ -191,20 +187,18 @@ async fn main() -> anyhow::Result<()> { /// Returns default server configuration along with its certificate. #[allow(clippy::field_reassign_with_default)] // https://github.com/rust-lang/rust-clippy/issues/6527 -fn configure_server( - secret_key: &iroh_net::key::SecretKey, -) -> anyhow::Result { +fn configure_server(secret_key: &iroh::key::SecretKey) -> anyhow::Result { make_server_config(secret_key, 8, 1024, vec![ALPN.to_vec()]) } /// Create a [`quinn::ServerConfig`] with the given secret key and limits. pub fn make_server_config( - secret_key: &iroh_net::key::SecretKey, + secret_key: &iroh::key::SecretKey, max_streams: u64, max_connections: u32, alpn_protocols: Vec>, ) -> anyhow::Result { - let tls_server_config = iroh_net::tls::make_server_config(secret_key, alpn_protocols, false)?; + let tls_server_config = iroh::tls::make_server_config(secret_key, alpn_protocols, false)?; let mut server_config = iroh_quinn::ServerConfig::with_crypto(Arc::new(tls_server_config)); let mut transport_config = iroh_quinn::TransportConfig::default(); transport_config @@ -216,43 +210,3 @@ pub fn make_server_config( .max_incoming(max_connections as usize); Ok(server_config) } - -/// Loads a [`SecretKey`] from the provided file. -pub async fn load_secret_key( - key_path: std::path::PathBuf, -) -> anyhow::Result { - if key_path.exists() { - let keystr = tokio::fs::read(key_path).await?; - let secret_key = - iroh_net::key::SecretKey::try_from_openssh(keystr).context("invalid keyfile")?; - Ok(secret_key) - } else { - let secret_key = iroh_net::key::SecretKey::generate(); - let ser_key = secret_key.to_openssh()?; - - // Try to canoncialize if possible - let key_path = key_path.canonicalize().unwrap_or(key_path); - let key_path_parent = key_path.parent().ok_or_else(|| { - anyhow::anyhow!("no parent directory found for '{}'", key_path.display()) - })?; - tokio::fs::create_dir_all(&key_path_parent).await?; - - // write to tempfile - let (file, temp_file_path) = tempfile::NamedTempFile::new_in(key_path_parent) - .context("unable to create tempfile")? - .into_parts(); - let mut file = tokio::fs::File::from_std(file); - file.write_all(ser_key.as_bytes()) - .await - .context("unable to write keyfile")?; - file.flush().await?; - drop(file); - - // move file - tokio::fs::rename(temp_file_path, key_path) - .await - .context("failed to rename keyfile")?; - - Ok(secret_key) - } -} diff --git a/content-discovery/iroh-mainline-tracker/src/tracker.rs b/content-discovery/iroh-mainline-tracker/src/tracker.rs index 1d2fc45..4098ed5 100644 --- a/content-discovery/iroh-mainline-tracker/src/tracker.rs +++ b/content-discovery/iroh-mainline-tracker/src/tracker.rs @@ -6,6 +6,7 @@ use std::{ }; use bao_tree::ChunkNum; +use iroh::{endpoint::get_remote_node_id, Endpoint, NodeId}; use iroh_blobs::{ get::{fsm::EndBlobNext, Stats}, hashseq::HashSeq, @@ -19,7 +20,6 @@ use iroh_mainline_content_discovery::{ }, to_infohash, }; -use iroh_net::{endpoint::get_remote_node_id, Endpoint, NodeId}; use rand::Rng; use redb::{ReadableTable, RedbValue}; use serde::{Deserialize, Serialize}; @@ -1263,7 +1263,7 @@ pub async fn get_alpn(connecting: &mut iroh_quinn::Connecting) -> anyhow::Result /// Accept an incoming connection and extract the client-provided [`NodeId`] and ALPN protocol. async fn iroh_accept_conn( - mut conn: iroh_net::endpoint::Connecting, + mut conn: iroh::endpoint::Connecting, ) -> anyhow::Result<(NodeId, Vec, iroh_quinn::Connection)> { let alpn = conn.alpn().await?; let conn = conn.await?; diff --git a/content-discovery/iroh-mainline-tracker/src/tracker/util.rs b/content-discovery/iroh-mainline-tracker/src/tracker/util.rs index 0165d5a..67e25f5 100644 --- a/content-discovery/iroh-mainline-tracker/src/tracker/util.rs +++ b/content-discovery/iroh-mainline-tracker/src/tracker/util.rs @@ -100,7 +100,7 @@ impl<'a, T> BatchIter<'a, T> { } } -impl<'a, T> Iterator for BatchIter<'a, T> { +impl Iterator for BatchIter<'_, T> { type Item = T; fn next(&mut self) -> Option { diff --git a/iroh-dag-sync/Cargo.toml b/iroh-dag-sync/Cargo.toml index 37b0b6f..b13c5e6 100644 --- a/iroh-dag-sync/Cargo.toml +++ b/iroh-dag-sync/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2021" [dependencies] -iroh-blobs = "0.28" -iroh-gossip = "0.28" -iroh-net = "0.28" +iroh-blobs = "0.29" +iroh-gossip = "0.29" +iroh = "0.29" iroh-car = "0.5.0" redb = "2.1.1" clap = { version = "4.5.7", features = ["derive"] } diff --git a/iroh-dag-sync/src/args.rs b/iroh-dag-sync/src/args.rs index 35978fb..9170c34 100644 --- a/iroh-dag-sync/src/args.rs +++ b/iroh-dag-sync/src/args.rs @@ -4,7 +4,7 @@ use std::{ }; use clap::Parser; -use iroh_net::NodeId; +use iroh::NodeId; use crate::protocol::Cid; diff --git a/iroh-dag-sync/src/main.rs b/iroh-dag-sync/src/main.rs index adf1960..190178e 100644 --- a/iroh-dag-sync/src/main.rs +++ b/iroh-dag-sync/src/main.rs @@ -5,13 +5,13 @@ use anyhow::Context; use clap::Parser; use futures_lite::StreamExt; use ipld_core::codec::Links; +use iroh::discovery::{dns::DnsDiscovery, pkarr::PkarrPublisher, ConcurrentDiscovery}; +use iroh::ticket::NodeTicket; +use iroh::NodeAddr; use iroh_blobs::store::{Map, MapEntry}; use iroh_blobs::{store::Store, BlobFormat}; use iroh_car::CarReader; use iroh_io::AsyncSliceReaderExt; -use iroh_net::discovery::{dns::DnsDiscovery, pkarr::PkarrPublisher, ConcurrentDiscovery}; -use iroh_net::ticket::NodeTicket; -use iroh_net::NodeAddr; use protocol::{ron_parser, Cid, Request}; use serde::{Deserialize, Serialize}; use sync::{handle_request, handle_sync_response}; @@ -35,14 +35,14 @@ const SYNC_ALPN: &[u8] = b"DAG_SYNC/1"; async fn create_endpoint( ipv4_addr: Option, ipv6_addr: Option, -) -> anyhow::Result { +) -> anyhow::Result { let secret_key = util::get_or_create_secret()?; let discovery = Box::new(ConcurrentDiscovery::from_services(vec![ Box::new(DnsDiscovery::n0_dns()), Box::new(PkarrPublisher::n0_dns(secret_key.clone())), ])); - let mut builder = iroh_net::Endpoint::builder() + let mut builder = iroh::Endpoint::builder() .secret_key(secret_key) .alpns(vec![SYNC_ALPN.to_vec()]) .discovery(discovery); diff --git a/iroh-dag-sync/src/sync.rs b/iroh-dag-sync/src/sync.rs index d8ccbeb..41cd272 100644 --- a/iroh-dag-sync/src/sync.rs +++ b/iroh-dag-sync/src/sync.rs @@ -1,5 +1,6 @@ use anyhow::Context; use bao_tree::{io::outboard::EmptyOutboard, BaoTree, ChunkRanges}; +use iroh::endpoint::{Connecting, RecvStream, SendStream}; use iroh_blobs::{ protocol::RangeSpec, provider::{send_blob, EventSender}, @@ -7,7 +8,6 @@ use iroh_blobs::{ BlobFormat, IROH_BLOCK_SIZE, }; use iroh_io::{TokioStreamReader, TokioStreamWriter}; -use iroh_net::endpoint::{Connecting, RecvStream, SendStream}; use multihash_codetable::MultihashDigest; use tokio::io::AsyncReadExt; diff --git a/iroh-dag-sync/src/util.rs b/iroh-dag-sync/src/util.rs index 8c5e9f6..ee681d2 100644 --- a/iroh-dag-sync/src/util.rs +++ b/iroh-dag-sync/src/util.rs @@ -1,5 +1,5 @@ use anyhow::anyhow; -use iroh_net::{key::SecretKey, Endpoint}; +use iroh::{key::SecretKey, Endpoint}; // Wait for the endpoint to figure out its relay address. pub async fn wait_for_relay(endpoint: &Endpoint) -> anyhow::Result<()> { diff --git a/iroh-pkarr-naming-system/Cargo.toml b/iroh-pkarr-naming-system/Cargo.toml index 235bf3e..100c30f 100644 --- a/iroh-pkarr-naming-system/Cargo.toml +++ b/iroh-pkarr-naming-system/Cargo.toml @@ -8,9 +8,8 @@ edition = "2021" [dependencies] anyhow = "1.0.79" derive_more = "0.99.17" -iroh = "0.28" -iroh-blobs = "0.28" -iroh-net = "0.28" +iroh = "0.29" +iroh-blobs = "0.29" pkarr = { version = "1.0.1", features = ["async", "dht"] } tokio = "1.35.1" tokio-util = "0.7.12" diff --git a/iroh-pkarr-naming-system/examples/cli.rs b/iroh-pkarr-naming-system/examples/cli.rs index bc0454b..f6cfce6 100644 --- a/iroh-pkarr-naming-system/examples/cli.rs +++ b/iroh-pkarr-naming-system/examples/cli.rs @@ -1,4 +1,4 @@ -use iroh::base::ticket::BlobTicket; +use iroh::ticket::BlobTicket; use iroh_blobs::{Hash, HashAndFormat}; use iroh_pkarr_naming_system::{Record, IPNS}; use std::{fmt::Display, process, str::FromStr}; @@ -59,7 +59,7 @@ async fn main() -> anyhow::Result<()> { match args.len() { // resolve a record 1 => { - let public_key = iroh_net::key::PublicKey::from_str(&args[0])?; + let public_key = iroh::key::PublicKey::from_str(&args[0])?; let ipns = IPNS::default(); let record = ipns.resolve(public_key).await?; if let Some(Record::Content { content }) = record { @@ -70,7 +70,7 @@ async fn main() -> anyhow::Result<()> { } // publish a record 2 => { - let secret_key = iroh_net::key::SecretKey::from_str(&args[0])?; + let secret_key = iroh::key::SecretKey::from_str(&args[0])?; let public_key = secret_key.public(); let zid = pkarr::PublicKey::try_from(*public_key.as_bytes())?.to_z32(); let content = ContentArg::from_str(&args[1])?.hash_and_format(); diff --git a/iroh-pkarr-naming-system/src/lib.rs b/iroh-pkarr-naming-system/src/lib.rs index 1819932..8c6369d 100644 --- a/iroh-pkarr-naming-system/src/lib.rs +++ b/iroh-pkarr-naming-system/src/lib.rs @@ -6,8 +6,8 @@ use std::{ }; use anyhow::Context; +use iroh::key::SecretKey; use iroh_blobs::HashAndFormat; -use iroh_net::key::SecretKey; use pkarr::{ dns::{ rdata::{RData, TXT}, @@ -50,7 +50,7 @@ pub struct IPNS(Arc); #[derive(Debug, Default)] struct Inner { pkarr: Arc, - packets: Mutex)>>, + packets: Mutex)>>, } impl IPNS { @@ -91,7 +91,7 @@ impl IPNS { /// Resolve a record for a public key. pub async fn resolve( &self, - public_key: iroh_net::key::PublicKey, + public_key: iroh::key::PublicKey, ) -> anyhow::Result> { let public_key = pkarr::PublicKey::try_from(*public_key.as_bytes()).context("invalid public key")?; diff --git a/iroh-s3-bao-store/Cargo.toml b/iroh-s3-bao-store/Cargo.toml index 4760d22..0a7c6b2 100644 --- a/iroh-s3-bao-store/Cargo.toml +++ b/iroh-s3-bao-store/Cargo.toml @@ -21,7 +21,8 @@ flume = "0.11.0" futures-lite = "2.3" hex = "0.4.3" indicatif = "0.17.7" -iroh = "0.28" +iroh = "0.29" +iroh-blobs = "0.29" iroh-io = { version = "0.6", features = ["x-http"] } num_cpus = "1.16.0" rand = "0.8.5" diff --git a/iroh-s3-bao-store/src/lib.rs b/iroh-s3-bao-store/src/lib.rs index d609869..534113c 100644 --- a/iroh-s3-bao-store/src/lib.rs +++ b/iroh-s3-bao-store/src/lib.rs @@ -6,10 +6,10 @@ use bao_tree::io::fsm::Outboard; use bao_tree::io::outboard::{PostOrderMemOutboard, PreOrderMemOutboard}; use bao_tree::BaoTree; use bytes::Bytes; -use iroh::blobs::store::bao_tree::blake3; -use iroh::blobs::store::{BaoBlobSize, MapEntry}; -use iroh::blobs::Hash; -use iroh::blobs::IROH_BLOCK_SIZE; +use iroh_blobs::store::bao_tree::blake3; +use iroh_blobs::store::{BaoBlobSize, MapEntry}; +use iroh_blobs::Hash; +use iroh_blobs::IROH_BLOCK_SIZE; use iroh_io::{AsyncSliceReader, AsyncSliceReaderExt, HttpAdapter}; use url::Url; @@ -153,10 +153,10 @@ impl AsyncSliceReader for File { } } -impl iroh::blobs::store::Map for S3Store { +impl iroh_blobs::store::Map for S3Store { type Entry = Entry; - async fn get(&self, hash: &iroh::blobs::Hash) -> io::Result> { + async fn get(&self, hash: &iroh_blobs::Hash) -> io::Result> { let key: blake3::Hash = (*hash).into(); Ok(self.0.entries.lock().unwrap().get(&key).cloned()) } diff --git a/iroh-s3-bao-store/src/main.rs b/iroh-s3-bao-store/src/main.rs index 672c01a..a9d2fce 100644 --- a/iroh-s3-bao-store/src/main.rs +++ b/iroh-s3-bao-store/src/main.rs @@ -3,13 +3,12 @@ use clap::{Parser, Subcommand}; use indicatif::{ HumanBytes, HumanDuration, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle, }; -use iroh::base::ticket::BlobTicket; -use iroh::blobs::util::local_pool::LocalPool; -use iroh::blobs::{ +use iroh::{key::SecretKey, ticket::BlobTicket, Endpoint, NodeAddr}; +use iroh_blobs::util::local_pool::LocalPool; +use iroh_blobs::{ provider::{self, handle_connection, CustomEventSender, EventSender}, BlobFormat, }; -use iroh::net::{key::SecretKey, Endpoint, NodeAddr}; use iroh_io::{AsyncSliceReaderExt, HttpAdapter}; use iroh_s3_bao_store::S3Store; use serde::Deserialize; @@ -63,7 +62,7 @@ impl Display for Format { } } -fn print_hash(hash: &iroh::blobs::Hash, format: Format) -> String { +fn print_hash(hash: &iroh_blobs::Hash, format: Format) -> String { match format { Format::Hex => hash.to_hex().to_string(), Format::Cid => hash.to_string(), @@ -179,12 +178,12 @@ impl Drop for ClientStatus { } impl CustomEventSender for ClientStatus { - fn send(&self, event: iroh::blobs::provider::Event) -> futures_lite::future::Boxed<()> { + fn send(&self, event: iroh_blobs::provider::Event) -> futures_lite::future::Boxed<()> { self.try_send(event); Box::pin(std::future::ready(())) } - fn try_send(&self, event: iroh::blobs::provider::Event) { + fn try_send(&self, event: iroh_blobs::provider::Event) { tracing::info!("{:?}", event); let msg = match event { provider::Event::ClientConnected { connection_id } => { @@ -233,7 +232,7 @@ async fn serve_db( let secret_key = get_or_create_secret(true)?; // create an iroh endpoint let mut builder = Endpoint::builder() - .alpns(vec![iroh::blobs::protocol::ALPN.to_vec()]) + .alpns(vec![iroh_blobs::protocol::ALPN.to_vec()]) .secret_key(secret_key); if let Some(addr) = iroh_ipv4_addr { @@ -287,7 +286,7 @@ async fn serve_s3(args: ServeS3Args) -> anyhow::Result<()> { let collection = hashes .iter() .cloned() - .collect::(); + .collect::(); let blobs = collection.to_blobs(); let mut last_hash = None; for blob in blobs { @@ -322,7 +321,7 @@ async fn serve_urls(args: ImportS3Args) -> anyhow::Result<()> { let collection = hashes .iter() .cloned() - .collect::(); + .collect::(); let blobs = collection.to_blobs(); let mut last_hash = None; for blob in blobs {