Skip to content

Commit c22adfc

Browse files
committed
Rewrite documentation now that we always use convert_channel_err
Now that we never call `locked_close_channel` directly, the documentation on it should be updated to note that it shouldn't be used, rather relying on `convert_channel_err`, which now gets much of the substantive documentation on closing logic. Similarly, as `finish_close_channel` is now only called from `handle_error` we update the docs on both to note the new semantics.
1 parent 5dcae5c commit c22adfc

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,18 +3107,7 @@ macro_rules! handle_error {
31073107
} };
31083108
}
31093109

3110-
/// When a channel is removed, two things need to happen:
3111-
/// (a) This must be called in the same `per_peer_state` lock as the channel-closing action,
3112-
/// (b) [`ChannelManager::finish_close_channel`] needs to be called without holding any locks
3113-
/// (except [`ChannelManager::total_consistency_lock`].
3114-
///
3115-
/// Note that this step can be skipped if the channel was never opened (through the creation of a
3116-
/// [`ChannelMonitor`]/channel funding transaction) to begin with.
3117-
///
3118-
/// For non-coop-close cases, you should generally prefer to call `convert_channel_err` and
3119-
/// [`handle_error`] instead (which delegate to this and [`ChannelManager::finish_close_channel`]),
3120-
/// as they ensure the relevant messages go out as well. In a coop close case, calling this
3121-
/// directly avoids duplicate error messages.
3110+
/// Do not call this directly, use `convert_channel_err` instead.
31223111
#[rustfmt::skip]
31233112
macro_rules! locked_close_channel {
31243113
($self: ident, $chan_context: expr, UNFUNDED) => {{
@@ -3166,7 +3155,18 @@ macro_rules! locked_close_channel {
31663155
}}
31673156
}
31683157

3169-
/// Returns (boolean indicating if we should remove the Channel object from memory, a mapped error)
3158+
/// When a channel is removed, two things need to happen:
3159+
/// (a) This must be called in the same `per_peer_state` lock as the channel-closing action,
3160+
/// (b) [`handle_error`] needs to be called without holding any locks (except
3161+
/// [`ChannelManager::total_consistency_lock`]), which then calls
3162+
/// [`ChannelManager::finish_close_channel`].
3163+
///
3164+
/// Note that this step can be skipped if the channel was never opened (through the creation of a
3165+
/// [`ChannelMonitor`]/channel funding transaction) to begin with.
3166+
///
3167+
/// Returns `(boolean indicating if we should remove the Channel object from memory, a mapped
3168+
/// error)`, except in the `COOP_CLOSE` case, where the bool is elided (it is always implicitly
3169+
/// true).
31703170
#[rustfmt::skip]
31713171
macro_rules! convert_channel_err {
31723172
($self: ident, $peer_state: expr, $err: expr, $chan: expr, $close: expr, $locked_close: expr, $channel_id: expr, _internal) => { {
@@ -4236,13 +4236,10 @@ where
42364236
}
42374237

42384238
/// When a channel is removed, two things need to happen:
4239-
/// (a) [`locked_close_channel`] must be called in the same `per_peer_state` lock as
4240-
/// the channel-closing action,
4241-
/// (b) this needs to be called without holding any locks (except
4242-
/// [`ChannelManager::total_consistency_lock`].
4243-
///
4244-
/// In non-coop-close cases, this is generally accomplished by calling [`convert_channel_err`]
4245-
/// followed by [`handle_error`].
4239+
/// (a) [`convert_channel_err`] must be called in the same `per_peer_state` lock as the
4240+
/// channel-closing action,
4241+
/// (b) [`handle_error`] needs to be called without holding any locks (except
4242+
/// [`ChannelManager::total_consistency_lock`]), which then calls this.
42464243
#[rustfmt::skip]
42474244
fn finish_close_channel(&self, mut shutdown_res: ShutdownResult) {
42484245
debug_assert_ne!(self.per_peer_state.held_by_thread(), LockHeldState::HeldByThread);

0 commit comments

Comments
 (0)