Skip to content

Commit e067262

Browse files
documentation fixes
1 parent 627871c commit e067262

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

lightning/src/ln/data_persister.rs

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Logic for persisting data from ChannelMonitors on-disk. Per-platform data
1+
//! Logic for persisting data from ChannelMonitors on-disk. Sample data
22
//! persisters are separated into the lightning-persist-data crate. These
33
//! objects mainly interface with the ChainMonitor when a channel monitor is
44
//! added or updated, and when they are all synced on startup.
@@ -8,7 +8,7 @@ use chain::transaction::OutPoint;
88
use std::collections::HashMap;
99

1010
/// ChannelDataPersister is responsible for persisting channel data: this could
11-
/// mean writing once to disk, and/or uploading to several backup services.
11+
/// mean writing once to disk, and/or uploading to one or more backup services.
1212
///
1313
/// Note that for every new monitor, you **must** persist the new ChannelMonitor
1414
/// to disk/backups. And, on every update, you **must** persist either the
@@ -19,33 +19,22 @@ use std::collections::HashMap;
1919
/// are toxic, so it's important that whatever channel state is persisted is
2020
/// kept up-to-date.
2121
///
22-
/// Upon calls to update_channel_data, implementers of this trait should either
23-
/// persist the ChannelMonitorUpdate or the ChannelMonitor. If an implementer
24-
/// chooses to persist the updates only, they need to make sure that all the
25-
/// updates are applied to the ChannelMonitors *before* the set of channel
26-
/// monitors is given to the ChainMonitor at startup time (e.g., all monitors
27-
/// returned by `load_channel_data` must be up-to-date). If full ChannelMonitors
28-
/// are persisted, then there is no need to persist individual updates.
29-
///
30-
/// Note that there could be a performance tradeoff between persisting complete
31-
/// channel monitors on every update vs. persisting only updates and applying
32-
/// them in batches.
33-
///
3422
/// Given multiple backups, situations may arise where one or more backup sources
3523
/// have fallen behind or disagree on the current state. Because these backup
3624
/// sources don't have any transaction signing/broadcasting duties and are only
3725
/// supposed to be persisting bytes of data, backup sources may be considered
3826
/// "in consensus" if a majority of them agree on the current state and are on
39-
/// the highest known commitment number. See individual methods for more info.
27+
/// the highest known commitment number.
4028
pub trait ChannelDataPersister: Send + Sync {
4129
/// The concrete type which signs for transactions and provides access to our channel public
4230
/// keys.
4331
type Keys: ChannelKeys;
4432

45-
/// Persist a new channel's data. The majority of backups should agree on a
46-
/// channel's state and be on the latest [`update_id`]. The data
47-
/// can be stored with any file name/path, but the identifier provided is the
48-
/// channel's outpoint.
33+
/// Persist a new channel's data. The data can be stored with any file
34+
/// name/path, but the identifier provided is the channel's outpoint.
35+
/// Note that you **must** persist every new monitor to disk. See the
36+
/// ChannelDataPersister trait documentation for more details, and for
37+
/// information on consensus between backups.
4938
///
5039
/// See [`ChannelMonitor::write_for_disk`] for writing out a ChannelMonitor.
5140
///
@@ -58,11 +47,8 @@ pub trait ChannelDataPersister: Send + Sync {
5847
///
5948
/// Note that on every update, you **must** persist either the
6049
/// ChannelMonitorUpdate or the updated monitor itself to disk/backups.
61-
/// Otherwise, there is risk of situations such as revoking a transaction,
62-
/// then crashing before this revocation can be persisted, then
63-
/// unintentionally broadcasting a revoked transaction and losing money. This
64-
/// is a risk because previous channel states are toxic, so it's important
65-
/// that whatever channel state is persisted is kept up-to-date.
50+
/// See the ChannelDataPersister trait documentation for more details, and
51+
/// for information on consensus between backups.
6652
///
6753
/// If an implementer chooses to persist the updates only, they need to make
6854
/// sure that all the updates are applied to the ChannelMonitors *before* the
@@ -71,23 +57,24 @@ pub trait ChannelDataPersister: Send + Sync {
7157
/// If full ChannelMonitors are persisted, then there is no need to persist
7258
/// individual updates.
7359
///
74-
/// In the case where one or more backups fail, it's likely safe to only
75-
/// require that the majority of backups succeed and agree on the latest
76-
/// [`update_id`] to succeed this method.
60+
/// Note that there could be a performance tradeoff between persisting complete
61+
/// channel monitors on every update vs. persisting only updates and applying
62+
/// them in batches.
7763
///
7864
/// See [`ChannelMonitor::write_for_disk`] for writing out a ChannelMonitor
7965
/// and [`ChannelMonitorUpdate::write`] for writing out an update.
8066
///
8167
/// [`load_channel_data`]: trait.ChannelDataPersister.html#tymethod.load_channel_data
82-
/// [`update_id`]: struct.ChannelMonitorUpdate.html#structfield.update_id
8368
/// [`ChannelMonitor::write_for_disk`]: struct.ChannelMonitor.html#method.write_for_disk
8469
/// [`ChannelMonitorUpdate::write`]: struct.ChannelMonitorUpdate.html#method.write
8570
fn update_channel_data(&self, id: OutPoint, update: &ChannelMonitorUpdate, data: &ChannelMonitor<Self::Keys>) -> Result<(), ChannelMonitorUpdateErr>;
8671

8772
/// Load the data for all channels. Generally only called on startup. You must
8873
/// ensure that the ChannelMonitors returned are on the latest [`update_id`],
89-
/// with all of the updates given in [`update_channel_data`] applied. Otherwise,
90-
/// there is a risk of broadcasting a revoked transaction and losing money.
74+
/// with all of the updates given in [`update_channel_data`] applied.
75+
///
76+
/// See the ChannelDataPersister trait documentation for more details, and
77+
/// for information on consensus between backups.
9178
///
9279
/// See [`ChannelMonitor::read`] for deserializing a ChannelMonitor.
9380
///

0 commit comments

Comments
 (0)