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>>,
|
wallet: Mutex<Wallet<AnyBlockchain, AnyDatabase>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait BdkProgress: Send {
|
pub trait BdkProgress: Send + Sync {
|
||||||
fn update(&self, progress: f32, message: Option<String>);
|
fn update(&self, progress: f32, message: Option<String>);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BdkProgressHolder {
|
struct BdkProgressHolder {
|
||||||
progress_update: Mutex<Box<dyn BdkProgress>>,
|
progress_update: Box<dyn BdkProgress>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Progress for BdkProgressHolder {
|
impl Progress for BdkProgressHolder {
|
||||||
fn update(&self, progress: f32, message: Option<String>) -> Result<(), Error> {
|
fn update(&self, progress: f32, message: Option<String>) -> Result<(), Error> {
|
||||||
self.progress_update
|
self.progress_update.update(progress, message);
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.update(progress, message);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,12 +144,10 @@ impl OnlineWallet {
|
|||||||
max_address_param: Option<u32>,
|
max_address_param: Option<u32>,
|
||||||
) -> Result<(), BdkError> {
|
) -> Result<(), BdkError> {
|
||||||
progress_update.update(21.0, Some("message".to_string()));
|
progress_update.update(21.0, Some("message".to_string()));
|
||||||
self.wallet.lock().unwrap().sync(
|
self.wallet
|
||||||
BdkProgressHolder {
|
.lock()
|
||||||
progress_update: Mutex::new(progress_update),
|
.unwrap()
|
||||||
},
|
.sync(BdkProgressHolder { progress_update }, max_address_param)
|
||||||
max_address_param,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user