Skip to content

Commit f752e7f

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 b0d0bd4 commit f752e7f

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
@@ -5142,36 +5142,50 @@ where
51425142
}
51435143

51445144
#[cfg(async_payments)]
5145-
#[rustfmt::skip]
51465145
fn initiate_async_payment(
5147-
&self, invoice: &StaticInvoice, payment_id: PaymentId
5146+
&self, invoice: &StaticInvoice, payment_id: PaymentId,
51485147
) -> Result<(), Bolt12PaymentError> {
51495148
let mut res = Ok(());
51505149
PersistenceNotifierGuard::optionally_notify(self, || {
51515150
let best_block_height = self.best_block.read().unwrap().height;
51525151
let features = self.bolt12_invoice_features();
51535152
let outbound_pmts_res = self.pending_outbound_payments.static_invoice_received(
5154-
invoice, payment_id, features, best_block_height, self.duration_since_epoch(),
5155-
&*self.entropy_source, &self.pending_events
5153+
invoice,
5154+
payment_id,
5155+
features,
5156+
best_block_height,
5157+
self.duration_since_epoch(),
5158+
&*self.entropy_source,
5159+
&self.pending_events,
51565160
);
51575161
match outbound_pmts_res {
51585162
Ok(()) => {},
5159-
Err(Bolt12PaymentError::UnexpectedInvoice) | Err(Bolt12PaymentError::DuplicateInvoice) => {
5163+
Err(Bolt12PaymentError::UnexpectedInvoice)
5164+
| Err(Bolt12PaymentError::DuplicateInvoice) => {
51605165
res = outbound_pmts_res.map(|_| ());
5161-
return NotifyOption::SkipPersistNoEvents
5166+
return NotifyOption::SkipPersistNoEvents;
51625167
},
51635168
Err(e) => {
51645169
res = Err(e);
5165-
return NotifyOption::DoPersist
5166-
}
5170+
return NotifyOption::DoPersist;
5171+
},
51675172
};
51685173

51695174
let entropy = &*self.entropy_source;
51705175

5171-
if self.flow.enqueue_held_htlc_available(entropy, invoice, payment_id, self.get_peers_for_blinded_path()).is_err() {
5172-
self.abandon_payment_with_reason(payment_id, PaymentFailureReason::BlindedPathCreationFailed);
5173-
res = Err(Bolt12PaymentError::BlindedPathCreationFailed);
5174-
return NotifyOption::DoPersist
5176+
let enqueue_held_htlc_available_res = self.flow.enqueue_held_htlc_available(
5177+
entropy,
5178+
invoice,
5179+
payment_id,
5180+
self.get_peers_for_blinded_path(),
5181+
);
5182+
if enqueue_held_htlc_available_res.is_err() {
5183+
self.abandon_payment_with_reason(
5184+
payment_id,
5185+
PaymentFailureReason::BlindedPathCreationFailed,
5186+
);
5187+
res = Err(Bolt12PaymentError::BlindedPathCreationFailed);
5188+
return NotifyOption::DoPersist;
51755189
};
51765190

51775191
NotifyOption::DoPersist
@@ -5181,27 +5195,36 @@ where
51815195
}
51825196

51835197
#[cfg(async_payments)]
5184-
#[rustfmt::skip]
51855198
fn send_payment_for_static_invoice(
5186-
&self, payment_id: PaymentId
5199+
&self, payment_id: PaymentId,
51875200
) -> Result<(), Bolt12PaymentError> {
51885201
let best_block_height = self.best_block.read().unwrap().height;
51895202
let mut res = Ok(());
51905203
PersistenceNotifierGuard::optionally_notify(self, || {
51915204
let outbound_pmts_res = self.pending_outbound_payments.send_payment_for_static_invoice(
5192-
payment_id, &self.router, self.list_usable_channels(), || self.compute_inflight_htlcs(),
5193-
&self.entropy_source, &self.node_signer, &self, &self.secp_ctx, best_block_height,
5194-
&self.logger, &self.pending_events, |args| self.send_payment_along_path(args)
5205+
payment_id,
5206+
&self.router,
5207+
self.list_usable_channels(),
5208+
|| self.compute_inflight_htlcs(),
5209+
&self.entropy_source,
5210+
&self.node_signer,
5211+
&self,
5212+
&self.secp_ctx,
5213+
best_block_height,
5214+
&self.logger,
5215+
&self.pending_events,
5216+
|args| self.send_payment_along_path(args),
51955217
);
51965218
match outbound_pmts_res {
5197-
Err(Bolt12PaymentError::UnexpectedInvoice) | Err(Bolt12PaymentError::DuplicateInvoice) => {
5219+
Err(Bolt12PaymentError::UnexpectedInvoice)
5220+
| Err(Bolt12PaymentError::DuplicateInvoice) => {
51985221
res = outbound_pmts_res.map(|_| ());
51995222
NotifyOption::SkipPersistNoEvents
52005223
},
52015224
other_res => {
52025225
res = other_res;
52035226
NotifyOption::DoPersist
5204-
}
5227+
},
52055228
}
52065229
});
52075230
res
@@ -10719,9 +10742,8 @@ where
1071910742
/// created via [`Self::create_async_receive_offer_builder`]. If `relative_expiry` is unset, the
1072010743
/// invoice's expiry will default to [`STATIC_INVOICE_DEFAULT_RELATIVE_EXPIRY`].
1072110744
#[cfg(async_payments)]
10722-
#[rustfmt::skip]
1072310745
pub fn create_static_invoice_builder<'a>(
10724-
&self, offer: &'a Offer, offer_nonce: Nonce, relative_expiry: Option<Duration>
10746+
&self, offer: &'a Offer, offer_nonce: Nonce, relative_expiry: Option<Duration>,
1072510747
) -> Result<StaticInvoiceBuilder<'a>, Bolt12SemanticError> {
1072610748
let entropy = &*self.entropy_source;
1072710749
let amount_msat = offer.amount().and_then(|amount| match amount {
@@ -10734,13 +10756,23 @@ where
1073410756

1073510757
let created_at = self.duration_since_epoch();
1073610758
let payment_secret = inbound_payment::create_for_spontaneous_payment(
10737-
&self.inbound_payment_key, amount_msat, relative_expiry_secs, created_at.as_secs(), None
10738-
).map_err(|()| Bolt12SemanticError::InvalidAmount)?;
10759+
&self.inbound_payment_key,
10760+
amount_msat,
10761+
relative_expiry_secs,
10762+
created_at.as_secs(),
10763+
None,
10764+
)
10765+
.map_err(|()| Bolt12SemanticError::InvalidAmount)?;
1073910766

1074010767
self.flow.create_static_invoice_builder(
10741-
&self.router, entropy, offer, offer_nonce, payment_secret,
10742-
relative_expiry_secs, self.list_usable_channels(),
10743-
self.get_peers_for_blinded_path()
10768+
&self.router,
10769+
entropy,
10770+
offer,
10771+
offer_nonce,
10772+
payment_secret,
10773+
relative_expiry_secs,
10774+
self.list_usable_channels(),
10775+
self.get_peers_for_blinded_path(),
1074410776
)
1074510777
}
1074610778

0 commit comments

Comments
 (0)