mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-20 03:57:03 +00:00
Get rid of Overlord Shutdown message (just do it via GLOBALS)
This commit is contained in:
parent
fe6a0cec55
commit
b3877fee79
@ -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(())
|
||||
}
|
||||
|
@ -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),
|
||||
|
||||
|
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user