Skip to content

Commit 1532913

Browse files
Remove rustfmt skips from ChannelManager async payments code
This code is not at risk of unwanted rebase conflicts, so the skips can safely be removed. Also did one minor extraction into a variable.
1 parent 89db55b commit 1532913

File tree

1 file changed

+58
-26
lines changed

1 file changed

+58
-26
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5138,36 +5138,50 @@ where
51385138
}
51395139

51405140
#[cfg(async_payments)]
5141-
#[rustfmt::skip]
51425141
fn initiate_async_payment(
5143-
&self, invoice: &StaticInvoice, payment_id: PaymentId
5142+
&self, invoice: &StaticInvoice, payment_id: PaymentId,
51445143
) -> Result<(), Bolt12PaymentError> {
51455144
let mut res = Ok(());
51465145
PersistenceNotifierGuard::optionally_notify(self, || {
51475146
let best_block_height = self.best_block.read().unwrap().height;
51485147
let features = self.bolt12_invoice_features();
51495148
let outbound_pmts_res = self.pending_outbound_payments.static_invoice_received(
5150-
invoice, payment_id, features, best_block_height, self.duration_since_epoch(),
5151-
&*self.entropy_source, &self.pending_events
5149+
invoice,
5150+
payment_id,
5151+
features,
5152+
best_block_height,
5153+
self.duration_since_epoch(),
5154+
&*self.entropy_source,
5155+
&self.pending_events,
51525156
);
51535157
match outbound_pmts_res {
51545158
Ok(()) => {},
5155-
Err(Bolt12PaymentError::UnexpectedInvoice) | Err(Bolt12PaymentError::DuplicateInvoice) => {
5159+
Err(Bolt12PaymentError::UnexpectedInvoice)
5160+
| Err(Bolt12PaymentError::DuplicateInvoice) => {
51565161
res = outbound_pmts_res.map(|_| ());
5157-
return NotifyOption::SkipPersistNoEvents
5162+
return NotifyOption::SkipPersistNoEvents;
51585163
},
51595164
Err(e) => {
51605165
res = Err(e);
5161-
return NotifyOption::DoPersist
5162-
}
5166+
return NotifyOption::DoPersist;
5167+
},
51635168
};
51645169

51655170
let entropy = &*self.entropy_source;
51665171

5167-
if self.flow.enqueue_held_htlc_available(entropy, invoice, payment_id, self.get_peers_for_blinded_path()).is_err() {
5168-
self.abandon_payment_with_reason(payment_id, PaymentFailureReason::BlindedPathCreationFailed);
5169-
res = Err(Bolt12PaymentError::BlindedPathCreationFailed);
5170-
return NotifyOption::DoPersist
5172+
let enqueue_held_htlc_available_res = self.flow.enqueue_held_htlc_available(
5173+
entropy,
5174+
invoice,
5175+
payment_id,
5176+
self.get_peers_for_blinded_path(),
5177+
);
5178+
if enqueue_held_htlc_available_res.is_err() {
5179+
self.abandon_payment_with_reason(
5180+
payment_id,
5181+
PaymentFailureReason::BlindedPathCreationFailed,
5182+
);
5183+
res = Err(Bolt12PaymentError::BlindedPathCreationFailed);
5184+
return NotifyOption::DoPersist;
51715185
};
51725186

51735187
NotifyOption::DoPersist
@@ -5177,27 +5191,36 @@ where
51775191
}
51785192

51795193
#[cfg(async_payments)]
5180-
#[rustfmt::skip]
51815194
fn send_payment_for_static_invoice(
5182-
&self, payment_id: PaymentId
5195+
&self, payment_id: PaymentId,
51835196
) -> Result<(), Bolt12PaymentError> {
51845197
let best_block_height = self.best_block.read().unwrap().height;
51855198
let mut res = Ok(());
51865199
PersistenceNotifierGuard::optionally_notify(self, || {
51875200
let outbound_pmts_res = self.pending_outbound_payments.send_payment_for_static_invoice(
5188-
payment_id, &self.router, self.list_usable_channels(), || self.compute_inflight_htlcs(),
5189-
&self.entropy_source, &self.node_signer, &self, &self.secp_ctx, best_block_height,
5190-
&self.logger, &self.pending_events, |args| self.send_payment_along_path(args)
5201+
payment_id,
5202+
&self.router,
5203+
self.list_usable_channels(),
5204+
|| self.compute_inflight_htlcs(),
5205+
&self.entropy_source,
5206+
&self.node_signer,
5207+
&self,
5208+
&self.secp_ctx,
5209+
best_block_height,
5210+
&self.logger,
5211+
&self.pending_events,
5212+
|args| self.send_payment_along_path(args),
51915213
);
51925214
match outbound_pmts_res {
5193-
Err(Bolt12PaymentError::UnexpectedInvoice) | Err(Bolt12PaymentError::DuplicateInvoice) => {
5215+
Err(Bolt12PaymentError::UnexpectedInvoice)
5216+
| Err(Bolt12PaymentError::DuplicateInvoice) => {
51945217
res = outbound_pmts_res.map(|_| ());
51955218
NotifyOption::SkipPersistNoEvents
51965219
},
51975220
other_res => {
51985221
res = other_res;
51995222
NotifyOption::DoPersist
5200-
}
5223+
},
52015224
}
52025225
});
52035226
res
@@ -10717,9 +10740,8 @@ where
1071710740
/// created via [`Self::create_async_receive_offer_builder`]. If `relative_expiry` is unset, the
1071810741
/// invoice's expiry will default to [`STATIC_INVOICE_DEFAULT_RELATIVE_EXPIRY`].
1071910742
#[cfg(async_payments)]
10720-
#[rustfmt::skip]
1072110743
pub fn create_static_invoice_builder<'a>(
10722-
&self, offer: &'a Offer, offer_nonce: Nonce, relative_expiry: Option<Duration>
10744+
&self, offer: &'a Offer, offer_nonce: Nonce, relative_expiry: Option<Duration>,
1072310745
) -> Result<StaticInvoiceBuilder<'a>, Bolt12SemanticError> {
1072410746
let entropy = &*self.entropy_source;
1072510747
let amount_msat = offer.amount().and_then(|amount| match amount {
@@ -10732,13 +10754,23 @@ where
1073210754

1073310755
let created_at = self.duration_since_epoch();
1073410756
let payment_secret = inbound_payment::create_for_spontaneous_payment(
10735-
&self.inbound_payment_key, amount_msat, relative_expiry_secs, created_at.as_secs(), None
10736-
).map_err(|()| Bolt12SemanticError::InvalidAmount)?;
10757+
&self.inbound_payment_key,
10758+
amount_msat,
10759+
relative_expiry_secs,
10760+
created_at.as_secs(),
10761+
None,
10762+
)
10763+
.map_err(|()| Bolt12SemanticError::InvalidAmount)?;
1073710764

1073810765
self.flow.create_static_invoice_builder(
10739-
&self.router, entropy, offer, offer_nonce, payment_secret,
10740-
relative_expiry_secs, self.list_usable_channels(),
10741-
self.get_peers_for_blinded_path()
10766+
&self.router,
10767+
entropy,
10768+
offer,
10769+
offer_nonce,
10770+
payment_secret,
10771+
relative_expiry_secs,
10772+
self.list_usable_channels(),
10773+
self.get_peers_for_blinded_path(),
1074210774
)
1074310775
}
1074410776

0 commit comments

Comments
 (0)