Skip to content

Commit b00376e

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 85d1e5f commit b00376e

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
@@ -10600,6 +10600,29 @@ where
1060010600
self.pending_outbound_payments.clear_pending_payments()
1060110601
}
1060210602

10603+
#[cfg(any(test, feature = "_test_utils"))]
10604+
pub(crate) fn get_and_clear_pending_raa_blockers(
10605+
&self,
10606+
) -> Vec<(ChannelId, Vec<RAAMonitorUpdateBlockingAction>)> {
10607+
let per_peer_state = self.per_peer_state.read().unwrap();
10608+
let mut pending_blockers = Vec::new();
10609+
10610+
for (_peer_pubkey, peer_state_mutex) in per_peer_state.iter() {
10611+
let mut peer_state = peer_state_mutex.lock().unwrap();
10612+
10613+
for (chan_id, actions) in peer_state.actions_blocking_raa_monitor_updates.iter() {
10614+
// Only collect the non-empty actions into `pending_blockers`.
10615+
if !actions.is_empty() {
10616+
pending_blockers.push((chan_id.clone(), actions.clone()));
10617+
}
10618+
}
10619+
10620+
peer_state.actions_blocking_raa_monitor_updates.clear();
10621+
}
10622+
10623+
pending_blockers
10624+
}
10625+
1060310626
/// When something which was blocking a channel from updating its [`ChannelMonitor`] (e.g. an
1060410627
/// [`Event`] being handled) completes, this should be called to restore the channel to normal
1060510628
/// operation. It will double-check that nothing *else* is also blocking the same channel from

0 commit comments

Comments
 (0)