From 268675a743b7aa9740e00fff740e1cd85b1f1e92 Mon Sep 17 00:00:00 2001 From: Arik Sosman Date: Fri, 20 Sep 2024 01:30:49 +0900 Subject: [PATCH] Document monitor archival idempotency requirement. --- lightning/src/chain/chainmonitor.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs index afd9df628..4e578ff9c 100644 --- a/lightning/src/chain/chainmonitor.rs +++ b/lightning/src/chain/chainmonitor.rs @@ -162,6 +162,13 @@ pub trait Persist { /// /// Archiving the data in a backup location (rather than deleting it fully) is useful for /// hedging against data loss in case of unexpected failure. + /// + /// Note that if a crash occurs during the archiving process, and its implementation is not + /// atomic, a state may emerge with the archival operation only being partially complete. In + /// that scenario, the monitor may still be loaded on startup pending successful completion of + /// the archive process. Additionally, because the archive operation could be retried on + /// restart, this method must in that case be idempotent, ensuring it can handle scenarios where + /// the monitor already exists in the archive. fn archive_persisted_channel(&self, channel_funding_outpoint: OutPoint); } -- 2.39.5