@@ -512,7 +512,7 @@ pub struct SimNode<T: SimNetwork, C: Clock> {
512512 pathfinding_graph : Arc < LdkNetworkGraph > ,
513513 /// Probabilistic scorer used to rank paths through the network for routing. This is reused across
514514 /// multiple payments to maintain scoring state.
515- scorer : ProbabilisticScorer < Arc < LdkNetworkGraph > , Arc < WrappedLog > > ,
515+ scorer : Mutex < ProbabilisticScorer < Arc < LdkNetworkGraph > , Arc < WrappedLog > > > ,
516516 /// Clock for tracking simulation time.
517517 clock : C ,
518518}
@@ -540,7 +540,7 @@ impl<T: SimNetwork, C: Clock> SimNode<T, C> {
540540 network : payment_network,
541541 in_flight : Mutex :: new ( HashMap :: new ( ) ) ,
542542 pathfinding_graph,
543- scorer,
543+ scorer : Mutex :: new ( scorer ) ,
544544 clock,
545545 } )
546546 }
@@ -673,12 +673,13 @@ impl<T: SimNetwork, C: Clock> LightningNode for SimNode<T, C> {
673673 } ;
674674
675675 // Use the stored scorer when finding a route
676+ let scorer_guard = self . scorer . lock ( ) . await ;
676677 let route = match find_payment_route (
677678 & self . info . pubkey ,
678679 dest,
679680 amount_msat,
680681 & self . pathfinding_graph ,
681- & self . scorer ,
682+ & scorer_guard ,
682683 ) {
683684 Ok ( path) => path,
684685 // In the case that we can't find a route for the payment, we still report a successful payment *api call*
@@ -743,9 +744,9 @@ impl<T: SimNetwork, C: Clock> LightningNode for SimNode<T, C> {
743744 if let Ok ( ref payment_result) = track_result {
744745 let duration = self . clock. now( ) . duration_since( UNIX_EPOCH ) ?;
745746 if payment_result. payment_outcome == PaymentOutcome :: Success {
746- self . scorer. payment_path_successful( & in_flight. path, duration) ;
747+ self . scorer. lock ( ) . await . payment_path_successful( & in_flight. path, duration) ;
747748 } else if let PaymentOutcome :: IndexFailure ( index) = payment_result. payment_outcome {
748- self . scorer. payment_path_failed( & in_flight. path, index. try_into( ) . unwrap( ) , duration) ;
749+ self . scorer. lock ( ) . await . payment_path_failed( & in_flight. path, index. try_into( ) . unwrap( ) , duration) ;
749750 }
750751 }
751752 track_result
0 commit comments