@@ -236,26 +236,28 @@ fn handle_network_graph_update<L: Deref>(
236
236
}
237
237
238
238
fn update_scorer < ' a , S : ' static + Deref < Target = SC > + Send + Sync , SC : ' a + WriteableScore < ' a > > (
239
- scorer : & ' a S , event : & Event
239
+ scorer : & ' a S ,
240
+ event : & Event ,
241
+ score_params : & <S :: Target as Score >:: ScoreParams
240
242
) {
241
243
let mut score = scorer. lock ( ) ;
242
244
match event {
243
245
Event :: PaymentPathFailed { ref path, short_channel_id : Some ( scid) , .. } => {
244
- score. payment_path_failed ( path, * scid) ;
246
+ score. payment_path_failed ( path, * scid, score_params ) ;
245
247
} ,
246
248
Event :: PaymentPathFailed { ref path, payment_failed_permanently : true , .. } => {
247
249
// Reached if the destination explicitly failed it back. We treat this as a successful probe
248
250
// because the payment made it all the way to the destination with sufficient liquidity.
249
- score. probe_successful ( path) ;
251
+ score. probe_successful ( path, score_params ) ;
250
252
} ,
251
253
Event :: PaymentPathSuccessful { path, .. } => {
252
- score. payment_path_successful ( path) ;
254
+ score. payment_path_successful ( path, score_params ) ;
253
255
} ,
254
256
Event :: ProbeSuccessful { path, .. } => {
255
- score. probe_successful ( path) ;
257
+ score. probe_successful ( path, score_params ) ;
256
258
} ,
257
259
Event :: ProbeFailed { path, short_channel_id : Some ( scid) , .. } => {
258
- score. probe_failed ( path, * scid) ;
260
+ score. probe_failed ( path, * scid, score_params ) ;
259
261
} ,
260
262
_ => { } ,
261
263
}
@@ -766,7 +768,7 @@ impl BackgroundProcessor {
766
768
handle_network_graph_update ( network_graph, & event)
767
769
}
768
770
if let Some ( ref scorer) = scorer {
769
- update_scorer ( scorer, & event) ;
771
+ update_scorer ( scorer, & event, & 0 ) ;
770
772
}
771
773
event_handler. handle_event ( event) ;
772
774
} ;
@@ -1015,11 +1017,12 @@ mod tests {
1015
1017
}
1016
1018
1017
1019
impl Score for TestScorer {
1020
+ type ScoreParams = i32 ;
1018
1021
fn channel_penalty_msat (
1019
- & self , _short_channel_id : u64 , _source : & NodeId , _target : & NodeId , _usage : ChannelUsage
1022
+ & self , _short_channel_id : u64 , _source : & NodeId , _target : & NodeId , _usage : ChannelUsage , _score_params : & Self :: ScoreParams
1020
1023
) -> u64 { unimplemented ! ( ) ; }
1021
1024
1022
- fn payment_path_failed ( & mut self , actual_path : & Path , actual_short_channel_id : u64 ) {
1025
+ fn payment_path_failed ( & mut self , actual_path : & Path , actual_short_channel_id : u64 , _score_params : & Self :: ScoreParams ) {
1023
1026
if let Some ( expectations) = & mut self . event_expectations {
1024
1027
match expectations. pop_front ( ) . unwrap ( ) {
1025
1028
TestResult :: PaymentFailure { path, short_channel_id } => {
@@ -1039,7 +1042,7 @@ mod tests {
1039
1042
}
1040
1043
}
1041
1044
1042
- fn payment_path_successful ( & mut self , actual_path : & Path ) {
1045
+ fn payment_path_successful ( & mut self , actual_path : & Path , _score_params : & Self :: ScoreParams ) {
1043
1046
if let Some ( expectations) = & mut self . event_expectations {
1044
1047
match expectations. pop_front ( ) . unwrap ( ) {
1045
1048
TestResult :: PaymentFailure { path, .. } => {
@@ -1058,7 +1061,7 @@ mod tests {
1058
1061
}
1059
1062
}
1060
1063
1061
- fn probe_failed ( & mut self , actual_path : & Path , _: u64 ) {
1064
+ fn probe_failed ( & mut self , actual_path : & Path , _: u64 , _score_params : & Self :: ScoreParams ) {
1062
1065
if let Some ( expectations) = & mut self . event_expectations {
1063
1066
match expectations. pop_front ( ) . unwrap ( ) {
1064
1067
TestResult :: PaymentFailure { path, .. } => {
@@ -1076,7 +1079,7 @@ mod tests {
1076
1079
}
1077
1080
}
1078
1081
}
1079
- fn probe_successful ( & mut self , actual_path : & Path ) {
1082
+ fn probe_successful ( & mut self , actual_path : & Path , _score_params : & Self :: ScoreParams ) {
1080
1083
if let Some ( expectations) = & mut self . event_expectations {
1081
1084
match expectations. pop_front ( ) . unwrap ( ) {
1082
1085
TestResult :: PaymentFailure { path, .. } => {
@@ -1129,7 +1132,7 @@ mod tests {
1129
1132
let network_graph = Arc :: new ( NetworkGraph :: new ( network, logger. clone ( ) ) ) ;
1130
1133
let scorer = Arc :: new ( Mutex :: new ( TestScorer :: new ( ) ) ) ;
1131
1134
let seed = [ i as u8 ; 32 ] ;
1132
- let router = Arc :: new ( DefaultRouter :: new ( network_graph. clone ( ) , logger. clone ( ) , seed, scorer. clone ( ) ) ) ;
1135
+ let router = Arc :: new ( DefaultRouter :: new ( network_graph. clone ( ) , logger. clone ( ) , seed, scorer. clone ( ) , & 0 ) ) ;
1133
1136
let chain_source = Arc :: new ( test_utils:: TestChainSource :: new ( Network :: Testnet ) ) ;
1134
1137
let persister = Arc :: new ( FilesystemPersister :: new ( format ! ( "{}_persister_{}" , & persist_dir, i) ) ) ;
1135
1138
let now = Duration :: from_secs ( genesis_block. header . time as u64 ) ;
0 commit comments