From 60c59ba61a4dfc62c18732ad3b74a25081e77148 Mon Sep 17 00:00:00 2001 From: ehsan shariati Date: Sun, 24 Nov 2024 16:27:42 -0500 Subject: [PATCH] async init --- Cargo.toml | 4 ++-- src/private_forest.rs | 15 ++------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 66bf014..021a2ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wnfsutils" -version = "1.1.8" +version = "1.1.9" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -24,7 +24,7 @@ sha3 = "0.10" futures = "0.3" rsa = "0.9" rand_chacha = "0.3" -base64 = "0.13.0" +base64 = "0.22.1" tempfile = "3.2" getrandom = { version = "0.2", features = ["js"] } wasm-bindgen-futures = "0.4.7" diff --git a/src/private_forest.rs b/src/private_forest.rs index 2b9a3bd..d1b39a5 100644 --- a/src/private_forest.rs +++ b/src/private_forest.rs @@ -704,22 +704,11 @@ impl<'a> PrivateDirectoryHelper<'a> { // Implement synced version of the library for using in android jni. impl<'a> PrivateDirectoryHelper<'a> { - pub fn synced_init( + pub async fn init_async( store: &mut FFIFriendlyBlockStore<'a>, wnfs_key: Vec, ) -> Result<(PrivateDirectoryHelper<'a>, AccessKey, Cid), String> { - #[cfg(target_arch = "wasm32")] - let runtime = tokio::runtime::Builder::new_current_thread() - .build() - .expect("Unable to create a runtime"); - - #[cfg(not(target_arch = "wasm32"))] - let runtime = tokio::runtime::Builder::new_current_thread() - .enable_time() - .build() - .expect("Unable to create a runtime"); - - runtime.block_on(PrivateDirectoryHelper::init(store, wnfs_key)) + PrivateDirectoryHelper::init(store, wnfs_key).await } pub fn synced_load_with_wnfs_key(