Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 13 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ quinn = { package = "iroh-quinn", version = "0.14.0" }
n0-future = "0.2.0"
n0-snafu = "0.2.0"
range-collections = { version = "0.4.6", features = ["serde"] }
redb = { version = "=2.4" }
smallvec = { version = "1", features = ["serde", "const_new"] }
snafu = "0.8.5"
tokio = { version = "1.43.0", features = ["full"] }
Expand All @@ -41,9 +40,10 @@ iroh = "0.91.1"
self_cell = "1.1.0"
genawaiter = { version = "0.99.1", features = ["futures03"] }
iroh-base = "0.91.1"
reflink-copy = "0.1.24"
irpc = { version = "0.7.0", features = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"], default-features = false }
iroh-metrics = { version = "0.35" }
redb = { version = "=2.4", optional = true }
reflink-copy = { version = "0.1.24", optional = true }

[dev-dependencies]
clap = { version = "4.5.31", features = ["derive"] }
Expand All @@ -64,7 +64,8 @@ iroh = { version = "0.91.1", features = ["discovery-local-network"]}
[features]
hide-proto-docs = []
metrics = []
default = ["hide-proto-docs"]
default = ["hide-proto-docs", "fs-store"]
fs-store = ["dep:redb", "dep:reflink-copy"]

[patch.crates-io]
iroh = { git = "https://github.com/n0-computer/iroh", branch = "main" }
Expand Down
3 changes: 3 additions & 0 deletions src/api/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ impl Blobs {
/// clears the protections before.
///
/// Users should rely only on garbage collection for blob deletion.
#[allow(dead_code)]
pub(crate) async fn delete_with_opts(&self, options: DeleteOptions) -> RequestResult<()> {
trace!("{options:?}");
self.client.rpc(options).await??;
Ok(())
}

/// See [`Self::delete_with_opts`].
#[allow(dead_code)]
pub(crate) async fn delete(
&self,
hashes: impl IntoIterator<Item = impl Into<Hash>>,
Expand Down Expand Up @@ -510,6 +512,7 @@ impl Blobs {
}
}

#[allow(dead_code)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's with this one?

pub(crate) async fn clear_protected(&self) -> RequestResult<()> {
let msg = ClearProtectedRequest;
self.client.rpc(msg).await??;
Expand Down
1 change: 1 addition & 0 deletions src/api/blobs/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ impl tokio::io::AsyncSeek for BlobReader {
}

#[cfg(test)]
#[cfg(feature = "fs-store")]
mod tests {
use bao_tree::ChunkRanges;
use testresult::TestResult;
Expand Down
1 change: 1 addition & 0 deletions src/api/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ impl ContentDiscovery for Shuffled {
}

#[cfg(test)]
#[cfg(feature = "fs-store")]
mod tests {
use std::ops::Deref;

Expand Down
1 change: 1 addition & 0 deletions src/api/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub use bitfield::Bitfield;

use crate::{store::util::Tag, util::temp_tag::TempTag, BlobFormat, Hash, HashAndFormat};

#[allow(dead_code)]
pub(crate) trait HashSpecific {
fn hash(&self) -> Hash;

Expand Down
1 change: 1 addition & 0 deletions src/api/proto/bitfield.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl<'de> Deserialize<'de> for Bitfield {
}

impl Bitfield {
#[cfg(feature = "fs-store")]
pub(crate) fn new_unchecked(ranges: ChunkRanges, size: u64) -> Self {
Self { ranges, size }
}
Expand Down
1 change: 1 addition & 0 deletions src/api/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ where
}

#[cfg(test)]
#[cfg(feature = "fs-store")]
mod tests {
use bao_tree::{ChunkNum, ChunkRanges};
use testresult::TestResult;
Expand Down
6 changes: 3 additions & 3 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl From<Hash> for HashAndFormat {
}
}

// #[cfg(feature = "redb")]
#[cfg(feature = "fs-store")]
mod redb_support {
use postcard::experimental::max_size::MaxSize;
use redb::{Key as RedbKey, Value as RedbValue};
Expand Down Expand Up @@ -493,7 +493,7 @@ mod tests {
assert_eq_hex!(serialized, expected);
}

// #[cfg(feature = "redb")]
#[cfg(feature = "fs-store")]
#[test]
fn hash_redb() {
use redb::Value as RedbValue;
Expand All @@ -518,7 +518,7 @@ mod tests {
assert_eq_hex!(serialized, expected);
}

// #[cfg(feature = "redb")]
#[cfg(feature = "fs-store")]
#[test]
fn hash_and_format_redb() {
use redb::Value as RedbValue;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub mod test;
pub mod util;

#[cfg(test)]
#[cfg(feature = "fs-store")]
mod tests;

pub use protocol::ALPN;
17 changes: 10 additions & 7 deletions src/store/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ use crate::{
util::entity_manager::{self, ActiveEntityState},
},
util::{BaoTreeSender, FixedSize, MemOrFile, ValueOrPoisioned},
Hash, IROH_BLOCK_SIZE,
IROH_BLOCK_SIZE,
},
util::{
channel::oneshot,
temp_tag::{TagDrop, TempTag, TempTagScope, TempTags},
},
Hash,
};
mod bao_file;
use bao_file::BaoFileHandle;
Expand All @@ -142,11 +143,13 @@ use options::Options;
use tracing::Instrument;
mod gc;

use super::HashAndFormat;
use crate::api::{
self,
blobs::{AddProgressItem, ExportMode, ExportProgressItem},
Store,
use crate::{
api::{
self,
blobs::{AddProgressItem, ExportMode, ExportProgressItem},
Store,
},
HashAndFormat,
};

/// Create a 16 byte unique ID.
Expand Down Expand Up @@ -1477,7 +1480,7 @@ pub mod tests {
api::blobs::Bitfield,
store::{
util::{read_checksummed, SliceInfoExt, Tag},
HashAndFormat, IROH_BLOCK_SIZE,
IROH_BLOCK_SIZE,
},
};

Expand Down
3 changes: 2 additions & 1 deletion src/store/fs/bao_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ use crate::{
read_checksummed_and_truncate, write_checksummed, FixedSize, MemOrFile,
PartialMemStorage, DD,
},
Hash, IROH_BLOCK_SIZE,
IROH_BLOCK_SIZE,
},
Hash,
};

/// Storage for complete blobs. There is no longer any uncertainty about the
Expand Down
4 changes: 3 additions & 1 deletion src/store/fs/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ use crate::{
ListTagsRequest, RenameTagRequest, SetTagRequest, ShutdownMsg, SyncDbMsg,
},
tags::TagInfo,
Tag,
},
util::channel::oneshot,
Hash,
};
mod proto;
pub use proto::*;
Expand All @@ -43,7 +45,7 @@ use super::{
util::PeekableReceiver,
BaoFilePart,
};
use crate::store::{util::Tag, Hash, IROH_BLOCK_SIZE};
use crate::store::IROH_BLOCK_SIZE;

/// Error type for message handler functions of the redb actor.
///
Expand Down
2 changes: 1 addition & 1 deletion src/store/fs/meta/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use redb::{ReadableTable, TableDefinition, TableError};

use super::EntryState;
use crate::store::{fs::delete_set::FileTransaction, util::Tag, Hash, HashAndFormat};
use crate::{api::Tag, store::fs::delete_set::FileTransaction, Hash, HashAndFormat};

pub(super) const BLOBS_TABLE: TableDefinition<Hash, EntryState> = TableDefinition::new("blobs-0");

Expand Down
4 changes: 2 additions & 2 deletions src/store/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ use crate::{
protocol::ChunkRangesExt,
store::{
util::{SizeInfo, SparseMemFile, Tag},
HashAndFormat, IROH_BLOCK_SIZE,
IROH_BLOCK_SIZE,
},
util::temp_tag::{TagDrop, TempTagScope, TempTags},
BlobFormat, Hash,
BlobFormat, Hash, HashAndFormat,
};

#[derive(Debug, Default)]
Expand Down
3 changes: 1 addition & 2 deletions src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
//! for when you want to efficiently share more than the available memory and
//! have access to a writeable filesystem.
use bao_tree::BlockSize;
#[cfg(feature = "fs-store")]
pub mod fs;
pub mod mem;
pub mod readonly_mem;
mod test;
pub(crate) mod util;

use crate::hash::{Hash, HashAndFormat};

/// Block size used by iroh, 2^4*1024 = 16KiB
pub const IROH_BLOCK_SIZE: BlockSize = BlockSize::from_chunk_log(4);
Loading
Loading