fix rescan crash: shutdown old lightclient before overwriting

This commit is contained in:
2026-03-22 11:12:19 -05:00
parent f5d26dd34d
commit b7a04bebc1
3 changed files with 13 additions and 2 deletions

View File

@@ -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)) => {