Skip to content

Commit 3dd05ab

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 c1e6a74 commit 3dd05ab

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,
@@ -3334,6 +3334,7 @@ where
33343334
HTLCFailReason::reason(0x4000 | 15, htlc_msat_height_data),
33353335
HTLCDestination::FailedPayment { payment_hash: $payment_hash },
33363336
));
3337+
continue 'next_forwardable_htlc;
33373338
}
33383339
}
33393340
let phantom_shared_secret = claimable_htlc.prev_hop.phantom_shared_secret;
@@ -3355,7 +3356,6 @@ where
33553356
let mut claimable_payments = self.claimable_payments.lock().unwrap();
33563357
if claimable_payments.pending_claiming_payments.contains_key(&payment_hash) {
33573358
fail_htlc!(claimable_htlc, payment_hash);
3358-
continue
33593359
}
33603360
let ref mut claimable_payment = claimable_payments.claimable_payments
33613361
.entry(payment_hash)
@@ -3371,7 +3371,6 @@ where
33713371
if let OnionPayload::Spontaneous(_) = htlcs[0].onion_payload {
33723372
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));
33733373
fail_htlc!(claimable_htlc, payment_hash);
3374-
continue
33753374
}
33763375
}
33773376
let mut total_value = claimable_htlc.sender_intended_value;
@@ -3447,7 +3446,6 @@ where
34473446
Err(()) => {
34483447
log_trace!(self.logger, "Failing new HTLC with payment_hash {} as payment verification failed", log_bytes!(payment_hash.0));
34493448
fail_htlc!(claimable_htlc, payment_hash);
3450-
continue
34513449
}
34523450
};
34533451
if let Some(min_final_cltv_expiry_delta) = min_final_cltv_expiry_delta {
@@ -3456,7 +3454,6 @@ where
34563454
log_trace!(self.logger, "Failing new HTLC with payment_hash {} as its CLTV expiry was too soon (had {}, earliest expected {})",
34573455
log_bytes!(payment_hash.0), cltv_expiry, expected_min_expiry_height);
34583456
fail_htlc!(claimable_htlc, payment_hash);
3459-
continue;
34603457
}
34613458
}
34623459
check_total_value!(payment_data, payment_preimage);
@@ -3465,7 +3462,6 @@ where
34653462
let mut claimable_payments = self.claimable_payments.lock().unwrap();
34663463
if claimable_payments.pending_claiming_payments.contains_key(&payment_hash) {
34673464
fail_htlc!(claimable_htlc, payment_hash);
3468-
continue
34693465
}
34703466
match claimable_payments.claimable_payments.entry(payment_hash) {
34713467
hash_map::Entry::Vacant(e) => {
@@ -3500,7 +3496,6 @@ where
35003496
if payment_data.is_none() {
35013497
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));
35023498
fail_htlc!(claimable_htlc, payment_hash);
3503-
continue
35043499
};
35053500
let payment_data = payment_data.unwrap();
35063501
if inbound_payment.get().payment_secret != payment_data.payment_secret {

0 commit comments

Comments
 (0)