@@ -9465,58 +9465,41 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
94659465 WithContext::from(&self.logger, peer_id, chan_id, Some(payment_hash));
94669466 log_trace!(logger, "Handling PaymentClaimed monitor update completion action");
94679467
9468- if let Some((counterparty_node_id , chan_id, claim_ptr)) = pending_mpp_claim {
9468+ if let Some((cp_node_id , chan_id, claim_ptr)) = pending_mpp_claim {
94699469 let per_peer_state = self.per_peer_state.read().unwrap();
9470- per_peer_state.get(&counterparty_node_id ).map(|peer_state_mutex| {
9470+ per_peer_state.get(&cp_node_id ).map(|peer_state_mutex| {
94719471 let mut peer_state = peer_state_mutex.lock().unwrap();
94729472 let blockers_entry =
94739473 peer_state.actions_blocking_raa_monitor_updates.entry(chan_id);
94749474 if let btree_map::Entry::Occupied(mut blockers) = blockers_entry {
94759475 blockers.get_mut().retain(|blocker| {
9476- if let &RAAMonitorUpdateBlockingAction::ClaimedMPPPayment {
9477- pending_claim,
9478- } = &blocker
9479- {
9480- if *pending_claim == claim_ptr {
9481- let mut pending_claim_state_lock =
9482- pending_claim.0.lock().unwrap();
9483- let pending_claim_state =
9484- &mut *pending_claim_state_lock;
9485- pending_claim_state.channels_without_preimage.retain(
9486- |(cp, cid)| {
9487- let this_claim = *cp == counterparty_node_id
9488- && *cid == chan_id;
9489- if this_claim {
9490- pending_claim_state
9491- .channels_with_preimage
9492- .push((*cp, *cid));
9493- false
9494- } else {
9495- true
9496- }
9497- },
9498- );
9499- if pending_claim_state
9500- .channels_without_preimage
9501- .is_empty()
9502- {
9503- for (cp, cid) in pending_claim_state
9504- .channels_with_preimage
9505- .iter()
9506- {
9507- let freed_chan = (*cp, *cid, blocker.clone());
9508- freed_channels.push(freed_chan);
9509- }
9510- }
9511- !pending_claim_state
9512- .channels_without_preimage
9513- .is_empty()
9476+ let pending_claim = match &blocker {
9477+ RAAMonitorUpdateBlockingAction::ClaimedMPPPayment {
9478+ pending_claim,
9479+ } => pending_claim,
9480+ _ => return true,
9481+ };
9482+ if *pending_claim != claim_ptr {
9483+ return true;
9484+ }
9485+ let mut claim_state_lock = pending_claim.0.lock().unwrap();
9486+ let claim_state = &mut *claim_state_lock;
9487+ claim_state.channels_without_preimage.retain(|(cp, cid)| {
9488+ let this_claim = *cp == cp_node_id && *cid == chan_id;
9489+ if this_claim {
9490+ claim_state.channels_with_preimage.push((*cp, *cid));
9491+ false
95149492 } else {
95159493 true
95169494 }
9517- } else {
9518- true
9495+ });
9496+ if claim_state.channels_without_preimage.is_empty() {
9497+ for (cp, cid) in claim_state.channels_with_preimage.iter() {
9498+ let freed_chan = (*cp, *cid, blocker.clone());
9499+ freed_channels.push(freed_chan);
9500+ }
95199501 }
9502+ !claim_state.channels_without_preimage.is_empty()
95209503 });
95219504 if blockers.get().is_empty() {
95229505 blockers.remove();
0 commit comments