Skip to content

Commit d53ab19

Browse files
committed
Rustfmt some channel.rs
1 parent b87a8e0 commit d53ab19

File tree

1 file changed

+88
-39
lines changed

1 file changed

+88
-39
lines changed

lightning/src/ln/channel.rs

Lines changed: 88 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10582,22 +10582,32 @@ where
1058210582
/// Queues up an outbound HTLC to send by placing it in the holding cell. You should call
1058310583
/// [`Self::maybe_free_holding_cell_htlcs`] in order to actually generate and send the
1058410584
/// commitment update.
10585-
#[rustfmt::skip]
1058610585
pub fn queue_add_htlc<F: Deref, L: Deref>(
10587-
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
10588-
onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
10589-
blinding_point: Option<PublicKey>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
10586+
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
10587+
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
10588+
blinding_point: Option<PublicKey>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1059010589
) -> Result<(), (LocalHTLCFailureReason, String)>
10591-
where F::Target: FeeEstimator, L::Target: Logger
10590+
where
10591+
F::Target: FeeEstimator,
10592+
L::Target: Logger,
1059210593
{
10593-
self
10594-
.send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true,
10595-
skimmed_fee_msat, blinding_point, fee_estimator, logger)
10596-
.map(|msg_opt| assert!(msg_opt.is_none(), "We forced holding cell?"))
10597-
.map_err(|err| {
10598-
debug_assert!(err.0.is_temporary(), "Queuing HTLC should return temporary error");
10599-
err
10600-
})
10594+
self.send_htlc(
10595+
amount_msat,
10596+
payment_hash,
10597+
cltv_expiry,
10598+
source,
10599+
onion_routing_packet,
10600+
true,
10601+
skimmed_fee_msat,
10602+
blinding_point,
10603+
fee_estimator,
10604+
logger,
10605+
)
10606+
.map(|msg_opt| assert!(msg_opt.is_none(), "We forced holding cell?"))
10607+
.map_err(|err| {
10608+
debug_assert!(err.0.is_temporary(), "Queuing HTLC should return temporary error");
10609+
err
10610+
})
1060110611
}
1060210612

