From 5307b5e8ceb2bb2ac9634eafd3c8b123d25da34f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 1 Aug 2021 02:42:42 +0000 Subject: [PATCH] Make BackgroundProcessor `#[must_use]` to avoid dropping immediately It is easy for users to have a bug where they drop a `BackgroundProcessor` immediately, causing it to start and then immediately stop. Instead, add a `#[must_use]` tag to provide a compiler warning for such instances. --- lightning-background-processor/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index 55ac14c0..afa3633b 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -39,6 +39,7 @@ use std::ops::Deref; /// then there is a risk of channels force-closing on startup when the manager realizes it's /// outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used /// for unilateral chain closure fees are at risk. +#[must_use = "BackgroundProcessor will immediately stop on drop. It should be stored until shutdown."] pub struct BackgroundProcessor { stop_thread: Arc, thread_handle: Option>>, -- 2.30.2