From: Jeffrey Czyz Date: Sun, 18 Jul 2021 17:33:15 +0000 (-0500) Subject: Explicitly stop BackgroundProcessor X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=664bc4ac7fb9c5fa1fca0bcaaeb5c0faee318d19;p=ldk-sample 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. --- 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]