@@ -78,14 +78,14 @@ pub struct ScoringParameters {
78
78
79
79
/// A penalty in msats to apply to a channel upon failure.
80
80
///
81
- /// This may be reduced over time based on [`failure_penalty_decay_interval `].
81
+ /// This may be reduced over time based on [`failure_penalty_half_life `].
82
82
///
83
- /// [`failure_penalty_decay_interval `]: Self::failure_penalty_decay_interval
83
+ /// [`failure_penalty_half_life `]: Self::failure_penalty_half_life
84
84
pub failure_penalty_msat : u64 ,
85
85
86
86
/// The time needed before any accumulated channel failure penalties are cut in half.
87
87
#[ cfg( not( feature = "no-std" ) ) ]
88
- pub failure_penalty_decay_interval : Duration ,
88
+ pub failure_penalty_half_life : Duration ,
89
89
}
90
90
91
91
impl Scorer {
@@ -103,13 +103,13 @@ impl Scorer {
103
103
base_penalty_msat : penalty_msat,
104
104
failure_penalty_msat : 0 ,
105
105
#[ cfg( not( feature = "no-std" ) ) ]
106
- failure_penalty_decay_interval : Duration :: from_secs ( 0 ) ,
106
+ failure_penalty_half_life : Duration :: from_secs ( 0 ) ,
107
107
} )
108
108
}
109
109
110
110
#[ cfg( not( feature = "no-std" ) ) ]
111
111
fn decay_from ( & self , penalty_msat : u64 , last_failure : & SystemTime ) -> u64 {
112
- decay_from ( penalty_msat, last_failure, self . params . failure_penalty_decay_interval )
112
+ decay_from ( penalty_msat, last_failure, self . params . failure_penalty_half_life )
113
113
}
114
114
}
115
115
@@ -125,7 +125,7 @@ impl Default for ScoringParameters {
125
125
base_penalty_msat : 500 ,
126
126
failure_penalty_msat : 1024 ,
127
127
#[ cfg( not( feature = "no-std" ) ) ]
128
- failure_penalty_decay_interval : Duration :: from_secs ( 3600 ) ,
128
+ failure_penalty_half_life : Duration :: from_secs ( 3600 ) ,
129
129
}
130
130
}
131
131
}
@@ -150,11 +150,11 @@ impl routing::Score for Scorer {
150
150
let failure_penalty_msat = self . params . failure_penalty_msat ;
151
151
#[ cfg( not( feature = "no-std" ) ) ]
152
152
{
153
- let decay_interval = self . params . failure_penalty_decay_interval ;
153
+ let half_life = self . params . failure_penalty_half_life ;
154
154
self . channel_failures
155
155
. entry ( short_channel_id)
156
156
. and_modify ( |( penalty_msat, last_failure) | {
157
- let decayed_penalty = decay_from ( * penalty_msat, last_failure, decay_interval ) ;
157
+ let decayed_penalty = decay_from ( * penalty_msat, last_failure, half_life ) ;
158
158
* penalty_msat = decayed_penalty + failure_penalty_msat;
159
159
* last_failure = SystemTime :: now ( ) ;
160
160
} )
@@ -169,9 +169,9 @@ impl routing::Score for Scorer {
169
169
}
170
170
171
171
#[ cfg( not( feature = "no-std" ) ) ]
172
- fn decay_from ( penalty_msat : u64 , last_failure : & SystemTime , decay_interval : Duration ) -> u64 {
172
+ fn decay_from ( penalty_msat : u64 , last_failure : & SystemTime , half_life : Duration ) -> u64 {
173
173
let decays = last_failure. elapsed ( ) . ok ( ) . map_or ( 0 , |elapsed| {
174
- elapsed. as_secs ( ) / decay_interval . as_secs ( )
174
+ elapsed. as_secs ( ) / half_life . as_secs ( )
175
175
} ) ;
176
176
penalty_msat >> decays
177
177
}
0 commit comments