@@ -495,7 +495,7 @@ where
495
495
496
496
let payer = self . payer . node_id ( ) ;
497
497
let first_hops = self . payer . first_hops ( ) ;
498
- let inflight_htlcs = self . create_inflight_map ( & payment_hash ) ;
498
+ let inflight_htlcs = self . create_inflight_map ( ) ;
499
499
let route = self . router . find_route (
500
500
& payer, & params, & payment_hash, Some ( & first_hops. iter ( ) . collect :: < Vec < _ > > ( ) ) ,
501
501
& AccountForInFlightHtlcs { scorer : & mut self . scorer . lock ( ) , inflight_htlcs } )
@@ -621,7 +621,7 @@ where
621
621
622
622
let payer = self . payer . node_id ( ) ;
623
623
let first_hops = self . payer . first_hops ( ) ;
624
- let inflight_htlcs = self . create_inflight_map ( & payment_hash ) ;
624
+ let inflight_htlcs = self . create_inflight_map ( ) ;
625
625
626
626
let route = self . router . find_route (
627
627
& payer, & params, & payment_hash, Some ( & first_hops. iter ( ) . collect :: < Vec < _ > > ( ) ) ,
@@ -667,13 +667,12 @@ where
667
667
///
668
668
/// This function should be called whenever we need information about currently used up liquidity
669
669
/// across payments.
670
- pub fn create_inflight_map ( & self , payment_hash : & PaymentHash ) -> HashMap < ( u64 , bool ) , u64 > {
670
+ pub fn create_inflight_map ( & self ) -> HashMap < ( u64 , bool ) , u64 > {
671
+ let mut total_inflight_map: HashMap < ( u64 , bool ) , u64 > = HashMap :: new ( ) ;
671
672
// Make an attempt at finding existing payment information from `payment_cache`. If it
672
673
// does not exist, it probably is a fresh payment and we can just return an empty
673
674
// HashMap.
674
- if let Some ( payment_info) = self . payment_cache . lock ( ) . unwrap ( ) . get ( & payment_hash) {
675
- let mut total_inflight_map: HashMap < ( u64 , bool ) , u64 > = HashMap :: new ( ) ;
676
-
675
+ for ( key, payment_info) in self . payment_cache . lock ( ) . unwrap ( ) . iter ( ) {
677
676
for path in & payment_info. paths {
678
677
if path. is_empty ( ) { break } ;
679
678
// total_inflight_map needs to be direction-sensitive when keeping track of the HTLC value
@@ -697,11 +696,9 @@ where
697
696
. or_insert ( cumulative_msat) ;
698
697
}
699
698
}
700
-
701
- return total_inflight_map
702
- } else {
703
- return HashMap :: new ( )
704
699
}
700
+
701
+ total_inflight_map
705
702
}
706
703
}
707
704
@@ -1570,7 +1567,7 @@ mod tests {
1570
1567
1571
1568
let payment_id = invoice_payer. pay_invoice ( & invoice) . unwrap ( ) ;
1572
1569
1573
- let inflight_map = invoice_payer. create_inflight_map ( & payment_hash . unwrap ( ) ) ;
1570
+ let inflight_map = invoice_payer. create_inflight_map ( ) ;
1574
1571
// First path check
1575
1572
assert_eq ! ( inflight_map. get( & ( 0 , true ) ) . unwrap( ) . clone( ) , 94 ) ;
1576
1573
assert_eq ! ( inflight_map. get( & ( 1 , false ) ) . unwrap( ) . clone( ) , 84 ) ;
@@ -1583,7 +1580,7 @@ mod tests {
1583
1580
payment_id, payment_hash, path : route. paths [ 0 ] . clone ( )
1584
1581
} ) ;
1585
1582
1586
- let inflight_map = invoice_payer. create_inflight_map ( & payment_hash . unwrap ( ) ) ;
1583
+ let inflight_map = invoice_payer. create_inflight_map ( ) ;
1587
1584
1588
1585
assert_eq ! ( inflight_map. get( & ( 0 , true ) ) , None ) ;
1589
1586
assert_eq ! ( inflight_map. get( & ( 1 , false ) ) , None ) ;
0 commit comments