Skip to content

Commit 86a0109

Browse files
committed
Introduce get_and_clear_pending_raa_blockers
Note: The `actions_blocking_raa_monitor_updates` list may contain stale entries in the form of `(channel_id, [])`, which do not represent actual dangling actions. To handle this, stale entries are ignored when accumulating pending actions before clearing them. This ensures that the logic focuses only on relevant actions and avoids unnecessary accumulation of already processed data.
1 parent aa2c6fe commit 86a0109

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10667,6 +10667,29 @@ where
1066710667
self.pending_outbound_payments.clear_pending_payments()
1066810668
}
1066910669

10670+
#[cfg(any(test, feature = "_test_utils"))]
10671+
pub(crate) fn get_and_clear_pending_raa_blockers(
10672+
&self,
10673+
) -> Vec<(ChannelId, Vec<RAAMonitorUpdateBlockingAction>)> {
10674+
let per_peer_state = self.per_peer_state.read().unwrap();
10675+
let mut pending_blockers = Vec::new();
10676+
10677+
for (_peer_pubkey, peer_state_mutex) in per_peer_state.iter() {
10678+
let mut peer_state = peer_state_mutex.lock().unwrap();
10679+
10680+
for (chan_id, actions) in peer_state.actions_blocking_raa_monitor_updates.iter() {
10681+
// Only collect the non-empty actions into `pending_blockers`.
10682+
if !actions.is_empty() {
10683+
pending_blockers.push((chan_id.clone(), actions.clone()));
10684+
}
10685+
}
10686+
10687+
peer_state.actions_blocking_raa_monitor_updates.clear();
10688+
}
10689+
10690+
pending_blockers
10691+
}
10692+
1067010693
/// When something which was blocking a channel from updating its [`ChannelMonitor`] (e.g. an
1067110694
/// [`Event`] being handled) completes, this should be called to restore the channel to normal
1067210695
/// operation. It will double-check that nothing *else* is also blocking the same channel from

0 commit comments

Comments
 (0)