diff --git a/Cargo.lock b/Cargo.lock index b54979936..f781bf4c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,15 +43,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -193,17 +184,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi 0.3.9", -] - [[package]] name = "autocfg" version = "0.1.7" @@ -234,30 +214,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" -[[package]] -name = "bindgen" -version = "0.53.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c72a978d268b1d70b0e963217e60fdabd9523a941457a6c42a7315d15c7e89e5" -dependencies = [ - "bitflags", - "cexpr", - "cfg-if", - "clang-sys", - "clap", - "env_logger", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "proc-macro2 1.0.19", - "quote 1.0.7", - "regex", - "rustc-hash", - "shlex", - "which", -] - [[package]] name = "bitflags" version = "1.2.1" @@ -421,18 +377,6 @@ name = "cc" version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" -dependencies = [ - "jobserver", -] - -[[package]] -name = "cexpr" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" -dependencies = [ - "nom", -] [[package]] name = "cfg-if" @@ -462,30 +406,15 @@ dependencies = [ "unsigned-varint 0.3.3", ] -[[package]] -name = "clang-sys" -version = "0.29.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "2.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" dependencies = [ - "ansi_term 0.11.0", - "atty", "bitflags", - "strsim", "textwrap", "unicode-width", - "vec_map", ] [[package]] @@ -813,19 +742,6 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime 1.3.0", - "log", - "regex", - "termcolor", -] - [[package]] name = "event-listener" version = "2.3.0" @@ -1100,12 +1016,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - [[package]] name = "h2" version = "0.2.6" @@ -1237,15 +1147,6 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "humantime" version = "2.0.1" @@ -1329,7 +1230,6 @@ dependencies = [ "prost", "prost-build", "rand 0.7.3", - "rocksdb", "serde", "serde_json", "sha2 0.9.1", @@ -1351,7 +1251,7 @@ dependencies = [ "futures 0.3.5", "hex", "hex-literal", - "humantime 2.0.1", + "humantime", "hyper", "ipfs", "libipld", @@ -1413,15 +1313,6 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" -[[package]] -name = "jobserver" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.44" @@ -1462,12 +1353,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" - [[package]] name = "libc" version = "0.2.74" @@ -1515,16 +1400,6 @@ dependencies = [ "multihash", ] -[[package]] -name = "libloading" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -dependencies = [ - "cc", - "winapi 0.3.9", -] - [[package]] name = "libp2p" version = "0.22.0" @@ -1785,18 +1660,6 @@ dependencies = [ "yamux", ] -[[package]] -name = "librocksdb-sys" -version = "6.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883213ae3d09bfc3d104aefe94b25ebb183b6f4d3a515b23b14817e1f4854005" -dependencies = [ - "bindgen", - "cc", - "glob", - "libc", -] - [[package]] name = "libsecp256k1" version = "0.3.5" @@ -2027,16 +1890,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" -[[package]] -name = "nom" -version = "5.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" -dependencies = [ - "memchr", - "version_check", -] - [[package]] name = "num-integer" version = "0.1.43" @@ -2191,12 +2044,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "percent-encoding" version = "2.1.0" @@ -2653,16 +2500,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "rocksdb" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12069b106981c6103d3eab7dd1c86751482d0779a520b7c14954c8b586c1e643" -dependencies = [ - "libc", - "librocksdb-sys", -] - [[package]] name = "rust-argon2" version = "0.7.0" @@ -2675,12 +2512,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc-hex" version = "2.1.0" @@ -2848,12 +2679,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shlex" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" - [[package]] name = "signal-hook-registry" version = "1.2.0" @@ -2945,12 +2770,6 @@ dependencies = [ "generic-array 0.12.3", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "structopt" version = "0.3.15" @@ -3046,15 +2865,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "termcolor" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" -dependencies = [ - "winapi-util", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -3362,7 +3172,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7b33f8b2ef2ab0c3778c12646d9c42a24f7772bee4cdafc72199644a9f58fdc" dependencies = [ - "ansi_term 0.12.1", + "ansi_term", "lazy_static", "matchers", "regex", @@ -3524,12 +3334,6 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "vergen" version = "3.1.0" @@ -3738,15 +3542,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index a6c625e9b..45a94abc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,6 @@ version = "0.1.0" [features] default = [] nightly = [] -all = ["rocksdb"] [dependencies] anyhow = { default-features = false, version = "1.0" } @@ -28,7 +27,6 @@ multibase = { default-features = false, version = "0.8" } multihash = { default-features = false, version = "0.11" } prost = { default-features = false, version = "0.6" } rand = { default-features = false, features = ["getrandom"], version = "0.7" } -rocksdb = { default-features = false, optional = true, version = "0.13"} serde = { default-features = false, features = ["derive"], version = "1.0" } serde_json = { default-features = false, version = "1.0" } thiserror = { default-features = false, version = "1.0" } diff --git a/src/lib.rs b/src/lib.rs index 60201d8bf..9b748a554 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -66,9 +66,6 @@ impl IpfsTypes for T {} pub struct Types; impl RepoTypes for Types { type TBlockStore = repo::fs::FsBlockStore; - #[cfg(feature = "rocksdb")] - type TDataStore = repo::fs::RocksDataStore; - #[cfg(not(feature = "rocksdb"))] type TDataStore = repo::mem::MemDataStore; } diff --git a/src/repo/fs.rs b/src/repo/fs.rs index c5c950b33..a7ab91819 100644 --- a/src/repo/fs.rs +++ b/src/repo/fs.rs @@ -1,8 +1,6 @@ //! Persistent fs backed repo use crate::error::Error; use crate::repo::{BlockPut, BlockStore}; -#[cfg(feature = "rocksdb")] -use crate::repo::{Column, DataStore}; use async_std::fs; use async_std::path::PathBuf; use async_std::prelude::*; @@ -132,105 +130,6 @@ impl BlockStore for FsBlockStore { } } -#[derive(Debug)] -#[cfg(feature = "rocksdb")] -pub struct RocksDataStore { - path: PathBuf, - db: Mutex>, -} - -#[cfg(feature = "rocksdb")] -trait ResolveColumnFamily { - fn resolve<'a>(&self, db: &'a rocksdb::DB) -> &'a rocksdb::ColumnFamily; -} - -#[cfg(feature = "rocksdb")] -impl ResolveColumnFamily for Column { - fn resolve<'a>(&self, db: &'a rocksdb::DB) -> &'a rocksdb::ColumnFamily { - let name = match *self { - Column::Ipns => "ipns", - Column::Pin => "pin", - }; - - // not sure why this isn't always present? - db.cf_handle(name).unwrap() - } -} - -#[cfg(feature = "rocksdb")] -#[async_trait] -impl DataStore for RocksDataStore { - fn new(path: PathBuf) -> Self { - RocksDataStore { - path, - db: Default::default(), - } - } - - async fn init(&self) -> Result<(), Error> { - Ok(()) - } - - async fn open(&self) -> Result<(), Error> { - let db = &self.db; - let path = self.path.clone(); - let mut db_opts = rocksdb::Options::default(); - db_opts.create_missing_column_families(true); - db_opts.create_if_missing(true); - - let ipns_opts = rocksdb::Options::default(); - let ipns_cf = rocksdb::ColumnFamilyDescriptor::new("ipns", ipns_opts); - let rdb = rocksdb::DB::open_cf_descriptors(&db_opts, &path, vec![ipns_cf])?; - *db.lock().await = Some(rdb); - Ok(()) - } - - async fn contains(&self, col: Column, key: &[u8]) -> Result { - let db = &self.db; - let key = key.to_owned(); - let db = db.lock().await; - let db = db.as_ref().unwrap(); - let cf = col.resolve(db); - let contains = db.get_cf(cf, &key)?.is_some(); - Ok(contains) - } - - async fn get(&self, col: Column, key: &[u8]) -> Result>, Error> { - let db = &self.db; - let key = key.to_owned(); - let db = db.lock().await; - let db = db.as_ref().unwrap(); - let cf = col.resolve(db); - let get = db.get_cf(cf, &key)?.map(|value| value.to_vec()); - Ok(get) - } - - async fn put(&self, col: Column, key: &[u8], value: &[u8]) -> Result<(), Error> { - let db = &self.db; - let key = key.to_owned(); - let value = value.to_owned(); - let db = db.lock().await; - let db = db.as_ref().unwrap(); - let cf = col.resolve(db); - db.put_cf(cf, &key, &value)?; - Ok(()) - } - - async fn remove(&self, col: Column, key: &[u8]) -> Result<(), Error> { - let db = &self.db; - let key = key.to_owned(); - let db = db.lock().await; - let db = db.as_ref().unwrap(); - let cf = col.resolve(db); - db.delete_cf(cf, &key)?; - Ok(()) - } - - async fn wipe(&self) { - // this function is currently only intended to be used with in-memory test setups - } -} - fn block_path(mut base: PathBuf, cid: &Cid) -> PathBuf { let mut file = cid.to_string(); file.push_str(".data"); @@ -332,40 +231,4 @@ mod tests { assert!(block_store.contains(cid).await.unwrap()); } } - - #[async_std::test] - #[cfg(feature = "rocksdb")] - async fn test_rocks_datastore() { - let mut tmp = temp_dir(); - tmp.push("datastore1"); - std::fs::remove_dir_all(&tmp).ok(); - let store = RocksDataStore::new(tmp.clone().into()); - - let col = Column::Ipns; - let key = [1, 2, 3, 4]; - let value = [5, 6, 7, 8]; - - store.init().await.unwrap(); - store.open().await.unwrap(); - - let contains = store.contains(col, &key); - assert_eq!(contains.await.unwrap(), false); - let get = store.get(col, &key); - assert_eq!(get.await.unwrap(), None); - store.remove(col, &key).await.unwrap(); - - store.put(col, &key, &value).await.unwrap(); - let contains = store.contains(col, &key); - assert_eq!(contains.await.unwrap(), true); - let get = store.get(col, &key); - assert_eq!(get.await.unwrap(), Some(value.to_vec())); - - store.remove(col, &key).await.unwrap(); - let contains = store.contains(col, &key); - assert_eq!(contains.await.unwrap(), false); - let get = store.get(col, &key); - assert_eq!(get.await.unwrap(), None); - - std::fs::remove_dir_all(&tmp).ok(); - } }