Get rid of Overlord Shutdown message (just do it via GLOBALS)

This commit is contained in:
Mike Dilger 2024-03-14 12:41:10 +13:00
parent fe6a0cec55
commit b3877fee79
3 changed files with 1 additions and 24 deletions

View File

@ -9,7 +9,6 @@ mod date_ago;
mod ui;
mod unsaved_settings;
use gossip_lib::comms::ToOverlordMessage;
use gossip_lib::Error;
use gossip_lib::GLOBALS;
use std::sync::atomic::Ordering;
@ -84,9 +83,7 @@ fn main() -> Result<(), Error> {
GLOBALS.wait_for_login_notify.notify_one();
// Tell the async parties to close down
if let Err(e) = initiate_shutdown() {
tracing::error!("{}", e);
}
GLOBALS.shutting_down.store(true, Ordering::Relaxed);
// Wait for the async thread to complete
async_thread.join().unwrap();
@ -95,10 +92,3 @@ fn main() -> Result<(), Error> {
Ok(())
}
// Any task can call this to shutdown
pub fn initiate_shutdown() -> Result<(), Error> {
let to_overlord = GLOBALS.to_overlord.clone();
let _ = to_overlord.send(ToOverlordMessage::Shutdown); // ignore errors
Ok(())
}

View File

@ -184,9 +184,6 @@ pub enum ToOverlordMessage {
/// Calls [subscribe_nip46](crate::Overlord::subscribe_nip46)
SubscribeNip46(Vec<RelayUrl>),
/// Calls [shutdown](crate::Overlord::shutdown)
Shutdown,
/// Calls [unlock_key](crate::Overlord::unlock_key)
UnlockKey(String),

View File

@ -727,9 +727,6 @@ impl Overlord {
ToOverlordMessage::SubscribeNip46(relays) => {
self.subscribe_nip46(relays).await?;
}
ToOverlordMessage::Shutdown => {
Self::shutdown()?;
}
ToOverlordMessage::UnlockKey(password) => {
Self::unlock_key(password)?;
}
@ -2891,13 +2888,6 @@ impl Overlord {
Ok(())
}
/// Shutdown gossip
pub fn shutdown() -> Result<(), Error> {
tracing::info!("Overlord shutting down");
GLOBALS.shutting_down.store(true, Ordering::Relaxed);
Ok(())
}
/// Unlock the private key with the given passphrase so that gossip can use it.
/// This is akin to logging in.
pub fn unlock_key(mut password: String) -> Result<(), Error> {