Skip to content

Commit a4740f4

Browse files
committed
Add additional variants to handle_new_monitor_update!
In the coming commits we'll start handling `ChannelMonitorUpdate`s during channel closure in-line rather than after dropping locks via `finish_close_channel`. In order to make that easy, here we add a new `REMAIN_LOCKED_UPDATE_ACTIONS_PROCESSED_LATER` variant to `handle_new_monitor_update!` which can attempt to apply an update without dropping the locks and processing `MonitorUpdateCompletionAction`s immediately. In the coming commits we'll start handling `ChannelMonitorUpdate`s "like normal" for updates against closed channels. Here we set up the first step by adding a new `POST_CHANNEL_CLOSE` variant on `handle_new_monitor_update!` which attempts to handle the `ChannelMonitorUpdate` and handles completion actions if it finishes immediately, just like the pre-close variant.
1 parent 01bc5f7 commit a4740f4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3337,6 +3337,27 @@ macro_rules! handle_new_monitor_update {
33373337
let _ = in_flight_updates.remove(idx);
33383338
})
33393339
} };
3340+
(
3341+
$self: ident, $funding_txo: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr,
3342+
$per_peer_state_lock: expr, $logger: expr, $channel_id: expr, POST_CHANNEL_CLOSE
3343+
) => { {
3344+
let in_flight_updates;
3345+
let idx;
3346+
handle_new_monitor_update!($self, $funding_txo, $update, $peer_state, $logger,
3347+
$channel_id, in_flight_updates, idx, _internal_outer,
3348+
{
3349+
let _ = in_flight_updates.remove(idx);
3350+
if in_flight_updates.is_empty() {
3351+
let update_actions = $peer_state.monitor_update_blocked_actions
3352+
.remove(&$channel_id).unwrap_or(Vec::new());
3353+
3354+
mem::drop($peer_state_lock);
3355+
mem::drop($per_peer_state_lock);
3356+
3357+
$self.handle_monitor_update_completion_actions(update_actions);
3358+
}
3359+
})
3360+
} };
33403361
(
33413362
$self: ident, $funding_txo: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr,
33423363
$per_peer_state_lock: expr, $chan: expr

0 commit comments

Comments
 (0)