Skip to content

Commit 0ad6189

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 3232812 commit 0ad6189

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
@@ -3105,18 +3105,7 @@ macro_rules! handle_error {
31053105
} };
31063106
}
31073107

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

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

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

0 commit comments

Comments
 (0)