Skip to content

Commit

Permalink
[feat] Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ppodolsky committed May 7, 2024
1 parent 9cb0b6b commit 2e275fb
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 47 deletions.
4 changes: 2 additions & 2 deletions bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
30 changes: 13 additions & 17 deletions src/iroh_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
}

Expand All @@ -186,8 +184,10 @@ impl IrohNode {
storage_name: Option<String>,
) -> Result<NamespaceId> {
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()
Expand Down Expand Up @@ -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"));
Expand All @@ -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()
Expand Down Expand Up @@ -377,11 +377,7 @@ impl IrohNode {
}
}

pub async fn table_get(
&self,
table_name: &str,
key: &str,
) -> Result<Option<iroh::client::Entry>> {
pub async fn table_get(&self, table_name: &str, key: &str) -> Result<Option<Entry>> {
let table = self
.tables
.get(table_name)
Expand Down
6 changes: 0 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,6 +23,3 @@ pub mod iroh_node;
pub mod ranges;
mod table;
mod utils;

pub type IrohDoc = iroh::client::Doc<FlumeConnection<ProviderResponse, ProviderRequest>>;
pub type IrohClient = iroh::client::Iroh<FlumeConnection<ProviderResponse, ProviderRequest>>;
2 changes: 1 addition & 1 deletion src/ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 21 additions & 20 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -108,7 +107,7 @@ impl Table {
table_name: &str,
author_id: AuthorId,
node: Node<Store>,
iroh_doc: IrohDoc,
iroh_doc: iroh::client::MemDoc,
storage_config: Option<StorageEngineConfig>,
table_config: TableConfig,
cancellation_token: CancellationToken,
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -422,7 +423,7 @@ impl Table {
}
}

pub fn iroh_doc(&self) -> &IrohDoc {
pub fn iroh_doc(&self) -> &iroh::client::MemDoc {
&self.iroh_doc
}

Expand Down

0 comments on commit 2e275fb

Please sign in to comment.