1060310613
/// Adds a pending outbound HTLC to this channel, note that you probably want
@@ -10616,18 +10626,19 @@ where
1061610626
/// on this [`FundedChannel`] if `force_holding_cell` is false.
1061710627
///
1061810628
/// `Err`'s will always be temporary channel failures.
10619-
#[rustfmt::skip]
1062010629
fn send_htlc<F: Deref, L: Deref>(
10621-
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
10622-
onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
10630+
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
10631+
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
1062310632
skimmed_fee_msat: Option<u64>, blinding_point: Option<PublicKey>,
10624-
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
10633+
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1062510634
) -> Result<Option<msgs::UpdateAddHTLC>, (LocalHTLCFailureReason, String)>
10626-
where F::Target: FeeEstimator, L::Target: Logger
10635+
where
10636+
F::Target: FeeEstimator,
10637+
L::Target: Logger,
1062710638
{
10628-
if !matches!(self.context.channel_state, ChannelState::ChannelReady(_)) ||
10629-
self.context.channel_state.is_local_shutdown_sent() ||
10630-
self.context.channel_state.is_remote_shutdown_sent()
10639+
if !matches!(self.context.channel_state, ChannelState::ChannelReady(_))
10640+
|| self.context.channel_state.is_local_shutdown_sent()
10641+
|| self.context.channel_state.is_remote_shutdown_sent()
1063110642
{
1063210643
return Err((LocalHTLCFailureReason::ChannelNotReady,
1063310644
"Cannot send HTLC until channel is fully established and we haven't started shutting down".to_owned()));
@@ -10639,13 +10650,23 @@ where
1063910650

1064010651
let available_balances = self.get_available_balances(fee_estimator);
1064110652
if amount_msat < available_balances.next_outbound_htlc_minimum_msat {
10642-
return Err((LocalHTLCFailureReason::HTLCMinimum, format!("Cannot send less than our next-HTLC minimum - {} msat",
10643-
available_balances.next_outbound_htlc_minimum_msat)));
10653+
return Err((
10654+
LocalHTLCFailureReason::HTLCMinimum,
10655+
format!(
10656+
"Cannot send less than our next-HTLC minimum - {} msat",
10657+
available_balances.next_outbound_htlc_minimum_msat
10658+
),
10659+
));
1064410660
}
1064510661

1064610662
if amount_msat > available_balances.next_outbound_htlc_limit_msat {
10647-
return Err((LocalHTLCFailureReason::HTLCMaximum, format!("Cannot send more than our next-HTLC maximum - {} msat",
10648-
available_balances.next_outbound_htlc_limit_msat)));
10663+
return Err((
10664+
LocalHTLCFailureReason::HTLCMaximum,
10665+
format!(
10666+
"Cannot send more than our next-HTLC maximum - {} msat",
10667+
available_balances.next_outbound_htlc_limit_msat
10668+
),
10669+
));
1064910670
}
1065010671

1065110672
if self.context.channel_state.is_peer_disconnected() {
@@ -10655,16 +10676,26 @@ where
1065510676
// disconnected during the time the previous hop was doing the commitment dance we may
1065610677
// end up getting here after the forwarding delay. In any case, returning an
1065710678
// IgnoreError will get ChannelManager to do the right thing and fail backwards now.
10658-
return Err((LocalHTLCFailureReason::PeerOffline,
10659-
"Cannot send an HTLC while disconnected from channel counterparty".to_owned()));
10679+
return Err((
10680+
LocalHTLCFailureReason::PeerOffline,
10681+
"Cannot send an HTLC while disconnected from channel counterparty".to_owned(),
10682+
));
1066010683
}
1066110684

1066210685
let need_holding_cell = !self.context.channel_state.can_generate_new_commitment();
10663-
log_debug!(logger, "Pushing new outbound HTLC with hash {} for {} msat {}",
10664-
payment_hash, amount_msat,
10665-
if force_holding_cell { "into holding cell" }
10666-
else if need_holding_cell { "into holding cell as we're awaiting an RAA or monitor" }
10667-
else { "to peer" });
10686+
log_debug!(
10687+
logger,
10688+
"Pushing new outbound HTLC with hash {} for {} msat {}",
10689+
payment_hash,
10690+
amount_msat,
10691+
if force_holding_cell {
10692+
"into holding cell"
10693+
} else if need_holding_cell {
10694+
"into holding cell as we're awaiting an RAA or monitor"
10695+
} else {
10696+
"to peer"
10697+
}
10698+
);
1066810699

1066910700
if need_holding_cell {
1067010701
force_holding_cell = true;
@@ -10952,24 +10983,42 @@ where
1095210983
///
1095310984
/// Shorthand for calling [`Self::send_htlc`] followed by a commitment update, see docs on
1095410985
/// [`Self::send_htlc`] and [`Self::build_commitment_no_state_update`] for more info.
10955-
#[rustfmt::skip]
1095610986
pub fn send_htlc_and_commit<F: Deref, L: Deref>(
1095710987
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
1095810988
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
10959-
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
10989+
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1096010990
) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
10961-
where F::Target: FeeEstimator, L::Target: Logger
10991+
where
10992+
F::Target: FeeEstimator,
10993+
L::Target: Logger,
1096210994
{
10963-
let send_res = self.send_htlc(amount_msat, payment_hash, cltv_expiry, source,
10964-
onion_routing_packet, false, skimmed_fee_msat, None, fee_estimator, logger);
10995+
let send_res = self.send_htlc(
10996+
amount_msat,
10997+
payment_hash,
10998+
cltv_expiry,
10999+
source,
11000+
onion_routing_packet,
11001+
false,
11002+
skimmed_fee_msat,
11003+
None,
11004+
fee_estimator,
11005+
logger,
11006+
);
1096511007
// All [`LocalHTLCFailureReason`] errors are temporary, so they are [`ChannelError::Ignore`].
1096611008
match send_res.map_err(|(_, msg)| ChannelError::Ignore(msg))? {
1096711009
Some(_) => {
1096811010
let monitor_update = self.build_commitment_no_status_check(logger);
10969-
self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
11011+
self.monitor_updating_paused(
11012+
false,
11013+
true,
11014+
false,
11015+
Vec::new(),
11016+
Vec::new(),
11017+
Vec::new(),
11018+
);
1097011019
Ok(self.push_ret_blockable_mon_update(monitor_update))
1097111020
},
10972-
None => Ok(None)
11021+
None => Ok(None),
1097311022
}
1097411023
}
1097511024

0 commit comments

Comments
 (0)