sdk: add blocking client and wallet as feature

This commit is contained in:
thesimplekid
2023-08-17 13:58:19 +01:00
parent 9ead2ea507
commit 1aedf3f2bc
8 changed files with 343 additions and 6 deletions

View File

@@ -1,7 +1,28 @@
#[cfg(feature = "wallet")]
#[cfg(feature = "blocking")]
use once_cell::sync::Lazy;
#[cfg(feature = "blocking")]
use tokio::runtime::Runtime;
#[cfg(feature = "blocking")]
use futures_util::Future;
// #[cfg(feature = "wallet")]
pub(crate) mod client;
#[cfg(feature = "mint")]
pub mod mint;
#[cfg(feature = "wallet")]
pub mod wallet;
pub use cashu::{self, *};
#[cfg(all(feature = "blocking", feature = "wallet"))]
use self::client::blocking;
#[cfg(feature = "blocking")]
static RUNTIME: Lazy<Runtime> = Lazy::new(|| Runtime::new().expect("Can't start Tokio runtime"));
#[cfg(feature = "blocking")]
pub fn block_on<F: Future>(future: F) -> F::Output {
RUNTIME.block_on(future)
}