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;
78
78
//! # &self, payer: &PublicKey, params: &RouteParameters,
79
79
//! # first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs
80
80
//! # ) -> Result<Route, LightningError> { unimplemented!() }
81
- //! # }
82
- //! # impl ScoringRouter for FakeRouter {
83
81
//! # fn notify_payment_path_failed(&self, path: &[&RouteHop], short_channel_id: u64) { unimplemented!() }
84
82
//! # fn notify_payment_path_successful(&self, path: &[&RouteHop]) { unimplemented!() }
85
83
//! # fn notify_payment_probe_successful(&self, path: &[&RouteHop]) { unimplemented!() }
@@ -146,7 +144,7 @@ use crate::prelude::*;
146
144
use lightning:: ln:: { PaymentHash , PaymentPreimage , PaymentSecret } ;
147
145
use lightning:: ln:: channelmanager:: { ChannelDetails , PaymentId , PaymentSendFailure } ;
148
146
use 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 } ;
150
148
use lightning:: util:: events:: { Event , EventHandler } ;
151
149
use lightning:: util:: logger:: Logger ;
152
150
use crate :: time_utils:: Time ;
@@ -186,7 +184,7 @@ mod sealed {
186
184
/// (C-not exported) generally all users should use the [`InvoicePayer`] type alias.
187
185
pub struct InvoicePayerUsingTime <
188
186
P : Deref ,
189
- R : ScoringRouter ,
187
+ R : Router ,
190
188
L : Deref ,
191
189
E : sealed:: BaseEventHandler ,
192
190
T : Time
@@ -279,30 +277,6 @@ pub trait Payer {
279
277
fn inflight_htlcs ( & self ) -> InFlightHtlcs ;
280
278
}
281
279
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
-
306
280
/// Strategies available to retry payment path failures for an [`Invoice`].
307
281
///
308
282
#[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
@@ -342,7 +316,7 @@ pub enum PaymentError {
342
316
Sending ( PaymentSendFailure ) ,
343
317
}
344
318
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 >
346
320
InvoicePayerUsingTime < P , R , L , E , T >
347
321
where
348
322
P :: Target : Payer ,
@@ -656,7 +630,7 @@ fn has_expired(route_params: &RouteParameters) -> bool {
656
630
} else { false }
657
631
}
658
632
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 >
660
634
InvoicePayerUsingTime < P , R , L , E , T >
661
635
where
662
636
P :: Target : Payer ,
@@ -723,7 +697,7 @@ where
723
697
}
724
698
}
725
699
726
- impl < P : Deref , R : ScoringRouter , L : Deref , E : EventHandler , T : Time >
700
+ impl < P : Deref , R : Router , L : Deref , E : EventHandler , T : Time >
727
701
EventHandler for InvoicePayerUsingTime < P , R , L , E , T >
728
702
where
729
703
P :: Target : Payer ,
@@ -737,7 +711,7 @@ where
737
711
}
738
712
}
739
713
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 >
741
715
InvoicePayerUsingTime < P , R , L , H , T >
742
716
where
743
717
P :: Target : Payer ,
@@ -757,15 +731,15 @@ where
757
731
mod tests {
758
732
use super :: * ;
759
733
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;
761
735
use bitcoin_hashes:: sha256:: Hash as Sha256 ;
762
736
use lightning:: ln:: PaymentPreimage ;
763
737
use lightning:: ln:: channelmanager;
764
738
use lightning:: ln:: features:: { ChannelFeatures , NodeFeatures } ;
765
739
use lightning:: ln:: functional_test_utils:: * ;
766
740
use lightning:: ln:: msgs:: { ChannelMessageHandler , ErrorAction , LightningError } ;
767
741
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 } ;
769
743
use lightning:: routing:: scoring:: { ChannelUsage , LockableScore , Score } ;
770
744
use lightning:: util:: test_utils:: TestLogger ;
771
745
use lightning:: util:: errors:: APIError ;
@@ -1726,9 +1700,7 @@ mod tests {
1726
1700
payment_params : Some ( route_params. payment_params . clone ( ) ) , ..Self :: route_for_value ( route_params. final_value_msat )
1727
1701
} )
1728
1702
}
1729
- }
1730
1703
1731
- impl ScoringRouter for TestRouter {
1732
1704
fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
1733
1705
self . scorer . lock ( ) . payment_path_failed ( path, short_channel_id) ;
1734
1706
}
@@ -1755,9 +1727,7 @@ mod tests {
1755
1727
) -> Result < Route , LightningError > {
1756
1728
Err ( LightningError { err : String :: new ( ) , action : ErrorAction :: IgnoreError } )
1757
1729
}
1758
- }
1759
1730
1760
- impl ScoringRouter for FailingRouter {
1761
1731
fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
1762
1732
1763
1733
fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
@@ -2045,8 +2015,7 @@ mod tests {
2045
2015
) -> Result < Route , LightningError > {
2046
2016
self . 0 . borrow_mut ( ) . pop_front ( ) . unwrap ( )
2047
2017
}
2048
- }
2049
- impl ScoringRouter for ManualRouter {
2018
+
2050
2019
fn notify_payment_path_failed ( & self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
2051
2020
2052
2021
fn notify_payment_path_successful ( & self , _path : & [ & RouteHop ] ) { }
0 commit comments