]> git.bitcoin.ninja Git - ldk-sample/commitdiff
Explicitly stop BackgroundProcessor
authorJeffrey Czyz <jkczyz@gmail.com>
Sun, 18 Jul 2021 17:33:15 +0000 (12:33 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Sun, 18 Jul 2021 17:33:15 +0000 (12:33 -0500)
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

index d24fcad81177ac75e66016a1b55d9e2f72807c0a..7c1a1034262b5460a4340eaedc396d0c88885b47 100644 (file)
@@ -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]