7777//! # first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs
7878//! # ) -> Result<Route, LightningError> { unimplemented!() }
7979//! #
80- //! # fn notify_payment_path_failed(&self, path: Vec<& RouteHop> , short_channel_id: u64) { unimplemented!() }
81- //! # fn notify_payment_path_successful(&self, path: Vec<& RouteHop> ) { unimplemented!() }
82- //! # fn notify_payment_probe_successful(&self, path: Vec<& RouteHop> ) { unimplemented!() }
83- //! # fn notify_payment_probe_failed(&self, path: Vec<& RouteHop> , short_channel_id: u64) { unimplemented!() }
80+ //! # fn notify_payment_path_failed(&self, path: &[& RouteHop] , short_channel_id: u64) { unimplemented!() }
81+ //! # fn notify_payment_path_successful(&self, path: &[& RouteHop] ) { unimplemented!() }
82+ //! # fn notify_payment_probe_successful(&self, path: &[& RouteHop] ) { unimplemented!() }
83+ //! # fn notify_payment_probe_failed(&self, path: &[& RouteHop] , short_channel_id: u64) { unimplemented!() }
8484//! # }
8585//! #
8686//! # struct FakeScorer {}
@@ -273,13 +273,13 @@ pub trait Router {
273273 first_hops : Option < & [ & ChannelDetails ] > , inflight_htlcs : InFlightHtlcs
274274 ) -> Result < Route , LightningError > ;
275275 /// Lets the router know that payment through a specific path has failed.
276- fn notify_payment_path_failed ( & self , path : Vec < & RouteHop > , short_channel_id : u64 ) ;
276+ fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) ;
277277 /// Lets the router know that payment through a specific path was successful.
278- fn notify_payment_path_successful ( & self , path : Vec < & RouteHop > ) ;
278+ fn notify_payment_path_successful ( & self , path : & [ & RouteHop ] ) ;
279279 /// Lets the router know that a payment probe was successful.
280- fn notify_payment_probe_successful ( & self , path : Vec < & RouteHop > ) ;
280+ fn notify_payment_probe_successful ( & self , path : & [ & RouteHop ] ) ;
281281 /// Lets the router know that a payment probe failed.
282- fn notify_payment_probe_failed ( & self , path : Vec < & RouteHop > , short_channel_id : u64 ) ;
282+ fn notify_payment_probe_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) ;
283283}
284284
285285/// Strategies available to retry payment path failures for an [`Invoice`].
@@ -680,7 +680,7 @@ where
680680 } => {
681681 if let Some ( short_channel_id) = short_channel_id {
682682 let path = path. iter ( ) . collect :: < Vec < _ > > ( ) ;
683- self . router . notify_payment_path_failed ( path, * short_channel_id)
683+ self . router . notify_payment_path_failed ( & path, * short_channel_id)
684684 }
685685
686686 if payment_id. is_none ( ) {
@@ -703,7 +703,7 @@ where
703703 } ,
704704 Event :: PaymentPathSuccessful { path, .. } => {
705705 let path = path. iter ( ) . collect :: < Vec < _ > > ( ) ;
706- self . router . notify_payment_path_successful ( path) ;
706+ self . router . notify_payment_path_successful ( & path) ;
707707 } ,
708708 Event :: PaymentSent { payment_hash, .. } => {
709709 let mut payment_cache = self . payment_cache . lock ( ) . unwrap ( ) ;
@@ -715,13 +715,13 @@ where
715715 Event :: ProbeSuccessful { payment_hash, path, .. } => {
716716 log_trace ! ( self . logger, "Probe payment {} of {}msat was successful" , log_bytes!( payment_hash. 0 ) , path. last( ) . unwrap( ) . fee_msat) ;
717717 let path = path. iter ( ) . collect :: < Vec < _ > > ( ) ;
718- self . router . notify_payment_probe_successful ( path) ;
718+ self . router . notify_payment_probe_successful ( & path) ;
719719 } ,
720720 Event :: ProbeFailed { payment_hash, path, short_channel_id, .. } => {
721721 if let Some ( short_channel_id) = short_channel_id {
722722 log_trace ! ( self . logger, "Probe payment {} of {}msat failed at channel {}" , log_bytes!( payment_hash. 0 ) , path. last( ) . unwrap( ) . fee_msat, * short_channel_id) ;
723723 let path = path. iter ( ) . collect :: < Vec < _ > > ( ) ;
724- self . router . notify_payment_probe_failed ( path, * short_channel_id) ;
724+ self . router . notify_payment_probe_failed ( & path, * short_channel_id) ;
725725 }
726726 } ,
727727 _ => { } ,
@@ -741,8 +741,8 @@ pub struct InFlightHtlcs(HashMap<(u64, bool), u64>);
741741impl InFlightHtlcs {
742742 /// Returns liquidity in msat given the public key of the HTLC source, target, and short channel
743743 /// id.
744- pub fn used_liquidity_msat ( & self , source : & NodeId , target : & NodeId , channel_scid : u64 ) -> Option < & u64 > {
745- self . 0 . get ( & ( channel_scid, source < target) )
744+ pub fn used_liquidity_msat ( & self , source : & NodeId , target : & NodeId , channel_scid : u64 ) -> Option < u64 > {
745+ self . 0 . get ( & ( channel_scid, source < target) ) . map ( |v| * v )
746746 }
747747}
748748
@@ -1844,20 +1844,20 @@ mod tests {
18441844 } )
18451845 }
18461846
1847- fn notify_payment_path_failed ( & self , path : Vec < & RouteHop > , short_channel_id : u64 ) {
1848- self . scorer . lock ( ) . payment_path_failed ( & path, short_channel_id) ;
1847+ fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
1848+ self . scorer . lock ( ) . payment_path_failed ( path, short_channel_id) ;
18491849 }
18501850
1851- fn notify_payment_path_successful ( & self , path : Vec < & RouteHop > ) {
1852- self . scorer . lock ( ) . payment_path_successful ( & path) ;
1851+ fn notify_payment_path_successful ( & self , path : & [ & RouteHop ] ) {
1852+ self . scorer . lock ( ) . payment_path_successful ( path) ;
18531853 }
18541854
1855- fn notify_payment_probe_successful ( & self , path : Vec < & RouteHop > ) {
1856- self . scorer . lock ( ) . probe_successful ( & path) ;
1855+ fn notify_payment_probe_successful ( & self , path : & [ & RouteHop ] ) {
1856+ self . scorer . lock ( ) . probe_successful ( path) ;
18571857 }
18581858
1859- fn notify_payment_probe_failed ( & self , path : Vec < & RouteHop > , short_channel_id : u64 ) {
1860- self . scorer . lock ( ) . probe_failed ( & path, short_channel_id) ;
1859+ fn notify_payment_probe_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
1860+ self . scorer . lock ( ) . probe_failed ( path, short_channel_id) ;
18611861 }
18621862 }
18631863
@@ -1871,13 +1871,13 @@ mod tests {
18711871 Err ( LightningError { err : String :: new ( ) , action : ErrorAction :: IgnoreError } )
18721872 }
18731873
1874- fn notify_payment_path_failed ( & self , _path : Vec < & RouteHop > , _short_channel_id : u64 ) { }
1874+ fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
18751875
1876- fn notify_payment_path_successful ( & self , _path : Vec < & RouteHop > ) { }
1876+ fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
18771877
1878- fn notify_payment_probe_successful ( & self , _path : Vec < & RouteHop > ) { }
1878+ fn notify_payment_probe_successful ( & self , _path : & [ & RouteHop ] ) { }
18791879
1880- fn notify_payment_probe_failed ( & self , _path : Vec < & RouteHop > , _short_channel_id : u64 ) { }
1880+ fn notify_payment_probe_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
18811881 }
18821882
18831883 struct TestScorer {
@@ -2133,13 +2133,13 @@ mod tests {
21332133 self . 0 . borrow_mut ( ) . pop_front ( ) . unwrap ( )
21342134 }
21352135
2136- fn notify_payment_path_failed ( & self , _path : Vec < & RouteHop > , _short_channel_id : u64 ) { }
2136+ fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
21372137
2138- fn notify_payment_path_successful ( & self , _path : Vec < & RouteHop > ) { }
2138+ fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
21392139
2140- fn notify_payment_probe_successful ( & self , _path : Vec < & RouteHop > ) { }
2140+ fn notify_payment_probe_successful ( & self , _path : & [ & RouteHop ] ) { }
21412141
2142- fn notify_payment_probe_failed ( & self , _path : Vec < & RouteHop > , _short_channel_id : u64 ) { }
2142+ fn notify_payment_probe_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
21432143 }
21442144 impl ManualRouter {
21452145 fn expect_find_route ( & self , result : Result < Route , LightningError > ) {
0 commit comments