From 6fb5bd36a7b83184029b599d7a07838e84cbaa52 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 19 Oct 2021 21:49:03 +0000 Subject: [PATCH] Clarify the contexts in which persist_new_channel may be called Its somewhat confusing that `persist_new_channel` is called on startup for an existing channel in common deployments, so we call it out explicitly. --- lightning/src/chain/chainmonitor.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs index 13a4ac378..71b0b3e50 100644 --- a/lightning/src/chain/chainmonitor.rs +++ b/lightning/src/chain/chainmonitor.rs @@ -92,10 +92,12 @@ impl MonitorUpdateId { /// closed without broadcasting the latest state. See /// [`ChannelMonitorUpdateErr::PermanentFailure`] for more details. pub trait Persist { - /// Persist a new channel's data. The data can be stored any way you want, but the identifier - /// provided by LDK is the channel's outpoint (and it is up to you to maintain a correct - /// mapping between the outpoint and the stored channel data). Note that you **must** persist - /// every new monitor to disk. + /// Persist a new channel's data in response to a [`chain::Watch::watch_channel`] call. This is + /// called by [`ChannelManager`] for new channels, or may be called directly, e.g. on startup. + /// + /// The data can be stored any way you want, but the identifier provided by LDK is the + /// channel's outpoint (and it is up to you to maintain a correct mapping between the outpoint + /// and the stored channel data). Note that you **must** persist every new monitor to disk. /// /// The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], /// if you return [`ChannelMonitorUpdateErr::TemporaryFailure`]. @@ -103,6 +105,7 @@ pub trait Persist { /// See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` /// and [`ChannelMonitorUpdateErr`] for requirements when returning errors. /// + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`Writeable::write`]: crate::util::ser::Writeable::write fn persist_new_channel(&self, channel_id: OutPoint, data: &ChannelMonitor, update_id: MonitorUpdateId) -> Result<(), ChannelMonitorUpdateErr>; -- 2.39.5