From 5588f43c72893e94b72910e773d26fad3388cb45 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Mon, 14 Aug 2023 21:29:42 +0300 Subject: [PATCH] testing rocksdb storage on android --- Cargo.lock | 4 ++-- ng-app/src-tauri/Cargo.toml | 2 +- ng-app/src-tauri/src/lib.rs | 9 ++++++++- p2p-net/src/broker.rs | 10 +++++++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee6affb..d529711 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2514,7 +2514,7 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "librocksdb-sys" version = "0.11.0+8.3.2" -source = "git+https://git.nextgraph.org/NextGraph/rust-rocksdb.git?branch=master#9fed72433fd4ca9fc5db48911dcac2a650eb663c" +source = "git+https://git.nextgraph.org/NextGraph/rust-rocksdb.git?branch=master#2026e3002eac5f7389697883b36eb1c4090e8c46" dependencies = [ "bindgen", "bzip2-sys", @@ -4009,7 +4009,7 @@ dependencies = [ [[package]] name = "rocksdb" version = "0.21.0" -source = "git+https://git.nextgraph.org/NextGraph/rust-rocksdb.git?branch=master#9fed72433fd4ca9fc5db48911dcac2a650eb663c" +source = "git+https://git.nextgraph.org/NextGraph/rust-rocksdb.git?branch=master#2026e3002eac5f7389697883b36eb1c4090e8c46" dependencies = [ "libc", "librocksdb-sys", diff --git a/ng-app/src-tauri/Cargo.toml b/ng-app/src-tauri/Cargo.toml index 9d75607..484f0c4 100644 --- a/ng-app/src-tauri/Cargo.toml +++ b/ng-app/src-tauri/Cargo.toml @@ -23,7 +23,7 @@ serde_json = "1.0" p2p-repo = { path = "../../p2p-repo" } p2p-net = { path = "../../p2p-net" } ng-wallet = { path = "../../ng-wallet" } -async-std = { version = "1.12.0", features = ["attributes","unstable"] } +async-std = { version = "1.12.0", features = ["attributes", "unstable"] } tauri-plugin-window = "2.0.0-alpha" [features] diff --git a/ng-app/src-tauri/src/lib.rs b/ng-app/src-tauri/src/lib.rs index f5f277b..ef5cac1 100644 --- a/ng-app/src-tauri/src/lib.rs +++ b/ng-app/src-tauri/src/lib.rs @@ -34,8 +34,15 @@ pub type SetupHook = Box Result<(), Box Result<(), ()> { +async fn test(app: tauri::AppHandle) -> Result<(), ()> { log_debug!("test is {}", BROKER.read().await.test()); + let path = app + .path() + .resolve("storage", BaseDirectory::AppLocalData) + .map_err(|_| ())?; + + BROKER.read().await.test_storage(path); + Ok(()) } diff --git a/p2p-net/src/broker.rs b/p2p-net/src/broker.rs index 0b9b548..a543bb1 100644 --- a/p2p-net/src/broker.rs +++ b/p2p-net/src/broker.rs @@ -422,14 +422,18 @@ impl<'a> Broker<'a> { } #[cfg(not(target_arch = "wasm32"))] - pub fn test_storage(path: PathBuf) { + pub fn test_storage(&self, path: PathBuf) { use stores_rocksdb::kcv_store::RocksdbKCVStore; let key: [u8; 32] = [0; 32]; let test_storage = RocksdbKCVStore::open(&path, key); match test_storage { - Err(e) => log_debug!("storage error {}", e), - Ok(_) => log_debug!("storage ok"), + Err(e) => { + log_debug!("storage error {}", e); + } + Ok(_) => { + log_debug!("storage ok"); + } } }