@@ -34,7 +34,7 @@ use lightning::ln::peer_handler::APeerManager;
34
34
use lightning:: routing:: gossip:: { NetworkGraph , P2PGossipSync } ;
35
35
use lightning:: routing:: utxo:: UtxoLookup ;
36
36
use lightning:: routing:: router:: Router ;
37
- use lightning:: routing:: scoring:: { Score , WriteableScore } ;
37
+ use lightning:: routing:: scoring:: { ScoreUpdate , WriteableScore } ;
38
38
use lightning:: util:: logger:: Logger ;
39
39
use lightning:: util:: persist:: Persister ;
40
40
#[ cfg( feature = "std" ) ]
@@ -241,23 +241,27 @@ fn handle_network_graph_update<L: Deref>(
241
241
fn update_scorer < ' a , S : ' static + Deref < Target = SC > + Send + Sync , SC : ' a + WriteableScore < ' a > > (
242
242
scorer : & ' a S , event : & Event
243
243
) -> bool {
244
- let mut score = scorer. lock ( ) ;
245
244
match event {
246
245
Event :: PaymentPathFailed { ref path, short_channel_id : Some ( scid) , .. } => {
246
+ let mut score = scorer. write_lock ( ) ;
247
247
score. payment_path_failed ( path, * scid) ;
248
248
} ,
249
249
Event :: PaymentPathFailed { ref path, payment_failed_permanently : true , .. } => {
250
250
// Reached if the destination explicitly failed it back. We treat this as a successful probe
251
251
// because the payment made it all the way to the destination with sufficient liquidity.
252
+ let mut score = scorer. write_lock ( ) ;
252
253
score. probe_successful ( path) ;
253
254
} ,
254
255
Event :: PaymentPathSuccessful { path, .. } => {
256
+ let mut score = scorer. write_lock ( ) ;
255
257
score. payment_path_successful ( path) ;
256
258
} ,
257
259
Event :: ProbeSuccessful { path, .. } => {
260
+ let mut score = scorer. write_lock ( ) ;
258
261
score. probe_successful ( path) ;
259
262
} ,
260
263
Event :: ProbeFailed { path, short_channel_id : Some ( scid) , .. } => {
264
+ let mut score = scorer. write_lock ( ) ;
261
265
score. probe_failed ( path, * scid) ;
262
266
} ,
263
267
_ => return false ,
@@ -858,7 +862,7 @@ mod tests {
858
862
use lightning:: ln:: peer_handler:: { PeerManager , MessageHandler , SocketDescriptor , IgnoringMessageHandler } ;
859
863
use lightning:: routing:: gossip:: { NetworkGraph , NodeId , P2PGossipSync } ;
860
864
use lightning:: routing:: router:: { DefaultRouter , Path , RouteHop } ;
861
- use lightning:: routing:: scoring:: { ChannelUsage , Score } ;
865
+ use lightning:: routing:: scoring:: { ChannelUsage , ScoreUpdate , ScoreLookUp } ;
862
866
use lightning:: util:: config:: UserConfig ;
863
867
use lightning:: util:: ser:: Writeable ;
864
868
use lightning:: util:: test_utils;
@@ -1033,12 +1037,14 @@ mod tests {
1033
1037
fn write < W : lightning:: util:: ser:: Writer > ( & self , _: & mut W ) -> Result < ( ) , lightning:: io:: Error > { Ok ( ( ) ) }
1034
1038
}
1035
1039
1036
- impl Score for TestScorer {
1040
+ impl ScoreLookUp for TestScorer {
1037
1041
type ScoreParams = ( ) ;
1038
1042
fn channel_penalty_msat (
1039
1043
& self , _short_channel_id : u64 , _source : & NodeId , _target : & NodeId , _usage : ChannelUsage , _score_params : & Self :: ScoreParams
1040
1044
) -> u64 { unimplemented ! ( ) ; }
1045
+ }
1041
1046
1047
+ impl ScoreUpdate for TestScorer {
1042
1048
fn payment_path_failed ( & mut self , actual_path : & Path , actual_short_channel_id : u64 ) {
1043
1049
if let Some ( expectations) = & mut self . event_expectations {
1044
1050
match expectations. pop_front ( ) . unwrap ( ) {
0 commit comments