Remove unnecessary Mutex wrapper
This commit is contained in:
parent
41afeafcd3
commit
d307b281d7
19
src/lib.rs
19
src/lib.rs
@ -76,20 +76,17 @@ struct OnlineWallet {
|
||||
wallet: Mutex<Wallet<AnyBlockchain, AnyDatabase>>,
|
||||
}
|
||||
|
||||
pub trait BdkProgress: Send {
|
||||
pub trait BdkProgress: Send + Sync {
|
||||
fn update(&self, progress: f32, message: Option<String>);
|
||||
}
|
||||
|
||||
struct BdkProgressHolder {
|
||||
progress_update: Mutex<Box<dyn BdkProgress>>,
|
||||
progress_update: Box<dyn BdkProgress>,
|
||||
}
|
||||
|
||||
impl Progress for BdkProgressHolder {
|
||||
fn update(&self, progress: f32, message: Option<String>) -> 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<u32>,
|
||||
) -> 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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user