Skip to content

Commit 9c99b17

Browse files
committed
Feature gate redb based store.
1 parent b1880e1 commit 9c99b17

File tree

7 files changed

+12
-6
lines changed

7 files changed

+12
-6
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/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/remote.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,7 @@ where
10611061
}
10621062

10631063
#[cfg(test)]
1064+
#[cfg(feature = "fs-store")]
10641065
mod tests {
10651066
use bao_tree::{ChunkNum, ChunkRanges};
10661067
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub mod test;
4646
pub mod util;
4747

4848
#[cfg(test)]
49+
#[cfg(feature = "fs-store")]
4950
mod tests;
5051

5152
pub use protocol::ALPN;

src/store/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! for when you want to efficiently share more than the available memory and
66
//! have access to a writeable filesystem.
77
use bao_tree::BlockSize;
8+
#[cfg(feature = "fs-store")]
89
pub mod fs;
910
pub mod mem;
1011
pub mod readonly_mem;

src/store/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ pub(crate) fn get_limited_slice(bytes: &Bytes, offset: u64, len: usize) -> Bytes
138138
bytes.slice(limited_range(offset, len, bytes.len()))
139139
}
140140

141+
#[cfg(feature = "fs-store")]
141142
mod redb_support {
142143
use bytes::Bytes;
143144
use redb::{Key as RedbKey, Value as RedbValue};

0 commit comments

Comments
 (0)