Skip to content

Commit 69867b5

Browse files
joostjagerclaude
andcommitted
Inline handle_monitor_update_completion! macro
Expand the macro at its three call sites and remove the macro definition, as it no longer provides significant abstraction benefit after refactoring the core logic into helper methods. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent cc3c1f9 commit 69867b5

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,41 +3291,23 @@ macro_rules! emit_initial_channel_ready_event {
32913291
};
32923292
}
32933293

3294-
/// Handles the completion steps for when a [`ChannelMonitorUpdate`] is applied to a live channel.
3295-
///
3296-
/// You should not add new direct calls to this, generally, rather rely on
3297-
/// `handle_new_monitor_update` or [`ChannelManager::channel_monitor_updated`] to call it for you.
3298-
///
3299-
/// Requires that the in-flight monitor update set for this channel is empty!
3300-
macro_rules! handle_monitor_update_completion {
3301-
($self: ident, $peer_state_lock: expr, $peer_state: expr, $per_peer_state_lock: expr, $chan: expr) => {{
3302-
let completion_data = $self.prepare_monitor_update_completion_data(
3303-
&mut $peer_state.in_flight_monitor_updates,
3304-
&mut $peer_state.monitor_update_blocked_actions,
3305-
&mut $peer_state.pending_msg_events,
3306-
$peer_state.is_connected,
3307-
$chan,
3308-
);
3309-
3310-
mem::drop($peer_state_lock);
3311-
mem::drop($per_peer_state_lock);
3312-
3313-
$self.handle_monitor_update_completion_data(completion_data);
3314-
}};
3315-
}
3316-
33173294
macro_rules! handle_initial_monitor {
33183295
($self: ident, $update_res: expr, $peer_state_lock: expr, $peer_state: expr, $per_peer_state_lock: expr, $chan: expr) => {
33193296
let logger = WithChannelContext::from(&$self.logger, &$chan.context, None);
33203297
let update_completed = $self.handle_monitor_update_res($update_res, logger);
33213298
if update_completed {
3322-
handle_monitor_update_completion!(
3323-
$self,
3324-
$peer_state_lock,
3325-
$peer_state,
3326-
$per_peer_state_lock,
3327-
$chan
3299+
let completion_data = $self.prepare_monitor_update_completion_data(
3300+
&mut $peer_state.in_flight_monitor_updates,
3301+
&mut $peer_state.monitor_update_blocked_actions,
3302+
&mut $peer_state.pending_msg_events,
3303+
$peer_state.is_connected,
3304+
$chan,
33283305
);
3306+
3307+
mem::drop($peer_state_lock);
3308+
mem::drop($per_peer_state_lock);
3309+
3310+
$self.handle_monitor_update_completion_data(completion_data);
33293311
}
33303312
};
33313313
}
@@ -3394,13 +3376,18 @@ macro_rules! handle_new_monitor_update {
33943376
$update,
33953377
);
33963378
if all_updates_complete {
3397-
handle_monitor_update_completion!(
3398-
$self,
3399-
$peer_state_lock,
3400-
$peer_state,
3401-
$per_peer_state_lock,
3402-
$chan
3379+
let completion_data = $self.prepare_monitor_update_completion_data(
3380+
&mut $peer_state.in_flight_monitor_updates,
3381+
&mut $peer_state.monitor_update_blocked_actions,
3382+
&mut $peer_state.pending_msg_events,
3383+
$peer_state.is_connected,
3384+
$chan,
34033385
);
3386+
3387+
mem::drop($peer_state_lock);
3388+
mem::drop($per_peer_state_lock);
3389+
3390+
$self.handle_monitor_update_completion_data(completion_data);
34043391
}
34053392
update_completed
34063393
}};
@@ -10124,7 +10111,18 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1012410111
.and_then(Channel::as_funded_mut)
1012510112
{
1012610113
if chan.is_awaiting_monitor_update() {
10127-
handle_monitor_update_completion!(self, peer_state_lock, peer_state, per_peer_state, chan);
10114+
let completion_data = self.prepare_monitor_update_completion_data(
10115+
&mut peer_state.in_flight_monitor_updates,
10116+
&mut peer_state.monitor_update_blocked_actions,
10117+
&mut peer_state.pending_msg_events,
10118+
peer_state.is_connected,
10119+
chan,
10120+
);
10121+
10122+
mem::drop(peer_state_lock);
10123+
mem::drop(per_peer_state);
10124+
10125+
self.handle_monitor_update_completion_data(completion_data);
1012810126
} else {
1012910127
log_trace!(logger, "Channel is open but not awaiting update");
1013010128
}

0 commit comments

Comments
 (0)