Skip to content

Commit

Permalink
Introduce get_and_clear_pending_raa_blockers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shaavan committed Jan 20, 2025
1 parent aa2c6fe commit 86a0109
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10667,6 +10667,29 @@ where
self.pending_outbound_payments.clear_pending_payments()
}

#[cfg(any(test, feature = "_test_utils"))]
pub(crate) fn get_and_clear_pending_raa_blockers(
&self,
) -> Vec<(ChannelId, Vec<RAAMonitorUpdateBlockingAction>)> {
let per_peer_state = self.per_peer_state.read().unwrap();
let mut pending_blockers = Vec::new();

for (_peer_pubkey, peer_state_mutex) in per_peer_state.iter() {
let mut peer_state = peer_state_mutex.lock().unwrap();

for (chan_id, actions) in peer_state.actions_blocking_raa_monitor_updates.iter() {
// Only collect the non-empty actions into `pending_blockers`.
if !actions.is_empty() {
pending_blockers.push((chan_id.clone(), actions.clone()));
}
}

peer_state.actions_blocking_raa_monitor_updates.clear();
}

pending_blockers
}

/// When something which was blocking a channel from updating its [`ChannelMonitor`] (e.g. an
/// [`Event`] being handled) completes, this should be called to restore the channel to normal
/// operation. It will double-check that nothing *else* is also blocking the same channel from
Expand Down

0 comments on commit 86a0109

Please sign in to comment.