@@ -6304,35 +6304,32 @@ where
6304
6304
return;
6305
6305
}
6306
6306
if valid_mpp {
6307
- let (source_claim_pairs, pending_claim_ptr_opt) = if sources.len() > 1 {
6308
- let mut pending_claims = PendingMPPClaim {
6309
- channels_without_preimage: Vec::new(),
6310
- channels_with_preimage: Vec::new(),
6311
- };
6312
- let (source_claim_pairs, channels_without_preimage) = sources.into_iter().filter_map(|htlc| {
6307
+ let pending_mpp_claim_ptr_opt = if sources.len() > 1 {
6308
+ let channels_without_preimage = sources.iter().filter_map(|htlc| {
6313
6309
if let Some(cp_id) = htlc.prev_hop.counterparty_node_id {
6314
- let htlc_id = htlc.prev_hop.htlc_id;
6315
- let chan_id = htlc.prev_hop.channel_id;
6316
- let chan_outpoint = htlc.prev_hop.outpoint;
6317
- Some((
6318
- (htlc, Some((cp_id, chan_id, htlc_id))),
6319
- (cp_id, chan_outpoint, chan_id, htlc_id),
6320
- ))
6310
+ let prev_hop = &htlc.prev_hop;
6311
+ Some((cp_id, prev_hop.outpoint, prev_hop.channel_id, prev_hop.htlc_id))
6321
6312
} else {
6322
6313
None
6323
6314
}
6324
- }).unzip::<_, _, Vec<_>, _>();
6325
- pending_claims.channels_without_preimage = channels_without_preimage;
6326
- (source_claim_pairs, Some(Arc::new(Mutex::new(pending_claims))))
6315
+ }).collect();
6316
+ Some(Arc::new(Mutex::new(PendingMPPClaim {
6317
+ channels_without_preimage,
6318
+ channels_with_preimage: Vec::new(),
6319
+ })))
6327
6320
} else {
6328
- (sources.into_iter().map(|htlc| (htlc, None)).collect(), None)
6321
+ None
6329
6322
};
6330
- for (htlc, mpp_claim) in source_claim_pairs {
6331
- let mut pending_mpp_claim = None;
6332
- let pending_claim_ptr = pending_claim_ptr_opt.as_ref().map(|pending_claim| {
6333
- pending_mpp_claim = mpp_claim.map(|(cp_id, chan_id, htlc_id)|
6334
- (cp_id, chan_id, htlc_id, PendingMPPClaimPointer(Arc::clone(pending_claim)))
6335
- );
6323
+ for htlc in sources {
6324
+ let this_mpp_claim = pending_mpp_claim_ptr_opt.as_ref().map(|pending_mpp_claim|
6325
+ if let Some(cp_id) = htlc.prev_hop.counterparty_node_id {
6326
+ let claim_ptr = PendingMPPClaimPointer(Arc::clone(pending_mpp_claim));
6327
+ Some((cp_id, htlc.prev_hop.channel_id, htlc.prev_hop.htlc_id, claim_ptr))
6328
+ } else {
6329
+ None
6330
+ }
6331
+ ).flatten();
6332
+ let raa_blocker = pending_mpp_claim_ptr_opt.as_ref().map(|pending_claim| {
6336
6333
RAAMonitorUpdateBlockingAction::ClaimedMPPPayment {
6337
6334
pending_claim: PendingMPPClaimPointer(Arc::clone(pending_claim)),
6338
6335
}
@@ -6341,7 +6338,7 @@ where
6341
6338
htlc.prev_hop, payment_preimage,
6342
6339
|_, definitely_duplicate| {
6343
6340
debug_assert!(!definitely_duplicate, "We shouldn't claim duplicatively from a payment");
6344
- (Some(MonitorUpdateCompletionAction::PaymentClaimed { payment_hash, pending_mpp_claim }), pending_claim_ptr )
6341
+ (Some(MonitorUpdateCompletionAction::PaymentClaimed { payment_hash, pending_mpp_claim: this_mpp_claim }), raa_blocker )
6345
6342
}
6346
6343
);
6347
6344
}
0 commit comments