loader: try to stop bitcoind if connected
This commit is contained in:
parent
29b20972c5
commit
320a6d700c
@ -217,15 +217,21 @@ impl Bitcoind {
|
||||
|
||||
/// Stop (internal) bitcoind.
|
||||
pub fn stop(&self) {
|
||||
match liana::BitcoinD::new(&self.config, "internal_bitcoind_stop".to_string()) {
|
||||
Ok(bitcoind) => {
|
||||
info!("Stopping internal bitcoind...");
|
||||
bitcoind.stop();
|
||||
info!("Stopped liana managed bitcoind");
|
||||
}
|
||||
Err(e) => {
|
||||
warn!("Could not create interface to internal bitcoind: '{}'.", e);
|
||||
}
|
||||
stop_bitcoind(&self.config);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stop_bitcoind(config: &BitcoindConfig) -> bool {
|
||||
match liana::BitcoinD::new(config, "internal_bitcoind_stop".to_string()) {
|
||||
Ok(bitcoind) => {
|
||||
info!("Stopping internal bitcoind...");
|
||||
bitcoind.stop();
|
||||
info!("Stopped liana managed bitcoind");
|
||||
true
|
||||
}
|
||||
Err(e) => {
|
||||
warn!("Could not create interface to internal bitcoind: '{}'.", e);
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ use crate::{
|
||||
config::Config as GUIConfig,
|
||||
wallet::{Wallet, WalletError},
|
||||
},
|
||||
bitcoind::{Bitcoind, StartInternalBitcoindError},
|
||||
bitcoind::{stop_bitcoind, Bitcoind, StartInternalBitcoindError},
|
||||
daemon::{client, embedded::EmbeddedDaemon, model::*, Daemon, DaemonError},
|
||||
};
|
||||
|
||||
@ -225,6 +225,15 @@ impl Loader {
|
||||
|
||||
if let Some(bitcoind) = &self.internal_bitcoind {
|
||||
bitcoind.stop();
|
||||
} else if self.gui_config.start_internal_bitcoind {
|
||||
if let Ok(config) = Config::from_file(self.gui_config.daemon_config_path.clone()) {
|
||||
if let Some(bitcoind_config) = &config.bitcoind_config {
|
||||
let mut stopped = false;
|
||||
while !stopped {
|
||||
stopped = stop_bitcoind(&bitcoind_config);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user