Skip to content

Commit 6fb5bd3

Browse files
committed
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.
1 parent e6bc2b5 commit 6fb5bd3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lightning/src/chain/chainmonitor.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,20 @@ impl MonitorUpdateId {
9292
/// closed without broadcasting the latest state. See
9393
/// [`ChannelMonitorUpdateErr::PermanentFailure`] for more details.
9494
pub trait Persist<ChannelSigner: Sign> {
95-
/// Persist a new channel's data. The data can be stored any way you want, but the identifier
96-
/// provided by LDK is the channel's outpoint (and it is up to you to maintain a correct
97-
/// mapping between the outpoint and the stored channel data). Note that you **must** persist
98-
/// every new monitor to disk.
95+
/// Persist a new channel's data in response to a [`chain::Watch::watch_channel`] call. This is
96+
/// called by [`ChannelManager`] for new channels, or may be called directly, e.g. on startup.
97+
///
98+
/// The data can be stored any way you want, but the identifier provided by LDK is the
99+
/// channel's outpoint (and it is up to you to maintain a correct mapping between the outpoint
100+
/// and the stored channel data). Note that you **must** persist every new monitor to disk.
99101
///
100102
/// The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`],
101103
/// if you return [`ChannelMonitorUpdateErr::TemporaryFailure`].
102104
///
103105
/// See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`
104106
/// and [`ChannelMonitorUpdateErr`] for requirements when returning errors.
105107
///
108+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
106109
/// [`Writeable::write`]: crate::util::ser::Writeable::write
107110
fn persist_new_channel(&self, channel_id: OutPoint, data: &ChannelMonitor<ChannelSigner>, update_id: MonitorUpdateId) -> Result<(), ChannelMonitorUpdateErr>;
108111

0 commit comments

Comments
 (0)