diff --git a/src/lib.rs b/src/lib.rs index 94cc219..7204fcd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,20 +76,17 @@ struct OnlineWallet { wallet: Mutex>, } -pub trait BdkProgress: Send { +pub trait BdkProgress: Send + Sync { fn update(&self, progress: f32, message: Option); } struct BdkProgressHolder { - progress_update: Mutex>, + progress_update: Box, } impl Progress for BdkProgressHolder { fn update(&self, progress: f32, message: Option) -> Result<(), Error> { - self.progress_update - .lock() - .unwrap() - .update(progress, message); + self.progress_update.update(progress, message); Ok(()) } } @@ -147,12 +144,10 @@ impl OnlineWallet { max_address_param: Option, ) -> Result<(), BdkError> { progress_update.update(21.0, Some("message".to_string())); - self.wallet.lock().unwrap().sync( - BdkProgressHolder { - progress_update: Mutex::new(progress_update), - }, - max_address_param, - ) + self.wallet + .lock() + .unwrap() + .sync(BdkProgressHolder { progress_update }, max_address_param) } }