@@ -519,6 +519,75 @@ pub struct ProbabilisticScoringFeeParameters {
519
519
pub considered_impossible_penalty_msat : u64 ,
520
520
}
521
521
522
+ impl Default for ProbabilisticScoringFeeParameters {
523
+ fn default ( ) -> Self {
524
+ Self {
525
+ base_penalty_msat : 500 ,
526
+ base_penalty_amount_multiplier_msat : 8192 ,
527
+ liquidity_penalty_multiplier_msat : 30_000 ,
528
+ liquidity_penalty_amount_multiplier_msat : 192 ,
529
+ manual_node_penalties : HashMap :: new ( ) ,
530
+ anti_probing_penalty_msat : 250 ,
531
+ considered_impossible_penalty_msat : 1_0000_0000_000 ,
532
+ historical_liquidity_penalty_multiplier_msat : 10_000 ,
533
+ historical_liquidity_penalty_amount_multiplier_msat : 64 ,
534
+ }
535
+ }
536
+ }
537
+
538
+ impl ProbabilisticScoringFeeParameters {
539
+ /// Marks the node with the given `node_id` as banned, i.e.,
540
+ /// it will be avoided during path finding.
541
+ pub fn add_banned ( & mut self , node_id : & NodeId ) {
542
+ self . manual_node_penalties . insert ( * node_id, u64:: max_value ( ) ) ;
543
+ }
544
+
545
+ /// Marks all nodes in the given list as banned, i.e.,
546
+ /// they will be avoided during path finding.
547
+ pub fn add_banned_from_list ( & mut self , node_ids : Vec < NodeId > ) {
548
+ for id in node_ids {
549
+ self . manual_node_penalties . insert ( id, u64:: max_value ( ) ) ;
550
+ }
551
+ }
552
+
553
+ /// Removes the node with the given `node_id` from the list of nodes to avoid.
554
+ pub fn remove_banned ( & mut self , node_id : & NodeId ) {
555
+ self . manual_node_penalties . remove ( node_id) ;
556
+ }
557
+
558
+ /// Sets a manual penalty for the given node.
559
+ pub fn set_manual_penalty ( & mut self , node_id : & NodeId , penalty : u64 ) {
560
+ self . manual_node_penalties . insert ( * node_id, penalty) ;
561
+ }
562
+
563
+ /// Removes the node with the given `node_id` from the list of manual penalties.
564
+ pub fn remove_manual_penalty ( & mut self , node_id : & NodeId ) {
565
+ self . manual_node_penalties . remove ( node_id) ;
566
+ }
567
+
568
+ /// Clears the list of manual penalties that are applied during path finding.
569
+ pub fn clear_manual_penalties ( & mut self ) {
570
+ self . manual_node_penalties = HashMap :: new ( ) ;
571
+ }
572
+ }
573
+
574
+ #[ cfg( test) ]
575
+ impl ProbabilisticScoringFeeParameters {
576
+ fn zero_penalty ( ) -> Self {
577
+ Self {
578
+ base_penalty_msat : 0 ,
579
+ base_penalty_amount_multiplier_msat : 0 ,
580
+ liquidity_penalty_multiplier_msat : 0 ,
581
+ liquidity_penalty_amount_multiplier_msat : 0 ,
582
+ historical_liquidity_penalty_multiplier_msat : 0 ,
583
+ historical_liquidity_penalty_amount_multiplier_msat : 0 ,
584
+ manual_node_penalties : HashMap :: new ( ) ,
585
+ anti_probing_penalty_msat : 0 ,
586
+ considered_impossible_penalty_msat : 0 ,
587
+ }
588
+ }
589
+ }
590
+
522
591
/// Parameters for configuring [`ProbabilisticScorer`].
523
592
///
524
593
/// Used to configure decay parameters that are static throughout the lifetime of the scorer.
@@ -561,24 +630,25 @@ pub struct ProbabilisticScoringDecayParameters {
561
630
pub liquidity_offset_half_life : Duration ,
562
631
}
563
632
564
- #[ cfg( test) ]
565
- impl ProbabilisticScoringDecayParameters {
566
- fn zero_penalty ( ) -> Self {
633
+ impl Default for ProbabilisticScoringDecayParameters {
634
+ fn default ( ) -> Self {
567
635
Self {
568
636
liquidity_offset_half_life : Duration :: from_secs ( 6 * 60 * 60 ) ,
569
637
historical_no_updates_half_life : Duration :: from_secs ( 60 * 60 * 24 * 14 ) ,
570
638
}
571
639
}
572
640
}
573
641
574
- impl Default for ProbabilisticScoringDecayParameters {
575
- fn default ( ) -> Self {
642
+ #[ cfg( test) ]
643
+ impl ProbabilisticScoringDecayParameters {
644
+ fn zero_penalty ( ) -> Self {
576
645
Self {
577
646
liquidity_offset_half_life : Duration :: from_secs ( 6 * 60 * 60 ) ,
578
647
historical_no_updates_half_life : Duration :: from_secs ( 60 * 60 * 24 * 14 ) ,
579
648
}
580
649
}
581
650
}
651
+
582
652
/// Tracks the historical state of a distribution as a weighted average of how much time was spent
583
653
/// in each of 8 buckets.
584
654
#[ derive( Clone , Copy ) ]
@@ -882,73 +952,6 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ProbabilisticScorerU
882
952
}
883
953
}
884
954
885
- impl ProbabilisticScoringFeeParameters {
886
- #[ cfg( test) ]
887
- fn zero_penalty ( ) -> Self {
888
- Self {
889
- base_penalty_msat : 0 ,
890
- base_penalty_amount_multiplier_msat : 0 ,
891
- liquidity_penalty_multiplier_msat : 0 ,
892
- liquidity_penalty_amount_multiplier_msat : 0 ,
893
- historical_liquidity_penalty_multiplier_msat : 0 ,
894
- historical_liquidity_penalty_amount_multiplier_msat : 0 ,
895
- manual_node_penalties : HashMap :: new ( ) ,
896
- anti_probing_penalty_msat : 0 ,
897
- considered_impossible_penalty_msat : 0 ,
898
- }
899
- }
900
-
901
- /// Marks the node with the given `node_id` as banned, i.e.,
902
- /// it will be avoided during path finding.
903
- pub fn add_banned ( & mut self , node_id : & NodeId ) {
904
- self . manual_node_penalties . insert ( * node_id, u64:: max_value ( ) ) ;
905
- }
906
-
907
- /// Marks all nodes in the given list as banned, i.e.,
908
- /// they will be avoided during path finding.
909
- pub fn add_banned_from_list ( & mut self , node_ids : Vec < NodeId > ) {
910
- for id in node_ids {
911
- self . manual_node_penalties . insert ( id, u64:: max_value ( ) ) ;
912
- }
913
- }
914
-
915
- /// Removes the node with the given `node_id` from the list of nodes to avoid.
916
- pub fn remove_banned ( & mut self , node_id : & NodeId ) {
917
- self . manual_node_penalties . remove ( node_id) ;
918
- }
919
-
920
- /// Sets a manual penalty for the given node.
921
- pub fn set_manual_penalty ( & mut self , node_id : & NodeId , penalty : u64 ) {
922
- self . manual_node_penalties . insert ( * node_id, penalty) ;
923
- }
924
-
925
- /// Removes the node with the given `node_id` from the list of manual penalties.
926
- pub fn remove_manual_penalty ( & mut self , node_id : & NodeId ) {
927
- self . manual_node_penalties . remove ( node_id) ;
928
- }
929
-
930
- /// Clears the list of manual penalties that are applied during path finding.
931
- pub fn clear_manual_penalties ( & mut self ) {
932
- self . manual_node_penalties = HashMap :: new ( ) ;
933
- }
934
- }
935
-
936
- impl Default for ProbabilisticScoringFeeParameters {
937
- fn default ( ) -> Self {
938
- Self {
939
- base_penalty_msat : 500 ,
940
- base_penalty_amount_multiplier_msat : 8192 ,
941
- liquidity_penalty_multiplier_msat : 30_000 ,
942
- liquidity_penalty_amount_multiplier_msat : 192 ,
943
- manual_node_penalties : HashMap :: new ( ) ,
944
- anti_probing_penalty_msat : 250 ,
945
- considered_impossible_penalty_msat : 1_0000_0000_000 ,
946
- historical_liquidity_penalty_multiplier_msat : 10_000 ,
947
- historical_liquidity_penalty_amount_multiplier_msat : 64 ,
948
- }
949
- }
950
- }
951
-
952
955
impl < T : Time > ChannelLiquidity < T > {
953
956
#[ inline]
954
957
fn new ( ) -> Self {
0 commit comments