Skip to content

Commit 50e3580

Browse files
committed
Merge branch 'main' into provider-events-refactor
2 parents 255f23b + 55414b9 commit 50e3580

File tree

20 files changed

+239
-197
lines changed

20 files changed

+239
-197
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ quinn = { package = "iroh-quinn", version = "0.14.0" }
2121
n0-future = "0.2.0"
2222
n0-snafu = "0.2.0"
2323
range-collections = { version = "0.4.6", features = ["serde"] }
24-
redb = { version = "=2.4" }
2524
smallvec = { version = "1", features = ["serde", "const_new"] }
2625
snafu = "0.8.5"
2726
tokio = { version = "1.43.0", features = ["full"] }
@@ -41,9 +40,10 @@ iroh = "0.91.1"
4140
self_cell = "1.1.0"
4241
genawaiter = { version = "0.99.1", features = ["futures03"] }
4342
iroh-base = "0.91.1"
44-
reflink-copy = "0.1.24"
4543
irpc = { version = "0.7.0", features = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"], default-features = false }
4644
iroh-metrics = { version = "0.35" }
45+
redb = { version = "=2.4", optional = true }
46+
reflink-copy = { version = "0.1.24", optional = true }
4747

4848
[dev-dependencies]
4949
clap = { version = "4.5.31", features = ["derive"] }
@@ -64,7 +64,8 @@ iroh = { version = "0.91.1", features = ["discovery-local-network"]}
6464
[features]
6565
hide-proto-docs = []
6666
metrics = []
67-
default = ["hide-proto-docs"]
67+
default = ["hide-proto-docs", "fs-store"]
68+
fs-store = ["dep:redb", "dep:reflink-copy"]
6869

6970
[patch.crates-io]
7071
iroh = { git = "https://github.com/n0-computer/iroh", branch = "main" }

src/api/blobs.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,15 @@ impl Blobs {
144144
/// clears the protections before.
145145
///
146146
/// Users should rely only on garbage collection for blob deletion.
147+
#[cfg(feature = "fs-store")]
147148
pub(crate) async fn delete_with_opts(&self, options: DeleteOptions) -> RequestResult<()> {
148149
trace!("{options:?}");
149150
self.client.rpc(options).await??;
150151
Ok(())
151152
}
152153

153154
/// See [`Self::delete_with_opts`].
155+
#[cfg(feature = "fs-store")]
154156
pub(crate) async fn delete(
155157
&self,
156158
hashes: impl IntoIterator<Item = impl Into<Hash>>,
@@ -510,6 +512,7 @@ impl Blobs {
510512
}
511513
}
512514

515+
#[allow(dead_code)]
513516
pub(crate) async fn clear_protected(&self) -> RequestResult<()> {
514517
let msg = ClearProtectedRequest;
515518
self.client.rpc(msg).await??;

src/api/blobs/reader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ impl tokio::io::AsyncSeek for BlobReader {
214214
}
215215

216216
#[cfg(test)]
217+
#[cfg(feature = "fs-store")]
217218
mod tests {
218219
use bao_tree::ChunkRanges;
219220
use testresult::TestResult;

src/api/downloader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ impl ContentDiscovery for Shuffled {
521521
}
522522

523523
#[cfg(test)]
524+
#[cfg(feature = "fs-store")]
524525
mod tests {
525526
use std::ops::Deref;
526527

src/api/proto.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub use bitfield::Bitfield;
4040

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

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

src/api/proto/bitfield.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl<'de> Deserialize<'de> for Bitfield {
7070
}
7171

7272
impl Bitfield {
73+
#[cfg(feature = "fs-store")]
7374
pub(crate) fn new_unchecked(ranges: ChunkRanges, size: u64) -> Self {
7475
Self { ranges, size }
7576
}

src/api/remote.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ where
10631063
}
10641064

10651065
#[cfg(test)]
1066+
#[cfg(feature = "fs-store")]
10661067
mod tests {
10671068
use bao_tree::{ChunkNum, ChunkRanges};
10681069
use testresult::TestResult;

src/hash.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl From<Hash> for HashAndFormat {
283283
}
284284
}
285285

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

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

521-
// #[cfg(feature = "redb")]
521+
#[cfg(feature = "fs-store")]
522522
#[test]
523523
fn hash_and_format_redb() {
524524
use redb::Value as RedbValue;

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
//! The [downloader](api::downloader) module provides a component to download blobs from
2525
//! multiple sources and store them in a store.
2626
//!
27+
//! # Features:
28+
//!
29+
//! - `fs-store`: Enables the filesystem based store implementation. This comes with a few additional dependencies such as `redb` and `reflink-copy`.
30+
//! - `metrics`: Enables prometheus metrics for stores and the protocol.
31+
//!
2732
//! [BLAKE3]: https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf
2833
//! [iroh]: https://docs.rs/iroh
2934
mod hash;
@@ -46,6 +51,7 @@ pub mod test;
4651
pub mod util;
4752

4853
#[cfg(test)]
54+
#[cfg(feature = "fs-store")]
4955
mod tests;
5056

5157
pub use protocol::ALPN;

src/store/fs.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ use crate::{
121121
util::entity_manager::{self, ActiveEntityState},
122122
},
123123
util::{BaoTreeSender, FixedSize, MemOrFile, ValueOrPoisioned},
124-
Hash, IROH_BLOCK_SIZE,
124+
IROH_BLOCK_SIZE,
125125
},
126126
util::{
127127
channel::oneshot,
128128
temp_tag::{TagDrop, TempTag, TempTagScope, TempTags},
129129
},
130+
Hash,
130131
};
131132
mod bao_file;
132133
use bao_file::BaoFileHandle;
@@ -142,11 +143,13 @@ use options::Options;
142143
use tracing::Instrument;
143144
mod gc;
144145

145-
use super::HashAndFormat;
146-
use crate::api::{
147-
self,
148-
blobs::{AddProgressItem, ExportMode, ExportProgressItem},
149-
Store,
146+
use crate::{
147+
api::{
148+
self,
149+
blobs::{AddProgressItem, ExportMode, ExportProgressItem},
150+
Store,
151+
},
152+
HashAndFormat,
150153
};
151154

152155
/// Create a 16 byte unique ID.
@@ -1477,7 +1480,7 @@ pub mod tests {
14771480
api::blobs::Bitfield,
14781481
store::{
14791482
util::{read_checksummed, SliceInfoExt, Tag},
1480-
HashAndFormat, IROH_BLOCK_SIZE,
1483+
IROH_BLOCK_SIZE,
14811484
},
14821485
};
14831486

0 commit comments

Comments
 (0)