Skip to content

Commit e9719dd

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

File tree

1 file changed

+48
-66
lines changed

1 file changed

+48
-66
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 48 additions & 66 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,19 +6819,19 @@ where
68346819
$htlc.value,
68356820
self.best_block.read().unwrap().height,
68366821
);
6822+
let counterparty_node_id =
6823+
$htlc.prev_hop.counterparty_node_id;
6824+
let incoming_packet_shared_secret =
6825+
$htlc.prev_hop.incoming_packet_shared_secret;
68376826
failed_forwards.push((
68386827
HTLCSource::PreviousHopData(HTLCPreviousHopData {
68396828
short_channel_id: $htlc.prev_hop.short_channel_id,
68406829
user_channel_id: $htlc.prev_hop.user_channel_id,
6841-
counterparty_node_id: $htlc
6842-
.prev_hop
6843-
.counterparty_node_id,
6830+
counterparty_node_id,
68446831
channel_id: prev_channel_id,
68456832
outpoint: prev_funding_outpoint,
68466833
htlc_id: $htlc.prev_hop.htlc_id,
6847-
incoming_packet_shared_secret: $htlc
6848-
.prev_hop
6849-
.incoming_packet_shared_secret,
6834+
incoming_packet_shared_secret,
68506835
phantom_shared_secret,
68516836
blinded_failure,
68526837
cltv_expiry: Some(cltv_expiry),
@@ -7231,7 +7216,8 @@ where
72317216
for (chan_id, chan) in peer_state.channel_by_id.iter_mut()
72327217
.filter_map(|(chan_id, chan)| chan.as_funded_mut().map(|chan| (chan_id, chan)))
72337218
{
7234-
let new_feerate = if chan.funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
7219+
let is_anchors_chan = chan.funding.get_channel_type().supports_anchors_zero_fee_htlc_tx();
7220+
let new_feerate = if is_anchors_chan {
72357221
anchor_feerate
72367222
} else {
72377223
non_anchor_feerate
@@ -7462,23 +7448,19 @@ where
74627448
// In this case we're not going to handle any timeouts of the parts here.
74637449
// This condition determining whether the MPP is complete here must match
74647450
// 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-
{
7451+
let htlc_total_msat =
7452+
payment.htlcs.iter().map(|h| h.sender_intended_value).sum();
7453+
if payment.htlcs[0].total_msat <= htlc_total_msat {
74717454
return true;
74727455
} else if payment.htlcs.iter_mut().any(|htlc| {
74737456
htlc.timer_ticks += 1;
74747457
return htlc.timer_ticks >= MPP_TIMEOUT_TICKS;
74757458
}) {
7476-
timed_out_mpp_htlcs.extend(
7477-
payment
7478-
.htlcs
7479-
.drain(..)
7480-
.map(|htlc: ClaimableHTLC| (htlc.prev_hop, *payment_hash)),
7481-
);
7459+
let htlcs = payment
7460+
.htlcs
7461+
.drain(..)
7462+
.map(|htlc: ClaimableHTLC| (htlc.prev_hop, *payment_hash));
7463+
timed_out_mpp_htlcs.extend(htlcs);
74827464
return false;
74837465
}
74847466
}
@@ -9943,15 +9925,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
99439925

99449926
#[inline]
99459927
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-
)],
9928+
&self, per_source_pending_forwards: &mut [PerSourcePendingForward],
99559929
) -> bool {
99569930
let mut push_forward_event = false;
99579931
for &mut (
@@ -10038,7 +10012,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1003810012
Some(prev_channel_id),
1003910013
Some(forward_info.payment_hash),
1004010014
);
10041-
log_info!(logger, "Failed to forward incoming HTLC: detected duplicate intercepted payment over short channel id {}", scid);
10015+
log_info!(
10016+
logger,
10017+
"Failed to forward incoming HTLC: detected duplicate intercepted payment over short channel id {}",
10018+
scid
10019+
);
1004210020
let htlc_source =
1004310021
HTLCSource::PreviousHopData(HTLCPreviousHopData {
1004410022
short_channel_id: prev_short_channel_id,
@@ -10058,15 +10036,19 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1005810036
.incoming_cltv_expiry(),
1005910037
});
1006010038

10061-
failed_intercept_forwards.push((
10062-
htlc_source,
10063-
forward_info.payment_hash,
10064-
HTLCFailReason::from_failure_code(
10065-
LocalHTLCFailureReason::UnknownNextPeer,
10066-
),
10039+
let payment_hash = forward_info.payment_hash;
10040+
let reason = HTLCFailReason::from_failure_code(
10041+
LocalHTLCFailureReason::UnknownNextPeer,
10042+
);
10043+
let failure_type =
1006710044
HTLCHandlingFailureType::InvalidForward {
1006810045
requested_forward_scid: scid,
10069-
},
10046+
};
10047+
failed_intercept_forwards.push((
10048+
htlc_source,
10049+
payment_hash,
10050+
reason,
10051+
failure_type,
1007010052
));
1007110053
},
1007210054
}

0 commit comments

Comments
 (0)