@@ -79,7 +79,7 @@ pub type DefaultClock = AlwaysPresent;
79
79
/// [`routing::Score`] implementation parameterized by a [`Clock`].
80
80
///
81
81
/// See [`Scorer`] for details.
82
- pub struct ScorerUsingClock < C : Clock + Sub < Duration , Output = C > > {
82
+ pub struct ScorerUsingClock < C : Clock > {
83
83
params : ScoringParameters ,
84
84
channel_failures : HashMap < u64 , ChannelFailure < C > > ,
85
85
}
@@ -109,7 +109,7 @@ impl_writeable_tlv_based!(ScoringParameters, {
109
109
/// Accounting for penalties from channel failures.
110
110
///
111
111
/// Penalties decay over time, though accumulated as more failures occur.
112
- struct ChannelFailure < C : Clock + Sub < Duration , Output = C > > {
112
+ struct ChannelFailure < C : Clock > {
113
113
/// Accumulated penalty in msats for the channel as of `last_failed`.
114
114
undecayed_penalty_msat : u64 ,
115
115
@@ -118,15 +118,15 @@ struct ChannelFailure<C: Clock + Sub<Duration, Output = C>> {
118
118
}
119
119
120
120
/// A measurement of time.
121
- pub trait Clock {
121
+ pub trait Clock : Sub < Duration , Output = Self > {
122
122
/// Returns an instance corresponding to "now".
123
123
fn now ( ) -> Self ;
124
124
125
125
/// Returns the amount of time elapsed since the clock was created.
126
126
fn elapsed ( & self ) -> Duration ;
127
127
}
128
128
129
- impl < C : Clock + Sub < Duration , Output = C > > ScorerUsingClock < C > {
129
+ impl < C : Clock > ScorerUsingClock < C > {
130
130
/// Creates a new scorer using the given scoring parameters.
131
131
pub fn new ( params : ScoringParameters ) -> Self {
132
132
Self {
@@ -146,7 +146,7 @@ impl<C: Clock + Sub<Duration, Output = C>> ScorerUsingClock<C> {
146
146
}
147
147
}
148
148
149
- impl < C : Clock + Sub < Duration , Output = C > > ChannelFailure < C > {
149
+ impl < C : Clock > ChannelFailure < C > {
150
150
fn new ( failure_penalty_msat : u64 ) -> Self {
151
151
Self {
152
152
undecayed_penalty_msat : failure_penalty_msat,
@@ -168,7 +168,7 @@ impl<C: Clock + Sub<Duration, Output = C>> ChannelFailure<C> {
168
168
}
169
169
}
170
170
171
- impl < C : Clock + Sub < Duration , Output = C > > Default for ScorerUsingClock < C > {
171
+ impl < C : Clock > Default for ScorerUsingClock < C > {
172
172
fn default ( ) -> Self {
173
173
Self :: new ( ScoringParameters :: default ( ) )
174
174
}
@@ -184,7 +184,7 @@ impl Default for ScoringParameters {
184
184
}
185
185
}
186
186
187
- impl < C : Clock + Sub < Duration , Output = C > > routing:: Score for ScorerUsingClock < C > {
187
+ impl < C : Clock > routing:: Score for ScorerUsingClock < C > {
188
188
fn channel_penalty_msat (
189
189
& self , short_channel_id : u64 , _source : & NodeId , _target : & NodeId
190
190
) -> u64 {
@@ -237,15 +237,15 @@ impl Sub<Duration> for AlwaysPresent {
237
237
}
238
238
}
239
239
240
- impl < C : Clock + Sub < Duration , Output = C > > Writeable for ScorerUsingClock < C > {
240
+ impl < C : Clock > Writeable for ScorerUsingClock < C > {
241
241
#[ inline]
242
242
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
243
243
self . params . write ( w) ?;
244
244
self . channel_failures . write ( w)
245
245
}
246
246
}
247
247
248
- impl < C : Clock + Sub < Duration , Output = C > > Readable for ScorerUsingClock < C > {
248
+ impl < C : Clock > Readable for ScorerUsingClock < C > {
249
249
#[ inline]
250
250
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
251
251
Ok ( Self {
@@ -255,15 +255,15 @@ impl<C: Clock + Sub<Duration, Output = C>> Readable for ScorerUsingClock<C> {
255
255
}
256
256
}
257
257
258
- impl < C : Clock + Sub < Duration , Output = C > > Writeable for ChannelFailure < C > {
258
+ impl < C : Clock > Writeable for ChannelFailure < C > {
259
259
#[ inline]
260
260
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
261
261
self . undecayed_penalty_msat . write ( w) ?;
262
262
( duration_since_epoch ( ) - self . last_failed . elapsed ( ) ) . write ( w)
263
263
}
264
264
}
265
265
266
- impl < C : Clock + Sub < Duration , Output = C > > Readable for ChannelFailure < C > {
266
+ impl < C : Clock > Readable for ChannelFailure < C > {
267
267
#[ inline]
268
268
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
269
269
Ok ( Self {
0 commit comments