31
31
//! # let logger = FakeLogger {};
32
32
//! #
33
33
//! // Use the default channel penalties.
34
- //! let scorer = Scorer::<std::time::Instant>:: default();
34
+ //! let scorer = Scorer::default();
35
35
//!
36
36
//! // Or use custom channel penalties.
37
- //! let scorer = Scorer::<std::time::Instant>:: new(ScoringParameters {
37
+ //! let scorer = Scorer::new(ScoringParameters {
38
38
//! base_penalty_msat: 1000,
39
39
//! failure_penalty_msat: 2 * 1024 * 1000,
40
40
//! ..ScoringParameters::default()
@@ -62,7 +62,20 @@ use core::time::Duration;
62
62
/// See [module-level documentation] for usage.
63
63
///
64
64
/// [module-level documentation]: crate::routing::scorer
65
- pub struct Scorer < C : Clock > {
65
+ pub type Scorer = ScorerUsingClock :: < DefaultClock > ;
66
+
67
+ /// Clock used by [`Scorer`].
68
+ #[ cfg( not( feature = "no-std" ) ) ]
69
+ pub type DefaultClock = std:: time:: Instant ;
70
+
71
+ /// Clock used by [`Scorer`].
72
+ #[ cfg( feature = "no-std" ) ]
73
+ pub type DefaultClock = AlwaysPresent ;
74
+
75
+ /// [`routing::Score`] implementation parameterized by a [`Clock`].
76
+ ///
77
+ /// See [`Scorer`] for details.
78
+ pub struct ScorerUsingClock < C : Clock > {
66
79
params : ScoringParameters ,
67
80
channel_failures : HashMap < u64 , ChannelFailure < C > > ,
68
81
}
@@ -103,7 +116,7 @@ pub trait Clock {
103
116
fn elapsed ( & self ) -> Duration ;
104
117
}
105
118
106
- impl < C : Clock > Scorer < C > {
119
+ impl < C : Clock > ScorerUsingClock < C > {
107
120
/// Creates a new scorer using the given scoring parameters.
108
121
pub fn new ( params : ScoringParameters ) -> Self {
109
122
Self {
@@ -145,9 +158,9 @@ impl<C: Clock> ChannelFailure<C> {
145
158
}
146
159
}
147
160
148
- impl < C : Clock > Default for Scorer < C > {
161
+ impl < C : Clock > Default for ScorerUsingClock < C > {
149
162
fn default ( ) -> Self {
150
- Scorer :: new ( ScoringParameters :: default ( ) )
163
+ Self :: new ( ScoringParameters :: default ( ) )
151
164
}
152
165
}
153
166
@@ -161,7 +174,7 @@ impl Default for ScoringParameters {
161
174
}
162
175
}
163
176
164
- impl < C : Clock > routing:: Score for Scorer < C > {
177
+ impl < C : Clock > routing:: Score for ScorerUsingClock < C > {
165
178
fn channel_penalty_msat (
166
179
& self , short_channel_id : u64 , _source : & NodeId , _target : & NodeId
167
180
) -> u64 {
0 commit comments