diff --git a/bin/main.rs b/bin/main.rs index d7caada..7f26798 100644 --- a/bin/main.rs +++ b/bin/main.rs @@ -11,8 +11,8 @@ use clap::{Parser, Subcommand}; use futures::TryStreamExt; use headers::{HeaderMap, HeaderMapExt, Range}; use hyper::header; -use iroh::rpc_protocol::ShareMode; -use iroh::sync::store::DownloadPolicy; +use iroh::client::docs::ShareMode; +use iroh::docs::store::DownloadPolicy; use iroh_base::hash::Hash; use iroh_base::node_addr::NodeAddr; use serde::{Deserialize, Serialize}; diff --git a/src/config.rs b/src/config.rs index f2c3b72..dd5a3f4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,5 @@ use crate::error::Error; -use iroh::sync::store::DownloadPolicy; +use iroh::docs::store::DownloadPolicy; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::path::{Path, PathBuf}; diff --git a/src/iroh_node.rs b/src/iroh_node.rs index 144f197..e4b3b74 100644 --- a/src/iroh_node.rs +++ b/src/iroh_node.rs @@ -3,17 +3,15 @@ use crate::error::{Error, Result}; use crate::table::Table; use async_stream::stream; use futures::StreamExt; -use iroh::bytes::store::fs::Store; -use iroh::bytes::Hash; +use iroh::blobs::store::fs::Store; +use iroh::client::docs::{Entry, ShareMode}; +use iroh::docs::store::DownloadPolicy; +use iroh::docs::{AuthorId, DocTicket, NamespaceId}; use iroh::net::defaults::DEFAULT_RELAY_STUN_PORT; use iroh::net::relay::{RelayMap, RelayMode, RelayNode}; use iroh::node::{GcPolicy, Node}; -use iroh::rpc_protocol::ShareMode; -use iroh::sync::store::DownloadPolicy; -use iroh::sync::{AuthorId, NamespaceId}; -use iroh::ticket::DocTicket; +use iroh_base::hash::Hash; use iroh_base::node_addr::NodeAddr; -use std::collections::hash_map::Entry; use std::collections::HashMap; use std::fmt::{Debug, Formatter}; use std::str::FromStr; @@ -172,7 +170,7 @@ impl IrohNode { Ok(iroh_node) } - pub fn client(&self) -> &iroh::client::mem::Iroh { + pub fn client(&self) -> &iroh::client::MemIroh { self.node.client() } @@ -186,8 +184,10 @@ impl IrohNode { storage_name: Option, ) -> Result { match self.tables.entry(table_name.to_string()) { - Entry::Occupied(_) => Err(Error::existing_table(table_name)), - Entry::Vacant(entry) => { + std::collections::hash_map::Entry::Occupied(_) => { + Err(Error::existing_table(table_name)) + } + std::collections::hash_map::Entry::Vacant(entry) => { let iroh_doc = self .node .client() @@ -245,7 +245,7 @@ impl IrohNode { let ticket = DocTicket::from_str(table_ticket).map_err(Error::doc)?; let nodes = ticket.nodes.clone(); match self.tables.entry(table_name.to_string()) { - Entry::Occupied(entry) => { + std::collections::hash_map::Entry::Occupied(entry) => { let iroh_doc = entry.get().iroh_doc(); if ticket.capability.id() != iroh_doc.id() { return Err(Error::existing_table("different document in table")); @@ -259,7 +259,7 @@ impl IrohNode { iroh_doc.start_sync(nodes).await.map_err(Error::doc)?; Ok(entry.get().iroh_doc().id()) } - Entry::Vacant(entry) => { + std::collections::hash_map::Entry::Vacant(entry) => { let iroh_doc = self .node .client() @@ -377,11 +377,7 @@ impl IrohNode { } } - pub async fn table_get( - &self, - table_name: &str, - key: &str, - ) -> Result> { + pub async fn table_get(&self, table_name: &str, key: &str) -> Result> { let table = self .tables .get(table_name) diff --git a/src/lib.rs b/src/lib.rs index 3b988d5..03b02e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,9 +15,6 @@ clippy::unwrap_used )] -use iroh::rpc_protocol::{ProviderRequest, ProviderResponse}; -use quic_rpc::transport::flume::FlumeConnection; - pub mod config; pub mod error; pub mod file_shard; @@ -26,6 +23,3 @@ pub mod iroh_node; pub mod ranges; mod table; mod utils; - -pub type IrohDoc = iroh::client::Doc>; -pub type IrohClient = iroh::client::Iroh>; diff --git a/src/ranges.rs b/src/ranges.rs index e1d512b..2d13e94 100644 --- a/src/ranges.rs +++ b/src/ranges.rs @@ -3,7 +3,7 @@ use std::ops::Bound; use bytes::Bytes; use headers::Range; -use iroh::bytes::store::bao_tree::ChunkNum; +use iroh::blobs::store::bao_tree::ChunkNum; use range_collections::{range_set::RangeSetRange, RangeSet2}; /// Given a range specified as arbitrary range bounds, normalize it into a range diff --git a/src/table.rs b/src/table.rs index d88be5a..e0b6357 100644 --- a/src/table.rs +++ b/src/table.rs @@ -3,22 +3,21 @@ use crate::error::{Error, Result}; use crate::file_shard::FileShard; use crate::hash_ring::HashRing; use crate::utils::key_to_bytes; -use crate::IrohDoc; use async_stream::stream; use bytes::Bytes; +use iroh::blobs::store::{ExportMode, Map}; + use futures::{Stream, StreamExt}; -use iroh::bytes::store::fs::Store; -use iroh::bytes::store::{ExportMode, Map}; -use iroh::bytes::Hash; -use iroh::client::{Entry, LiveEvent}; +use iroh::blobs::store::fs::Store; +use iroh::blobs::util::SetTagOption; +use iroh::client::blobs::{DownloadMode, DownloadOptions}; +use iroh::client::docs::{Entry, LiveEvent, ShareMode}; +use iroh::docs::store::{DownloadPolicy, Query, SortBy, SortDirection}; +use iroh::docs::{AuthorId, Capability, ContentStatus, DocTicket}; use iroh::net::key::PublicKey; use iroh::net::NodeAddr; use iroh::node::Node; -use iroh::rpc_protocol::{BlobDownloadRequest, DownloadMode, SetTagOption, ShareMode}; -use iroh::sync::store::{DownloadPolicy, Query, SortBy, SortDirection}; -use iroh::sync::{AuthorId, Capability, ContentStatus}; -use iroh::ticket::DocTicket; -use iroh_base::hash::BlobFormat; +use iroh_base::hash::{BlobFormat, Hash}; use lru::LruCache; use rand::seq::SliceRandom; use rand::thread_rng; @@ -95,7 +94,7 @@ impl Storage { #[derive(Clone)] pub struct Table { author_id: AuthorId, - iroh_doc: IrohDoc, + iroh_doc: iroh::client::MemDoc, table_config: TableConfig, cancellation_token: CancellationToken, task_tracker: TaskTracker, @@ -108,7 +107,7 @@ impl Table { table_name: &str, author_id: AuthorId, node: Node, - iroh_doc: IrohDoc, + iroh_doc: iroh::client::MemDoc, storage_config: Option, table_config: TableConfig, cancellation_token: CancellationToken, @@ -314,13 +313,15 @@ impl Table { let progress = self .node .blobs - .download(BlobDownloadRequest { - hash: entry.content_hash(), - format: BlobFormat::Raw, - nodes: nodes.to_vec(), - tag: SetTagOption::Auto, - mode: DownloadMode::Queued, - }) + .download_with_opts( + entry.content_hash(), + DownloadOptions { + format: BlobFormat::Raw, + nodes: nodes.to_vec(), + tag: SetTagOption::Auto, + mode: DownloadMode::Queued, + }, + ) .await .map_err(Error::io_error)?; progress.finish().await.map_err(Error::failed_download)?; @@ -422,7 +423,7 @@ impl Table { } } - pub fn iroh_doc(&self) -> &IrohDoc { + pub fn iroh_doc(&self) -> &iroh::client::MemDoc { &self.iroh_doc }