Cesar Rodas 2 ماه پیش
والد
کامیت
526cc44996
4فایلهای تغییر یافته به همراه14 افزوده شده و 10 حذف شده
  1. 5 1
      crates/cdk-common/Cargo.toml
  2. 6 7
      crates/cdk-common/src/task.rs
  3. 0 1
      crates/cdk-ffi/src/database.rs
  4. 3 1
      crates/cdk-ffi/src/postgres.rs

+ 5 - 1
crates/cdk-common/Cargo.toml

@@ -40,12 +40,16 @@ anyhow.workspace = true
 serde_json.workspace = true
 serde_with.workspace = true
 web-time.workspace = true
-tokio.workspace = true
 parking_lot = "0.12.5"
 
+
+[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
+tokio = { version = "1", default-features = false, features = ["rt", "rt-multi-thread", "macros", "test-util", "sync"] }
+
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 uuid = { workspace = true, features = ["js"], optional = true }
 getrandom = { version = "0.2", features = ["js"] }
+tokio.workspace = true
 wasm-bindgen = "0.2"
 wasm-bindgen-futures = "0.4"
 

+ 6 - 7
crates/cdk-common/src/task.rs

@@ -1,6 +1,7 @@
 //! Thin wrapper for spawn and spawn_local for native and wasm.
 
-use std::{future::Future, sync::OnceLock};
+use std::future::Future;
+use std::sync::OnceLock;
 
 use tokio::task::JoinHandle;
 
@@ -21,12 +22,10 @@ where
         // use (or lazily create) a global runtime and spawn on it.
         GLOBAL_RUNTIME
             .get_or_init(|| {
-                tokio::runtime::Runtime::new().expect("failed to build global Tokio runtime")
-                // or, if you want to be explicit:
-                // tokio::runtime::Builder::new_multi_thread()
-                //     .enable_all()
-                //     .build()
-                //     .expect("failed to build global Tokio runtime")
+                tokio::runtime::Builder::new_multi_thread()
+                    .enable_all()
+                    .build()
+                    .expect("failed to build global Tokio runtime")
             })
             .spawn(future)
     }

+ 0 - 1
crates/cdk-ffi/src/database.rs

@@ -1032,7 +1032,6 @@ impl Drop for FfiWalletTransaction {
             let tx = self.tx.clone();
             spawn(async move {
                 if let Some(s) = tx.lock().await.take() {
-                    println!("inplicit rollback");
                     let _ = s.rollback().await;
                 }
             });

+ 3 - 1
crates/cdk-ffi/src/postgres.rs

@@ -62,7 +62,9 @@ impl WalletPostgresDatabase {
 #[uniffi::export(async_runtime = "tokio")]
 #[async_trait::async_trait]
 impl WalletDatabase for WalletPostgresDatabase {
-    async fn begin_db_transaction(&self) -> Result<Arc<WalletDatabaseTransactionWrapper>, FfiError> {
+    async fn begin_db_transaction(
+        &self,
+    ) -> Result<Arc<WalletDatabaseTransactionWrapper>, FfiError> {
         self.inner.begin_db_transaction().await
     }