44
44
//! # use lightning::util::logger::{Logger, Record};
45
45
//! # use lightning::util::ser::{Writeable, Writer};
46
46
//! # use lightning_invoice::Invoice;
47
- //! # use lightning_invoice::payment::{InvoicePayer, Payer, Retry, ScoringRouter };
47
+ //! # use lightning_invoice::payment::{InvoicePayer, Payer, Retry};
48
48
//! # use secp256k1::PublicKey;
49
49
//! # use std::cell::RefCell;
50
50
//! # use std::ops::Deref;
77
77
//! # &self, payer: &PublicKey, params: &RouteParameters,
78
78
//! # first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs
79
79
//! # ) -> Result<Route, LightningError> { unimplemented!() }
80
- //! # }
81
- //! # impl ScoringRouter for FakeRouter {
82
80
//! # fn notify_payment_path_failed(&self, path: &[&RouteHop], short_channel_id: u64) { unimplemented!() }
83
81
//! # fn notify_payment_path_successful(&self, path: &[&RouteHop]) { unimplemented!() }
84
82
//! # fn notify_payment_probe_successful(&self, path: &[&RouteHop]) { unimplemented!() }
@@ -187,7 +185,7 @@ mod sealed {
187
185
/// (C-not exported) generally all users should use the [`InvoicePayer`] type alias.
188
186
pub struct InvoicePayerUsingTime <
189
187
P : Deref ,
190
- R : ScoringRouter ,
188
+ R : Router ,
191
189
L : Deref ,
192
190
E : sealed:: BaseEventHandler ,
193
191
T : Time
@@ -292,30 +290,6 @@ pub trait Payer {
292
290
fn abandon_payment ( & self , payment_id : PaymentId ) ;
293
291
}
294
292
295
- /// A trait defining behavior for a [`Router`] implementation that also supports scoring channels
296
- /// based on payment and probe success/failure.
297
- ///
298
- /// [`Router`]: lightning::routing::router::Router
299
- pub trait ScoringRouter : Router {
300
- /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values. Includes
301
- /// `PaymentHash` and `PaymentId` to be able to correlate the request with a specific payment.
302
- fn find_route_with_id (
303
- & self , payer : & PublicKey , route_params : & RouteParameters ,
304
- first_hops : Option < & [ & ChannelDetails ] > , inflight_htlcs : InFlightHtlcs ,
305
- _payment_hash : PaymentHash , _payment_id : PaymentId
306
- ) -> Result < Route , LightningError > {
307
- self . find_route ( payer, route_params, first_hops, inflight_htlcs)
308
- }
309
- /// Lets the router know that payment through a specific path has failed.
310
- fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) ;
311
- /// Lets the router know that payment through a specific path was successful.
312
- fn notify_payment_path_successful ( & self , path : & [ & RouteHop ] ) ;
313
- /// Lets the router know that a payment probe was successful.
314
- fn notify_payment_probe_successful ( & self , path : & [ & RouteHop ] ) ;
315
- /// Lets the router know that a payment probe failed.
316
- fn notify_payment_probe_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) ;
317
- }
318
-
319
293
/// Strategies available to retry payment path failures for an [`Invoice`].
320
294
///
321
295
#[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
@@ -355,7 +329,7 @@ pub enum PaymentError {
355
329
Sending ( PaymentSendFailure ) ,
356
330
}
357
331
358
- impl < P : Deref , R : ScoringRouter , L : Deref , E : sealed:: BaseEventHandler , T : Time >
332
+ impl < P : Deref , R : Router , L : Deref , E : sealed:: BaseEventHandler , T : Time >
359
333
InvoicePayerUsingTime < P , R , L , E , T >
360
334
where
361
335
P :: Target : Payer ,
@@ -763,7 +737,7 @@ fn has_expired(route_params: &RouteParameters) -> bool {
763
737
} else { false }
764
738
}
765
739
766
- impl < P : Deref , R : ScoringRouter , L : Deref , E : sealed:: BaseEventHandler , T : Time >
740
+ impl < P : Deref , R : Router , L : Deref , E : sealed:: BaseEventHandler , T : Time >
767
741
InvoicePayerUsingTime < P , R , L , E , T >
768
742
where
769
743
P :: Target : Payer ,
@@ -840,7 +814,7 @@ where
840
814
}
841
815
}
842
816
843
- impl < P : Deref , R : ScoringRouter , L : Deref , E : EventHandler , T : Time >
817
+ impl < P : Deref , R : Router , L : Deref , E : EventHandler , T : Time >
844
818
EventHandler for InvoicePayerUsingTime < P , R , L , E , T >
845
819
where
846
820
P :: Target : Payer ,
@@ -854,7 +828,7 @@ where
854
828
}
855
829
}
856
830
857
- impl < P : Deref , R : ScoringRouter , L : Deref , T : Time , F : Future , H : Fn ( Event ) -> F >
831
+ impl < P : Deref , R : Router , L : Deref , T : Time , F : Future , H : Fn ( Event ) -> F >
858
832
InvoicePayerUsingTime < P , R , L , H , T >
859
833
where
860
834
P :: Target : Payer ,
@@ -1956,9 +1930,7 @@ mod tests {
1956
1930
payment_params : Some ( route_params. payment_params . clone ( ) ) , ..Self :: route_for_value ( route_params. final_value_msat )
1957
1931
} )
1958
1932
}
1959
- }
1960
1933
1961
- impl ScoringRouter for TestRouter {
1962
1934
fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
1963
1935
self . scorer . lock ( ) . payment_path_failed ( path, short_channel_id) ;
1964
1936
}
@@ -1985,9 +1957,7 @@ mod tests {
1985
1957
) -> Result < Route , LightningError > {
1986
1958
Err ( LightningError { err : String :: new ( ) , action : ErrorAction :: IgnoreError } )
1987
1959
}
1988
- }
1989
1960
1990
- impl ScoringRouter for FailingRouter {
1991
1961
fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
1992
1962
1993
1963
fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
@@ -2249,8 +2219,7 @@ mod tests {
2249
2219
) -> Result < Route , LightningError > {
2250
2220
self . 0 . borrow_mut ( ) . pop_front ( ) . unwrap ( )
2251
2221
}
2252
- }
2253
- impl ScoringRouter for ManualRouter {
2222
+
2254
2223
fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
2255
2224
2256
2225
fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
0 commit comments