Skip to content

Commit 0375e62

Browse files
committed
f - fix rustdocs
1 parent 5966296 commit 0375e62

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

fuzz/src/full_stack.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
382382
let our_id = PublicKey::from_secret_key(&Secp256k1::signing_only(), &keys_manager.get_node_secret());
383383
let network_graph = NetworkGraph::new(genesis_block(network).block_hash());
384384
let net_graph_msg_handler = Arc::new(NetGraphMsgHandler::new(network_graph, None, Arc::clone(&logger)));
385-
let scorer = Scorer::<std::time::Instant>::with_fixed_penalty(0);
385+
let scorer = Scorer::with_fixed_penalty(0);
386386

387387
let peers = RefCell::new([false; 256]);
388388
let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), PeerManager::new(MessageHandler {

fuzz/src/router.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
248248
}]));
249249
}
250250
}
251-
let scorer = Scorer::<std::time::Instant>::with_fixed_penalty(0);
251+
let scorer = Scorer::with_fixed_penalty(0);
252252
for target in node_pks.iter() {
253253
let params = RouteParameters {
254254
payee: Payee::new(*target).with_route_hints(last_hops.clone()),

lightning/src/ln/channelmanager.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6602,7 +6602,7 @@ pub mod bench {
66026602
let usable_channels = $node_a.list_usable_channels();
66036603
let payee = Payee::new($node_b.get_our_node_id())
66046604
.with_features(InvoiceFeatures::known());
6605-
let scorer = Scorer::<std::time::Instant>::with_fixed_penalty(0);
6605+
let scorer = Scorer::with_fixed_penalty(0);
66066606
let route = get_route(&$node_a.get_our_node_id(), &payee, &dummy_graph,
66076607
Some(&usable_channels.iter().map(|r| r).collect::<Vec<_>>()), 10_000, TEST_FINAL_CLTV, &logger_a, &scorer).unwrap();
66086608

lightning/src/routing/router.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4785,7 +4785,7 @@ mod benches {
47854785
let mut d = test_utils::get_route_file().unwrap();
47864786
let graph = NetworkGraph::read(&mut d).unwrap();
47874787
let nodes = graph.read_only().nodes().clone();
4788-
let scorer = Scorer::<std::time::Instant>::with_fixed_penalty(0);
4788+
let scorer = Scorer::with_fixed_penalty(0);
47894789

47904790
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
47914791
let mut path_endpoints = Vec::new();
@@ -4820,7 +4820,7 @@ mod benches {
48204820
let mut d = test_utils::get_route_file().unwrap();
48214821
let graph = NetworkGraph::read(&mut d).unwrap();
48224822
let nodes = graph.read_only().nodes().clone();
4823-
let scorer = Scorer::<std::time::Instant>::with_fixed_penalty(0);
4823+
let scorer = Scorer::with_fixed_penalty(0);
48244824

48254825
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
48264826
let mut path_endpoints = Vec::new();

lightning/src/routing/scorer.rs

+20-7
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
//! # let logger = FakeLogger {};
3232
//! #
3333
//! // Use the default channel penalties.
34-
//! let scorer = Scorer::<std::time::Instant>::default();
34+
//! let scorer = Scorer::default();
3535
//!
3636
//! // Or use custom channel penalties.
37-
//! let scorer = Scorer::<std::time::Instant>::new(ScoringParameters {
37+
//! let scorer = Scorer::new(ScoringParameters {
3838
//! base_penalty_msat: 1000,
3939
//! failure_penalty_msat: 2 * 1024 * 1000,
4040
//! ..ScoringParameters::default()
@@ -62,7 +62,20 @@ use core::time::Duration;
6262
/// See [module-level documentation] for usage.
6363
///
6464
/// [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> {
6679
params: ScoringParameters,
6780
channel_failures: HashMap<u64, ChannelFailure<C>>,
6881
}
@@ -103,7 +116,7 @@ pub trait Clock {
103116
fn elapsed(&self) -> Duration;
104117
}
105118

106-
impl<C: Clock> Scorer<C> {
119+
impl<C: Clock> ScorerUsingClock<C> {
107120
/// Creates a new scorer using the given scoring parameters.
108121
pub fn new(params: ScoringParameters) -> Self {
109122
Self {
@@ -145,9 +158,9 @@ impl<C: Clock> ChannelFailure<C> {
145158
}
146159
}
147160

148-
impl<C: Clock> Default for Scorer<C> {
161+
impl<C: Clock> Default for ScorerUsingClock<C> {
149162
fn default() -> Self {
150-
Scorer::new(ScoringParameters::default())
163+
Self::new(ScoringParameters::default())
151164
}
152165
}
153166

@@ -161,7 +174,7 @@ impl Default for ScoringParameters {
161174
}
162175
}
163176

164-
impl<C: Clock> routing::Score for Scorer<C> {
177+
impl<C: Clock> routing::Score for ScorerUsingClock<C> {
165178
fn channel_penalty_msat(
166179
&self, short_channel_id: u64, _source: &NodeId, _target: &NodeId
167180
) -> u64 {

lightning/src/util/test_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use ln::features::{ChannelFeatures, InitFeatures};
2121
use ln::msgs;
2222
use ln::msgs::OptionalField;
2323
use ln::script::ShutdownScript;
24-
use routing::scorer::{AlwaysPresent, Scorer};
24+
use routing::scorer::{AlwaysPresent, ScorerUsingClock};
2525
use util::enforcing_trait_impls::{EnforcingSigner, EnforcementState};
2626
use util::events;
2727
use util::logger::{Logger, Level, Record};
@@ -696,4 +696,4 @@ impl core::fmt::Debug for OnRegisterOutput {
696696
}
697697

698698
/// A scorer useful in testing, when the passage of time isn't a concern.
699-
pub type TestScorer = Scorer<AlwaysPresent>;
699+
pub type TestScorer = ScorerUsingClock<AlwaysPresent>;

0 commit comments

Comments
 (0)