fix rescan crash: shutdown old lightclient before overwriting
This commit is contained in:
@@ -140,6 +140,17 @@ pub extern "C" fn litelib_initialize_new_from_phrase(dangerous: bool, server: *c
|
||||
|
||||
//println!("Initializing with server: {}, seed: {}", server_str, seed_str);
|
||||
|
||||
// Shut down the existing client if one is running, to stop background threads
|
||||
if overwrite {
|
||||
let old_lc = match LIGHTCLIENT.lock() {
|
||||
Ok(l) => l.borrow().clone(),
|
||||
Err(poisoned) => poisoned.into_inner().borrow().clone(),
|
||||
};
|
||||
if let Some(lc) = old_lc {
|
||||
lc.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
let server = LightClientConfig::get_server_or_default(Some(server_str));
|
||||
let (config, _latest_block_height) = match LightClientConfig::create(server, dangerous) {
|
||||
Ok((c, h)) => {
|
||||
|
||||
Reference in New Issue
Block a user