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, ScoringRouter };
47+ //! # use lightning_invoice::payment::{InvoicePayer, Payer, Retry};
4848//! # use secp256k1::PublicKey;
4949//! # use std::cell::RefCell;
5050//! # use std::ops::Deref;
7878//! # &self, payer: &PublicKey, params: &RouteParameters,
7979//! # first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs
8080//! # ) -> Result<Route, LightningError> { unimplemented!() }
81- //! # }
82- //! # impl ScoringRouter for FakeRouter {
8381//! # fn notify_payment_path_failed(&self, path: &[&RouteHop], short_channel_id: u64) { unimplemented!() }
8482//! # fn notify_payment_path_successful(&self, path: &[&RouteHop]) { unimplemented!() }
8583//! # fn notify_payment_probe_successful(&self, path: &[&RouteHop]) { unimplemented!() }
@@ -146,7 +144,7 @@ use crate::prelude::*;
146144use lightning:: ln:: { PaymentHash , PaymentPreimage , PaymentSecret } ;
147145use lightning:: ln:: channelmanager:: { ChannelDetails , PaymentId , PaymentSendFailure } ;
148146use lightning:: ln:: msgs:: LightningError ;
149- use lightning:: routing:: router:: { InFlightHtlcs , PaymentParameters , Route , RouteHop , RouteParameters , Router } ;
147+ use lightning:: routing:: router:: { InFlightHtlcs , PaymentParameters , Route , RouteParameters , Router } ;
150148use lightning:: util:: events:: { Event , EventHandler } ;
151149use lightning:: util:: logger:: Logger ;
152150use crate :: time_utils:: Time ;
@@ -186,7 +184,7 @@ mod sealed {
186184/// (C-not exported) generally all users should use the [`InvoicePayer`] type alias.
187185pub struct InvoicePayerUsingTime <
188186 P : Deref ,
189- R : ScoringRouter ,
187+ R : Router ,
190188 L : Deref ,
191189 E : sealed:: BaseEventHandler ,
192190 T : Time
@@ -279,30 +277,6 @@ pub trait Payer {
279277 fn inflight_htlcs ( & self ) -> InFlightHtlcs ;
280278}
281279
282- /// A trait defining behavior for a [`Router`] implementation that also supports scoring channels
283- /// based on payment and probe success/failure.
284- ///
285- /// [`Router`]: lightning::routing::router::Router
286- pub trait ScoringRouter : Router {
287- /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values. Includes
288- /// `PaymentHash` and `PaymentId` to be able to correlate the request with a specific payment.
289- fn find_route_with_id (
290- & self , payer : & PublicKey , route_params : & RouteParameters ,
291- first_hops : Option < & [ & ChannelDetails ] > , inflight_htlcs : InFlightHtlcs ,
292- _payment_hash : PaymentHash , _payment_id : PaymentId
293- ) -> Result < Route , LightningError > {
294- self . find_route ( payer, route_params, first_hops, inflight_htlcs)
295- }
296- /// Lets the router know that payment through a specific path has failed.
297- fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) ;
298- /// Lets the router know that payment through a specific path was successful.
299- fn notify_payment_path_successful ( & self , path : & [ & RouteHop ] ) ;
300- /// Lets the router know that a payment probe was successful.
301- fn notify_payment_probe_successful ( & self , path : & [ & RouteHop ] ) ;
302- /// Lets the router know that a payment probe failed.
303- fn notify_payment_probe_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) ;
304- }
305-
306280/// Strategies available to retry payment path failures for an [`Invoice`].
307281///
308282#[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
@@ -342,7 +316,7 @@ pub enum PaymentError {
342316 Sending ( PaymentSendFailure ) ,
343317}
344318
345- impl < P : Deref , R : ScoringRouter , L : Deref , E : sealed:: BaseEventHandler , T : Time >
319+ impl < P : Deref , R : Router , L : Deref , E : sealed:: BaseEventHandler , T : Time >
346320 InvoicePayerUsingTime < P , R , L , E , T >
347321where
348322 P :: Target : Payer ,
@@ -656,7 +630,7 @@ fn has_expired(route_params: &RouteParameters) -> bool {
656630 } else { false }
657631}
658632
659- impl < P : Deref , R : ScoringRouter , L : Deref , E : sealed:: BaseEventHandler , T : Time >
633+ impl < P : Deref , R : Router , L : Deref , E : sealed:: BaseEventHandler , T : Time >
660634 InvoicePayerUsingTime < P , R , L , E , T >
661635where
662636 P :: Target : Payer ,
@@ -723,7 +697,7 @@ where
723697 }
724698}
725699
726- impl < P : Deref , R : ScoringRouter , L : Deref , E : EventHandler , T : Time >
700+ impl < P : Deref , R : Router , L : Deref , E : EventHandler , T : Time >
727701 EventHandler for InvoicePayerUsingTime < P , R , L , E , T >
728702where
729703 P :: Target : Payer ,
@@ -737,7 +711,7 @@ where
737711 }
738712}
739713
740- impl < P : Deref , R : ScoringRouter , L : Deref , T : Time , F : Future , H : Fn ( Event ) -> F >
714+ impl < P : Deref , R : Router , L : Deref , T : Time , F : Future , H : Fn ( Event ) -> F >
741715 InvoicePayerUsingTime < P , R , L , H , T >
742716where
743717 P :: Target : Payer ,
@@ -757,15 +731,15 @@ where
757731mod tests {
758732 use super :: * ;
759733 use crate :: { InvoiceBuilder , Currency } ;
760- use crate :: utils:: { ScorerAccountingForInFlightHtlcs , create_invoice_from_channelmanager_and_duration_since_epoch} ;
734+ use crate :: utils:: create_invoice_from_channelmanager_and_duration_since_epoch;
761735 use bitcoin_hashes:: sha256:: Hash as Sha256 ;
762736 use lightning:: ln:: PaymentPreimage ;
763737 use lightning:: ln:: channelmanager;
764738 use lightning:: ln:: features:: { ChannelFeatures , NodeFeatures } ;
765739 use lightning:: ln:: functional_test_utils:: * ;
766740 use lightning:: ln:: msgs:: { ChannelMessageHandler , ErrorAction , LightningError } ;
767741 use lightning:: routing:: gossip:: { EffectiveCapacity , NodeId } ;
768- use lightning:: routing:: router:: { InFlightHtlcs , PaymentParameters , Route , RouteHop , Router } ;
742+ use lightning:: routing:: router:: { InFlightHtlcs , PaymentParameters , Route , RouteHop , Router , ScorerAccountingForInFlightHtlcs } ;
769743 use lightning:: routing:: scoring:: { ChannelUsage , LockableScore , Score } ;
770744 use lightning:: util:: test_utils:: TestLogger ;
771745 use lightning:: util:: errors:: APIError ;
@@ -1726,9 +1700,7 @@ mod tests {
17261700 payment_params : Some ( route_params. payment_params . clone ( ) ) , ..Self :: route_for_value ( route_params. final_value_msat )
17271701 } )
17281702 }
1729- }
17301703
1731- impl ScoringRouter for TestRouter {
17321704 fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
17331705 self . scorer . lock ( ) . payment_path_failed ( path, short_channel_id) ;
17341706 }
@@ -1755,9 +1727,7 @@ mod tests {
17551727 ) -> Result < Route , LightningError > {
17561728 Err ( LightningError { err : String :: new ( ) , action : ErrorAction :: IgnoreError } )
17571729 }
1758- }
17591730
1760- impl ScoringRouter for FailingRouter {
17611731 fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
17621732
17631733 fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
@@ -2045,8 +2015,7 @@ mod tests {
20452015 ) -> Result < Route , LightningError > {
20462016 self . 0 . borrow_mut ( ) . pop_front ( ) . unwrap ( )
20472017 }
2048- }
2049- impl ScoringRouter for ManualRouter {
2018+
20502019 fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
20512020
20522021 fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
0 commit comments