From bf6f5d6552163db90d6be36cdfe5c6e2c0b1db14 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Tue, 14 May 2024 23:35:00 -0500 Subject: [PATCH] Remove sleep on startup --- src/core.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/core.rs b/src/core.rs index 2bcc833..58f8dec 100644 --- a/src/core.rs +++ b/src/core.rs @@ -21,6 +21,7 @@ use iced::{ }; use log::{error, warn}; use tokio::sync::RwLock; +use tokio::task::spawn_blocking; use crate::fedimint_client::{ spawn_onchain_payment_subscription, spawn_onchain_receive_subscription, @@ -225,16 +226,12 @@ pub fn run_core() -> Subscription { .await .expect("should send"); - // TODO: for some reason the unlocking message gets delivered at the end if I don't sleep here - sleep(Duration::from_secs(1)).await; - // attempting to unlock - let db = setup_db( - path.join("harbor.sqlite") - .to_str() - .expect("path must be correct"), - password, - ); + let db_path = path.join("harbor.sqlite"); + let join = + spawn_blocking(move || setup_db(db_path.to_str().unwrap(), password)); + + let db = join.await.expect("Could not create join handle"); if let Err(e) = db { // probably invalid password