From 664bc4ac7fb9c5fa1fca0bcaaeb5c0faee318d19 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Sun, 18 Jul 2021 12:33:15 -0500 Subject: [PATCH] Explicitly stop BackgroundProcessor An upcoming change will stop the BackgroundProcessor's thread upon drop. Store the processor in a variable and explicitly stop it. Otherwise, the thread would be stopped immediately after it is started. --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index d24fcad..7c1a103 100644 --- a/src/main.rs +++ b/src/main.rs @@ -536,7 +536,7 @@ async fn start_ldk() { let persist_channel_manager_callback = move |node: &ChannelManager| FilesystemPersister::persist_manager(data_dir.clone(), &*node); // Step 17: Background Processing - BackgroundProcessor::start( + let background_processor = BackgroundProcessor::start( persist_channel_manager_callback, event_handler, chain_monitor.clone(), @@ -595,6 +595,9 @@ async fn start_ldk() { network, ) .await; + + // Stop the background processor. + background_processor.stop().unwrap(); } #[tokio::main] -- 2.39.5