Skip to content

Commit e01c793

Browse files
committed
Post-rustfmt cleanup
1 parent 6082c94 commit e01c793

File tree

1 file changed

+60
-72
lines changed

1 file changed

+60
-72
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 60 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6191,11 +6191,8 @@ where
61916191
Ok(decoded_onion) => decoded_onion,
61926192

61936193
Err((htlc_fail, reason)) => {
6194-
htlc_fails.push((
6195-
htlc_fail,
6196-
HTLCHandlingFailureType::InvalidOnion,
6197-
reason.into(),
6198-
));
6194+
let failure_type = HTLCHandlingFailureType::InvalidOnion;
6195+
htlc_fails.push((htlc_fail, failure_type, reason.into()));
61996196
continue;
62006197
},
62016198
};
@@ -6329,14 +6326,7 @@ where
63296326

63306327
let mut new_events = VecDeque::new();
63316328
let mut failed_forwards = Vec::new();
6332-
let mut phantom_receives: Vec<(
6333-
u64,
6334-
Option<PublicKey>,
6335-
OutPoint,
6336-
ChannelId,
6337-
u128,
6338-
Vec<(PendingHTLCInfo, u64)>,
6339-
)> = Vec::new();
6329+
let mut phantom_receives: Vec<PerSourcePendingForward> = Vec::new();
63406330
{
63416331
let mut forward_htlcs = new_hash_map();
63426332
mem::swap(&mut forward_htlcs, &mut self.forward_htlcs.lock().unwrap());
@@ -6540,13 +6530,10 @@ where
65406530
.filter_map(|chan| {
65416531
let balances =
65426532
chan.get_available_balances(&self.fee_estimator);
6543-
if outgoing_amt_msat
6544-
<= balances.next_outbound_htlc_limit_msat
6545-
&& outgoing_amt_msat
6546-
>= balances.next_outbound_htlc_minimum_msat && chan
6547-
.context
6548-
.is_usable()
6549-
{
6533+
let is_in_range = (balances.next_outbound_htlc_minimum_msat
6534+
..=balances.next_outbound_htlc_limit_msat)
6535+
.contains(&outgoing_amt_msat);
6536+
if is_in_range && chan.context.is_usable() {
65506537
Some((chan, balances))
65516538
} else {
65526539
None
@@ -6567,10 +6554,9 @@ where
65676554
{
65686555
chan
65696556
} else {
6570-
forwarding_channel_not_found!(core::iter::once(
6571-
forward_info
6572-
)
6573-
.chain(draining_pending_forwards));
6557+
let fwd_iter = core::iter::once(forward_info)
6558+
.chain(draining_pending_forwards);
6559+
forwarding_channel_not_found!(fwd_iter);
65746560
break;
65756561
}
65766562
},
@@ -6610,16 +6596,15 @@ where
66106596
.and_then(Channel::as_funded_mut)
66116597
{
66126598
let data = self.get_htlc_inbound_temp_fail_data(reason);
6599+
let failure_type = HTLCHandlingFailureType::Forward {
6600+
node_id: Some(chan.context.get_counterparty_node_id()),
6601+
channel_id: forward_chan_id,
6602+
};
66136603
failed_forwards.push((
66146604
htlc_source,
66156605
payment_hash,
66166606
HTLCFailReason::reason(reason, data),
6617-
HTLCHandlingFailureType::Forward {
6618-
node_id: Some(
6619-
chan.context.get_counterparty_node_id(),
6620-
),
6621-
channel_id: forward_chan_id,
6622-
},
6607+
failure_type,
66236608
));
66246609
} else {
66256610
forwarding_channel_not_found!(core::iter::once(
@@ -6834,22 +6819,28 @@ where
68346819
$htlc.value,
68356820
self.best_block.read().unwrap().height,
68366821
);
6822+
let short_channel_id = $htlc.prev_hop.short_channel_id;
6823+
let user_channel_id = $htlc.prev_hop.user_channel_id;
6824+
let counterparty_node_id =
6825+
$htlc.prev_hop.counterparty_node_id;
6826+
let channel_id = prev_channel_id;
6827+
let outpoint = prev_funding_outpoint;
6828+
let htlc_id = $htlc.prev_hop.htlc_id;
6829+
let incoming_packet_shared_secret =
6830+
$htlc.prev_hop.incoming_packet_shared_secret;
6831+
let cltv_expiry = Some(cltv_expiry);
68376832
failed_forwards.push((
68386833
HTLCSource::PreviousHopData(HTLCPreviousHopData {
6839-
short_channel_id: $htlc.prev_hop.short_channel_id,
6840-
user_channel_id: $htlc.prev_hop.user_channel_id,
6841-
counterparty_node_id: $htlc
6842-
.prev_hop
6843-
.counterparty_node_id,
6844-
channel_id: prev_channel_id,
6845-
outpoint: prev_funding_outpoint,
6846-
htlc_id: $htlc.prev_hop.htlc_id,
6847-
incoming_packet_shared_secret: $htlc
6848-
.prev_hop
6849-
.incoming_packet_shared_secret,
6834+
short_channel_id,
6835+
user_channel_id,
6836+
counterparty_node_id,
6837+
channel_id,
6838+
outpoint,
6839+
htlc_id,
6840+
incoming_packet_shared_secret,
68506841
phantom_shared_secret,
68516842
blinded_failure,
6852-
cltv_expiry: Some(cltv_expiry),
6843+
cltv_expiry,
68536844
}),
68546845
payment_hash,
68556846
HTLCFailReason::reason(
@@ -7231,7 +7222,8 @@ where
72317222
for (chan_id, chan) in peer_state.channel_by_id.iter_mut()
72327223
.filter_map(|(chan_id, chan)| chan.as_funded_mut().map(|chan| (chan_id, chan)))
72337224
{
7234-
let new_feerate = if chan.funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
7225+
let is_anchors_chan = chan.funding.get_channel_type().supports_anchors_zero_fee_htlc_tx();
7226+
let new_feerate = if is_anchors_chan {
72357227
anchor_feerate
72367228
} else {
72377229
non_anchor_feerate
@@ -7462,23 +7454,19 @@ where
74627454
// In this case we're not going to handle any timeouts of the parts here.
74637455
// This condition determining whether the MPP is complete here must match
74647456
// exactly the condition used in `process_pending_htlc_forwards`.
7465-
if payment.htlcs[0].total_msat
7466-
<= payment
7467-
.htlcs
7468-
.iter()
7469-
.fold(0, |total, htlc| total + htlc.sender_intended_value)
7470-
{
7457+
let htlc_total_msat =
7458+
payment.htlcs.iter().map(|h| h.sender_intended_value).sum();
7459+
if payment.htlcs[0].total_msat <= htlc_total_msat {
74717460
return true;
74727461
} else if payment.htlcs.iter_mut().any(|htlc| {
74737462
htlc.timer_ticks += 1;
74747463
return htlc.timer_ticks >= MPP_TIMEOUT_TICKS;
74757464
}) {
7476-
timed_out_mpp_htlcs.extend(
7477-
payment
7478-
.htlcs
7479-
.drain(..)
7480-
.map(|htlc: ClaimableHTLC| (htlc.prev_hop, *payment_hash)),
7481-
);
7465+
let htlcs = payment
7466+
.htlcs
7467+
.drain(..)
7468+
.map(|htlc: ClaimableHTLC| (htlc.prev_hop, *payment_hash));
7469+
timed_out_mpp_htlcs.extend(htlcs);
74827470
return false;
74837471
}
74847472
}
@@ -9943,15 +9931,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
99439931

99449932
#[inline]
99459933
fn forward_htlcs_without_forward_event(
9946-
&self,
9947-
per_source_pending_forwards: &mut [(
9948-
u64,
9949-
Option<PublicKey>,
9950-
OutPoint,
9951-
ChannelId,
9952-
u128,
9953-
Vec<(PendingHTLCInfo, u64)>,
9954-
)],
9934+
&self, per_source_pending_forwards: &mut [PerSourcePendingForward],
99559935
) -> bool {
99569936
let mut push_forward_event = false;
99579937
for &mut (
@@ -10038,7 +10018,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1003810018
Some(prev_channel_id),
1003910019
Some(forward_info.payment_hash),
1004010020
);
10041-
log_info!(logger, "Failed to forward incoming HTLC: detected duplicate intercepted payment over short channel id {}", scid);
10021+
log_info!(
10022+
logger,
10023+
"Failed to forward incoming HTLC: detected duplicate intercepted payment over short channel id {}",
10024+
scid
10025+
);
1004210026
let htlc_source =
1004310027
HTLCSource::PreviousHopData(HTLCPreviousHopData {
1004410028
short_channel_id: prev_short_channel_id,
@@ -10058,15 +10042,19 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1005810042
.incoming_cltv_expiry(),
1005910043
});
1006010044

10061-
failed_intercept_forwards.push((
10062-
htlc_source,
10063-
forward_info.payment_hash,
10064-
HTLCFailReason::from_failure_code(
10065-
LocalHTLCFailureReason::UnknownNextPeer,
10066-
),
10045+
let payment_hash = forward_info.payment_hash;
10046+
let reason = HTLCFailReason::from_failure_code(
10047+
LocalHTLCFailureReason::UnknownNextPeer,
10048+
);
10049+
let failure_type =
1006710050
HTLCHandlingFailureType::InvalidForward {
1006810051
requested_forward_scid: scid,
10069-
},
10052+
};
10053+
failed_intercept_forwards.push((
10054+
htlc_source,
10055+
payment_hash,
10056+
reason,
10057+
failure_type,
1007010058
));
1007110059
},
1007210060
}

0 commit comments

Comments
 (0)