Skip to content

Commit d5c8465

Browse files
committed
Remove create_inflight_map from InvoicePayer
1 parent 8c57c70 commit d5c8465

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lightning-invoice/src/payment.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ where
520520

521521
let payer = self.payer.node_id();
522522
let first_hops = self.payer.first_hops();
523-
let inflight_htlcs = self.create_inflight_map();
523+
let inflight_htlcs = self.payer.inflight_htlcs();
524524
let route = self.router.find_route(
525525
&payer, &params, Some(&first_hops.iter().collect::<Vec<_>>()), inflight_htlcs
526526
).map_err(|e| PaymentError::Routing(e))?;
@@ -586,7 +586,7 @@ where
586586

587587
let payer = self.payer.node_id();
588588
let first_hops = self.payer.first_hops();
589-
let inflight_htlcs = self.create_inflight_map();
589+
let inflight_htlcs = self.payer.inflight_htlcs();
590590

591591
let route = self.router.find_route(
592592
&payer, &params, Some(&first_hops.iter().collect::<Vec<_>>()), inflight_htlcs
@@ -624,12 +624,6 @@ where
624624
pub fn remove_cached_payment(&self, payment_hash: &PaymentHash) {
625625
self.payment_cache.lock().unwrap().remove(payment_hash);
626626
}
627-
628-
/// Construct an [`InFlightHtlcs`] containing information about currently used up liquidity
629-
/// across payments.
630-
fn create_inflight_map(&self) -> InFlightHtlcs {
631-
self.payer.inflight_htlcs()
632-
}
633627
}
634628

635629
fn expiry_time_from_unix_epoch(invoice: &Invoice) -> Duration {
@@ -1470,7 +1464,7 @@ mod tests {
14701464

14711465
let payment_id = invoice_payer.pay_invoice(&invoice).unwrap();
14721466

1473-
let inflight_map = invoice_payer.create_inflight_map();
1467+
let inflight_map = invoice_payer.payer.inflight_htlcs();
14741468
// First path check
14751469
assert_eq!(inflight_map.0.get(&(0, false)).unwrap().clone(), 94);
14761470
assert_eq!(inflight_map.0.get(&(1, true)).unwrap().clone(), 84);
@@ -1484,7 +1478,7 @@ mod tests {
14841478
payment_id, payment_hash, path: route.paths[0].clone()
14851479
});
14861480

1487-
let inflight_map = invoice_payer.create_inflight_map();
1481+
let inflight_map = invoice_payer.payer.inflight_htlcs();
14881482

14891483
assert_eq!(inflight_map.0.get(&(0, false)), None);
14901484
assert_eq!(inflight_map.0.get(&(1, true)), None);
@@ -1642,7 +1636,7 @@ mod tests {
16421636
InvoicePayer::new(&payer, router, &logger, event_handler, Retry::Attempts(0));
16431637

16441638
invoice_payer.pay_invoice(&invoice_to_pay).unwrap();
1645-
let inflight_map = invoice_payer.create_inflight_map();
1639+
let inflight_map = invoice_payer.payer.inflight_htlcs();
16461640

16471641
// Only the second path, which failed with `MonitorUpdateInProgress` should be added to our
16481642
// inflight map because retries are disabled.
@@ -1673,7 +1667,7 @@ mod tests {
16731667
InvoicePayer::new(&payer, router, &logger, event_handler, Retry::Attempts(0));
16741668

16751669
invoice_payer.pay_invoice(&invoice_to_pay).unwrap();
1676-
let inflight_map = invoice_payer.create_inflight_map();
1670+
let inflight_map = invoice_payer.payer.inflight_htlcs();
16771671

16781672
// All paths successful, hence we check of the existence of all 5 hops.
16791673
assert_eq!(inflight_map.0.len(), 5);

0 commit comments

Comments
 (0)