Skip to content

Commit d844905

Browse files
committed
continue automatically after fail_htlc in receiving an HTLC
If we receive an HTLC and are processing it a potential MPP part, we always continue in the per-HTLC loop if we call the `fail_htlc` macro, thus its nice to actually do the `continue` therein rather than at the callsites.
1 parent 4cea521 commit d844905

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3276,7 +3276,7 @@ where
32763276
}
32773277
}
32783278
} else {
3279-
for forward_info in pending_forwards.drain(..) {
3279+
'next_forwardable_htlc: for forward_info in pending_forwards.drain(..) {
32803280
match forward_info {
32813281
HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
32823282
prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id,
@@ -3331,6 +3331,7 @@ where
33313331
HTLCFailReason::reason(0x4000 | 15, htlc_msat_height_data),
33323332
HTLCDestination::FailedPayment { payment_hash: $payment_hash },
33333333
));
3334+
continue 'next_forwardable_htlc;
33343335
}
33353336
}
33363337
let phantom_shared_secret = claimable_htlc.prev_hop.phantom_shared_secret;
@@ -3352,7 +3353,6 @@ where
33523353
let mut claimable_payments = self.claimable_payments.lock().unwrap();
33533354
if claimable_payments.pending_claiming_payments.contains_key(&payment_hash) {
33543355
fail_htlc!(claimable_htlc, payment_hash);
3355-
continue
33563356
}
33573357
let ref mut claimable_payment = claimable_payments.claimable_htlcs
33583358
.entry(payment_hash)
@@ -3365,7 +3365,6 @@ where
33653365
if let OnionPayload::Spontaneous(_) = htlcs[0].onion_payload {
33663366
log_trace!(self.logger, "Failing new HTLC with payment_hash {} as we already had an existing keysend HTLC with the same payment hash", log_bytes!(payment_hash.0));
33673367
fail_htlc!(claimable_htlc, payment_hash);
3368-
continue
33693368
}
33703369
}
33713370
let mut total_value = claimable_htlc.sender_intended_value;
@@ -3435,7 +3434,6 @@ where
34353434
Err(()) => {
34363435
log_trace!(self.logger, "Failing new HTLC with payment_hash {} as payment verification failed", log_bytes!(payment_hash.0));
34373436
fail_htlc!(claimable_htlc, payment_hash);
3438-
continue
34393437
}
34403438
};
34413439
if let Some(min_final_cltv_expiry_delta) = min_final_cltv_expiry_delta {
@@ -3444,7 +3442,6 @@ where
34443442
log_trace!(self.logger, "Failing new HTLC with payment_hash {} as its CLTV expiry was too soon (had {}, earliest expected {})",
34453443
log_bytes!(payment_hash.0), cltv_expiry, expected_min_expiry_height);
34463444
fail_htlc!(claimable_htlc, payment_hash);
3447-
continue;
34483445
}
34493446
}
34503447
check_total_value!(payment_data, payment_preimage);
@@ -3453,7 +3450,6 @@ where
34533450
let mut claimable_payments = self.claimable_payments.lock().unwrap();
34543451
if claimable_payments.pending_claiming_payments.contains_key(&payment_hash) {
34553452
fail_htlc!(claimable_htlc, payment_hash);
3456-
continue
34573453
}
34583454
match claimable_payments.claimable_htlcs.entry(payment_hash) {
34593455
hash_map::Entry::Vacant(e) => {
@@ -3488,7 +3484,6 @@ where
34883484
if payment_data.is_none() {
34893485
log_trace!(self.logger, "Failing new keysend HTLC with payment_hash {} because we already have an inbound payment with the same payment hash", log_bytes!(payment_hash.0));
34903486
fail_htlc!(claimable_htlc, payment_hash);
3491-
continue
34923487
};
34933488
let payment_data = payment_data.unwrap();
34943489
if inbound_payment.get().payment_secret != payment_data.payment_secret {

0 commit comments

Comments
 (0)