@@ -47,32 +47,32 @@ pub use lightning_types::routing::{RouteHint, RouteHintHop};
47
47
/// it will create a one-hop path using the recipient as the introduction node if it is a announced
48
48
/// node. Otherwise, there is no way to find a path to the introduction node in order to send a
49
49
/// payment, and thus an `Err` is returned.
50
- pub struct DefaultRouter < G : Deref < Target = NetworkGraph < L > > , L : Deref , ES : Deref , S : Deref , SP : Sized , Sc : ScoreLookUp < ScoreParams = SP > > where
50
+ pub struct DefaultRouter < G : Deref < Target = NetworkGraph < L > > , L : Deref , ES : Deref , S : Deref > where
51
51
L :: Target : Logger ,
52
- S :: Target : for < ' a > LockableScore < ' a , ScoreLookUp = Sc > ,
52
+ S :: Target : for < ' a > LockableScore < ' a > ,
53
53
ES :: Target : EntropySource ,
54
54
{
55
55
network_graph : G ,
56
56
logger : L ,
57
57
entropy_source : ES ,
58
58
scorer : S ,
59
- score_params : SP ,
59
+ score_params : crate :: routing :: scoring :: ProbabilisticScoringFeeParameters ,
60
60
}
61
61
62
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , ES : Deref , S : Deref , SP : Sized , Sc : ScoreLookUp < ScoreParams = SP > > DefaultRouter < G , L , ES , S , SP , Sc > where
62
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , ES : Deref , S : Deref > DefaultRouter < G , L , ES , S > where
63
63
L :: Target : Logger ,
64
- S :: Target : for < ' a > LockableScore < ' a , ScoreLookUp = Sc > ,
64
+ S :: Target : for < ' a > LockableScore < ' a > ,
65
65
ES :: Target : EntropySource ,
66
66
{
67
67
/// Creates a new router.
68
- pub fn new ( network_graph : G , logger : L , entropy_source : ES , scorer : S , score_params : SP ) -> Self {
68
+ pub fn new ( network_graph : G , logger : L , entropy_source : ES , scorer : S , score_params : crate :: routing :: scoring :: ProbabilisticScoringFeeParameters ) -> Self {
69
69
Self { network_graph, logger, entropy_source, scorer, score_params }
70
70
}
71
71
}
72
72
73
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , ES : Deref , S : Deref , SP : Sized , Sc : ScoreLookUp < ScoreParams = SP > > Router for DefaultRouter < G , L , ES , S , SP , Sc > where
73
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , ES : Deref , S : Deref > Router for DefaultRouter < G , L , ES , S > where
74
74
L :: Target : Logger ,
75
- S :: Target : for < ' a > LockableScore < ' a , ScoreLookUp = Sc > ,
75
+ S :: Target : for < ' a > LockableScore < ' a > ,
76
76
ES :: Target : EntropySource ,
77
77
{
78
78
fn find_route (
@@ -244,8 +244,9 @@ impl<'a, S: Deref> ScorerAccountingForInFlightHtlcs<'a, S> where S::Target: Scor
244
244
}
245
245
246
246
impl < ' a , S : Deref > ScoreLookUp for ScorerAccountingForInFlightHtlcs < ' a , S > where S :: Target : ScoreLookUp {
247
+ #[ cfg( not( c_bindings) ) ]
247
248
type ScoreParams = <S :: Target as ScoreLookUp >:: ScoreParams ;
248
- fn channel_penalty_msat ( & self , candidate : & CandidateRouteHop , usage : ChannelUsage , score_params : & Self :: ScoreParams ) -> u64 {
249
+ fn channel_penalty_msat ( & self , candidate : & CandidateRouteHop , usage : ChannelUsage , score_params : & crate :: routing :: scoring :: ProbabilisticScoringFeeParameters ) -> u64 {
249
250
let target = match candidate. target ( ) {
250
251
Some ( target) => target,
251
252
None => return self . scorer . channel_penalty_msat ( candidate, usage, score_params) ,
@@ -2064,7 +2065,7 @@ fn sort_first_hop_channels(
2064
2065
pub fn find_route < L : Deref , GL : Deref , S : ScoreLookUp > (
2065
2066
our_node_pubkey : & PublicKey , route_params : & RouteParameters ,
2066
2067
network_graph : & NetworkGraph < GL > , first_hops : Option < & [ & ChannelDetails ] > , logger : L ,
2067
- scorer : & S , score_params : & S :: ScoreParams , random_seed_bytes : & [ u8 ; 32 ]
2068
+ scorer : & S , score_params : & crate :: routing :: scoring :: ProbabilisticScoringFeeParameters , random_seed_bytes : & [ u8 ; 32 ]
2068
2069
) -> Result < Route , LightningError >
2069
2070
where L :: Target : Logger , GL :: Target : Logger {
2070
2071
let graph_lock = network_graph. read_only ( ) ;
@@ -2076,7 +2077,7 @@ where L::Target: Logger, GL::Target: Logger {
2076
2077
2077
2078
pub ( crate ) fn get_route < L : Deref , S : ScoreLookUp > (
2078
2079
our_node_pubkey : & PublicKey , route_params : & RouteParameters , network_graph : & ReadOnlyNetworkGraph ,
2079
- first_hops : Option < & [ & ChannelDetails ] > , logger : L , scorer : & S , score_params : & S :: ScoreParams ,
2080
+ first_hops : Option < & [ & ChannelDetails ] > , logger : L , scorer : & S , score_params : & crate :: routing :: scoring :: ProbabilisticScoringFeeParameters ,
2080
2081
_random_seed_bytes : & [ u8 ; 32 ]
2081
2082
) -> Result < Route , LightningError >
2082
2083
where L :: Target : Logger {
@@ -3494,9 +3495,10 @@ fn build_route_from_hops_internal<L: Deref>(
3494
3495
}
3495
3496
3496
3497
impl ScoreLookUp for HopScorer {
3498
+ #[ cfg( not( c_bindings) ) ]
3497
3499
type ScoreParams = ( ) ;
3498
3500
fn channel_penalty_msat ( & self , candidate : & CandidateRouteHop ,
3499
- _usage : ChannelUsage , _score_params : & Self :: ScoreParams ) -> u64
3501
+ _usage : ChannelUsage , _score_params : & crate :: routing :: scoring :: ProbabilisticScoringFeeParameters ) -> u64
3500
3502
{
3501
3503
let mut cur_id = self . our_node_id ;
3502
3504
for i in 0 ..self . hop_ids . len ( ) {
@@ -6994,8 +6996,9 @@ mod tests {
6994
6996
fn write < W : Writer > ( & self , _w : & mut W ) -> Result < ( ) , crate :: io:: Error > { unimplemented ! ( ) }
6995
6997
}
6996
6998
impl ScoreLookUp for BadChannelScorer {
6999
+ #[ cfg( not( c_bindings) ) ]
6997
7000
type ScoreParams = ( ) ;
6998
- fn channel_penalty_msat ( & self , candidate : & CandidateRouteHop , _: ChannelUsage , _score_params : & Self :: ScoreParams ) -> u64 {
7001
+ fn channel_penalty_msat ( & self , candidate : & CandidateRouteHop , _: ChannelUsage , _score_params : & crate :: routing :: scoring :: ProbabilisticScoringFeeParameters ) -> u64 {
6999
7002
if candidate. short_channel_id ( ) == Some ( self . short_channel_id ) { u64:: max_value ( ) } else { 0 }
7000
7003
}
7001
7004
}
@@ -7010,8 +7013,9 @@ mod tests {
7010
7013
}
7011
7014
7012
7015
impl ScoreLookUp for BadNodeScorer {
7016
+ #[ cfg( not( c_bindings) ) ]
7013
7017
type ScoreParams = ( ) ;
7014
- fn channel_penalty_msat ( & self , candidate : & CandidateRouteHop , _: ChannelUsage , _score_params : & Self :: ScoreParams ) -> u64 {
7018
+ fn channel_penalty_msat ( & self , candidate : & CandidateRouteHop , _: ChannelUsage , _score_params : & crate :: routing :: scoring :: ProbabilisticScoringFeeParameters ) -> u64 {
7015
7019
if candidate. target ( ) == Some ( self . node_id ) { u64:: max_value ( ) } else { 0 }
7016
7020
}
7017
7021
}
@@ -8803,7 +8807,7 @@ pub(crate) mod bench_utils {
8803
8807
}
8804
8808
8805
8809
pub ( crate ) fn generate_test_routes < S : ScoreLookUp + ScoreUpdate > ( graph : & NetworkGraph < & TestLogger > , scorer : & mut S ,
8806
- score_params : & S :: ScoreParams , features : Bolt11InvoiceFeatures , mut seed : u64 ,
8810
+ score_params : & crate :: routing :: scoring :: ProbabilisticScoringFeeParameters , features : Bolt11InvoiceFeatures , mut seed : u64 ,
8807
8811
starting_amount : u64 , route_count : usize ,
8808
8812
) -> Vec < ( ChannelDetails , PaymentParameters , u64 ) > {
8809
8813
let payer = payer_pubkey ( ) ;
@@ -8933,7 +8937,7 @@ pub mod benches {
8933
8937
8934
8938
fn generate_routes < S : ScoreLookUp + ScoreUpdate > (
8935
8939
bench : & mut Criterion , graph : & NetworkGraph < & TestLogger > , mut scorer : S ,
8936
- score_params : & S :: ScoreParams , features : Bolt11InvoiceFeatures , starting_amount : u64 ,
8940
+ score_params : & crate :: routing :: scoring :: ProbabilisticScoringFeeParameters , features : Bolt11InvoiceFeatures , starting_amount : u64 ,
8937
8941
bench_name : & ' static str ,
8938
8942
) {
8939
8943
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
0 commit comments