@@ -79,7 +79,7 @@ pub type DefaultTime = Eternity;
79
79
/// [`routing::Score`] implementation parameterized by [`Time`].
80
80
///
81
81
/// See [`Scorer`] for details.
82
- pub struct ScorerUsingTime < T : Time + Sub < Duration , Output = T > > {
82
+ pub struct ScorerUsingTime < T : Time > {
83
83
params : ScoringParameters ,
84
84
// TODO: Remove entries of closed channels.
85
85
channel_failures : HashMap < u64 , ChannelFailure < T > > ,
@@ -116,7 +116,7 @@ impl_writeable_tlv_based!(ScoringParameters, {
116
116
/// Accounting for penalties from channel failures.
117
117
///
118
118
/// Penalties decay over time, though accumulate as more failures occur.
119
- struct ChannelFailure < T : Time + Sub < Duration , Output = T > > {
119
+ struct ChannelFailure < T : Time > {
120
120
/// Accumulated penalty in msats for the channel as of `last_failed`.
121
121
undecayed_penalty_msat : u64 ,
122
122
@@ -125,15 +125,15 @@ struct ChannelFailure<T: Time + Sub<Duration, Output = T>> {
125
125
}
126
126
127
127
/// A measurement of time.
128
- pub trait Time {
128
+ pub trait Time : Sub < Duration , Output = Self > {
129
129
/// Returns an instance corresponding to the current moment.
130
130
fn now ( ) -> Self ;
131
131
132
132
/// Returns the amount of time elapsed since created.
133
133
fn elapsed ( & self ) -> Duration ;
134
134
}
135
135
136
- impl < T : Time + Sub < Duration , Output = T > > ScorerUsingTime < T > {
136
+ impl < T : Time > ScorerUsingTime < T > {
137
137
/// Creates a new scorer using the given scoring parameters.
138
138
pub fn new ( params : ScoringParameters ) -> Self {
139
139
Self {
@@ -153,7 +153,7 @@ impl<T: Time + Sub<Duration, Output = T>> ScorerUsingTime<T> {
153
153
}
154
154
}
155
155
156
- impl < T : Time + Sub < Duration , Output = T > > ChannelFailure < T > {
156
+ impl < T : Time > ChannelFailure < T > {
157
157
fn new ( failure_penalty_msat : u64 ) -> Self {
158
158
Self {
159
159
undecayed_penalty_msat : failure_penalty_msat,
@@ -175,7 +175,7 @@ impl<T: Time + Sub<Duration, Output = T>> ChannelFailure<T> {
175
175
}
176
176
}
177
177
178
- impl < T : Time + Sub < Duration , Output = T > > Default for ScorerUsingTime < T > {
178
+ impl < T : Time > Default for ScorerUsingTime < T > {
179
179
fn default ( ) -> Self {
180
180
Self :: new ( ScoringParameters :: default ( ) )
181
181
}
@@ -191,7 +191,7 @@ impl Default for ScoringParameters {
191
191
}
192
192
}
193
193
194
- impl < T : Time + Sub < Duration , Output = T > > routing:: Score for ScorerUsingTime < T > {
194
+ impl < T : Time > routing:: Score for ScorerUsingTime < T > {
195
195
fn channel_penalty_msat (
196
196
& self , short_channel_id : u64 , _source : & NodeId , _target : & NodeId
197
197
) -> u64 {
@@ -244,15 +244,15 @@ impl Sub<Duration> for Eternity {
244
244
}
245
245
}
246
246
247
- impl < T : Time + Sub < Duration , Output = T > > Writeable for ScorerUsingTime < T > {
247
+ impl < T : Time > Writeable for ScorerUsingTime < T > {
248
248
#[ inline]
249
249
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
250
250
self . params . write ( w) ?;
251
251
self . channel_failures . write ( w)
252
252
}
253
253
}
254
254
255
- impl < T : Time + Sub < Duration , Output = T > > Readable for ScorerUsingTime < T > {
255
+ impl < T : Time > Readable for ScorerUsingTime < T > {
256
256
#[ inline]
257
257
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
258
258
Ok ( Self {
@@ -262,15 +262,15 @@ impl<T: Time + Sub<Duration, Output = T>> Readable for ScorerUsingTime<T> {
262
262
}
263
263
}
264
264
265
- impl < T : Time + Sub < Duration , Output = T > > Writeable for ChannelFailure < T > {
265
+ impl < T : Time > Writeable for ChannelFailure < T > {
266
266
#[ inline]
267
267
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
268
268
self . undecayed_penalty_msat . write ( w) ?;
269
269
( duration_since_epoch ( ) - self . last_failed . elapsed ( ) ) . write ( w)
270
270
}
271
271
}
272
272
273
- impl < T : Time + Sub < Duration , Output = T > > Readable for ChannelFailure < T > {
273
+ impl < T : Time > Readable for ChannelFailure < T > {
274
274
#[ inline]
275
275
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
276
276
Ok ( Self {
0 commit comments