4444//! # use lightning::util::logger::{Logger, Record};
4545//! # use lightning::util::ser::{Writeable, Writer};
4646//! # use lightning_invoice::Invoice;
47- //! # use lightning_invoice::payment::{InvoicePayer, Payer, Retry, ProbingRouter };
47+ //! # use lightning_invoice::payment::{InvoicePayer, Payer, Retry, ScoringRouter };
4848//! # use secp256k1::PublicKey;
4949//! # use std::cell::RefCell;
5050//! # use std::ops::Deref;
7676//! # &self, payer: &PublicKey, params: &RouteParameters,
7777//! # first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs
7878//! # ) -> Result<Route, LightningError> { unimplemented!() }
79- //! #
79+ //! # }
80+ //! # impl ScoringRouter for FakeRouter {
8081//! # fn notify_payment_path_failed(&self, path: &[&RouteHop], short_channel_id: u64) { unimplemented!() }
8182//! # fn notify_payment_path_successful(&self, path: &[&RouteHop]) { unimplemented!() }
82- //! # }
83- //! # impl ProbingRouter for FakeRouter {
8483//! # fn notify_payment_probe_successful(&self, path: &[&RouteHop]) { unimplemented!() }
8584//! # fn notify_payment_probe_failed(&self, path: &[&RouteHop], short_channel_id: u64) { unimplemented!() }
8685//! # }
@@ -177,7 +176,7 @@ use crate::time_utils;
177176type ConfiguredTime = time_utils:: Eternity ;
178177
179178/// (C-not exported) generally all users should use the [`InvoicePayer`] type alias.
180- pub struct InvoicePayerUsingTime < P : Deref , R : ProbingRouter , L : Deref , E : EventHandler , T : Time >
179+ pub struct InvoicePayerUsingTime < P : Deref , R : ScoringRouter , L : Deref , E : EventHandler , T : Time >
181180where
182181 P :: Target : Payer ,
183182 L :: Target : Logger ,
@@ -266,10 +265,15 @@ pub trait Payer {
266265 fn abandon_payment ( & self , payment_id : PaymentId ) ;
267266}
268267
269- /// A trait defining behavior for a [`Router`] implementation that also supports probing.
268+ /// A trait defining behavior for a [`Router`] implementation that also supports probing
269+ /// and scoring based on payment success data.
270270///
271271/// [`Router`]: lightning::ln::channelmanager::Router
272- pub trait ProbingRouter : Router {
272+ pub trait ScoringRouter : Router {
273+ /// Lets the router know that payment through a specific path has failed.
274+ fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) ;
275+ /// Lets the router know that payment through a specific path was successful.
276+ fn notify_payment_path_successful ( & self , path : & [ & RouteHop ] ) ;
273277 /// Lets the router know that a payment probe was successful.
274278 fn notify_payment_probe_successful ( & self , path : & [ & RouteHop ] ) ;
275279 /// Lets the router know that a payment probe failed.
@@ -315,7 +319,7 @@ pub enum PaymentError {
315319 Sending ( PaymentSendFailure ) ,
316320}
317321
318- impl < P : Deref , R : ProbingRouter , L : Deref , E : EventHandler , T : Time > InvoicePayerUsingTime < P , R , L , E , T >
322+ impl < P : Deref , R : ScoringRouter , L : Deref , E : EventHandler , T : Time > InvoicePayerUsingTime < P , R , L , E , T >
319323where
320324 P :: Target : Payer ,
321325 L :: Target : Logger ,
@@ -649,7 +653,7 @@ fn has_expired(route_params: &RouteParameters) -> bool {
649653 } else { false }
650654}
651655
652- impl < P : Deref , R : ProbingRouter , L : Deref , E : EventHandler , T : Time > EventHandler for InvoicePayerUsingTime < P , R , L , E , T >
656+ impl < P : Deref , R : ScoringRouter , L : Deref , E : EventHandler , T : Time > EventHandler for InvoicePayerUsingTime < P , R , L , E , T >
653657where
654658 P :: Target : Payer ,
655659 L :: Target : Logger ,
@@ -1809,17 +1813,17 @@ mod tests {
18091813 payment_params : Some ( route_params. payment_params . clone ( ) ) , ..Self :: route_for_value ( route_params. final_value_msat )
18101814 } )
18111815 }
1816+ }
18121817
1818+ impl ScoringRouter for TestRouter {
18131819 fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
18141820 self . scorer . lock ( ) . payment_path_failed ( path, short_channel_id) ;
18151821 }
18161822
18171823 fn notify_payment_path_successful ( & self , path : & [ & RouteHop ] ) {
18181824 self . scorer . lock ( ) . payment_path_successful ( path) ;
18191825 }
1820- }
18211826
1822- impl ProbingRouter for TestRouter {
18231827 fn notify_payment_probe_successful ( & self , path : & [ & RouteHop ] ) {
18241828 self . scorer . lock ( ) . probe_successful ( path) ;
18251829 }
@@ -1838,13 +1842,13 @@ mod tests {
18381842 ) -> Result < Route , LightningError > {
18391843 Err ( LightningError { err : String :: new ( ) , action : ErrorAction :: IgnoreError } )
18401844 }
1845+ }
18411846
1847+ impl ScoringRouter for FailingRouter {
18421848 fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
18431849
18441850 fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
1845- }
18461851
1847- impl ProbingRouter for FailingRouter {
18481852 fn notify_payment_probe_successful ( & self , _path : & [ & RouteHop ] ) { }
18491853
18501854 fn notify_payment_probe_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
@@ -2102,12 +2106,12 @@ mod tests {
21022106 ) -> Result < Route , LightningError > {
21032107 self . 0 . borrow_mut ( ) . pop_front ( ) . unwrap ( )
21042108 }
2105-
2109+ }
2110+ impl ScoringRouter for ManualRouter {
21062111 fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
21072112
21082113 fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
2109- }
2110- impl ProbingRouter for ManualRouter {
2114+
21112115 fn notify_payment_probe_successful ( & self , _path : & [ & RouteHop ] ) { }
21122116
21132117 fn notify_payment_probe_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
0 commit comments