Skip to content

Commit f0ec4d7

Browse files
Use default impl of ChannelScorer for NetworkGraph
The user will be responsible for overriding the ChannelScorer trait functions.
1 parent c8f6203 commit f0ec4d7

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

lightning/src/routing/network_graph.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,6 @@ impl_writeable!(ChannelInfo, 0, {
282282
minimum_fee_penalty
283283
});
284284

285-
/// By default, these methods do nothing. A user may override them to write to their metadata as needed
286-
impl ChannelScorer for ChannelInfo {
287-
fn calculate_minimum_fee_penalty(&self, _channel_id: u64) {}
288-
fn score_payment_failure(&self, _route: Vec<Vec<RouteHop>>, _faulty_nodes: Vec<PublicKey>) {}
289-
fn score_payment_success(&self, _route: Vec<Vec<RouteHop>>) {}
290-
}
291-
292285
/// Fees for routing via a given channel or a node
293286
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
294287
pub struct RoutingFees {
@@ -443,11 +436,11 @@ impl Readable for NodeInfo {
443436
/// route-finding algorithm.
444437
pub trait ChannelScorer {
445438
/// Returns penalty fee for a given channel ID based on user's channel metadata
446-
fn calculate_minimum_fee_penalty(&self, channel_id: u64);
439+
fn calculate_minimum_fee_penalty(&self, _channel_id: u64) {}
447440
/// Optional: allows user to count PaymentSent events for channels
448-
fn score_payment_success(&self, route: Vec<Vec<RouteHop>>);
441+
fn score_payment_success(&self, _route: Vec<Vec<RouteHop>>) {}
449442
/// Optional: allows user to count PaymentFailed events for channels
450-
fn score_payment_failure(&self, route: Vec<Vec<RouteHop>>, faulty_nodes: Vec<PublicKey>);
443+
fn score_payment_failure(&self, _route: Vec<Vec<RouteHop>>, _faulty_nodes: Vec<PublicKey>) {}
451444
}
452445

453446
/// Represents the network as nodes and channels between them
@@ -510,11 +503,7 @@ impl std::fmt::Display for NetworkGraph {
510503
}
511504
}
512505

513-
impl ChannelScorer for NetworkGraph {
514-
fn calculate_minimum_fee_penalty(&self, _channel_id: u64) {}
515-
fn score_payment_success(&self, _route: Vec<Vec<RouteHop>>) {}
516-
fn score_payment_failure(&self, _route: Vec<Vec<RouteHop>>, _faulty_nodes: Vec<PublicKey>) {}
517-
}
506+
impl ChannelScorer for NetworkGraph {}
518507

519508
impl NetworkGraph {
520509
/// Returns all known valid channels' short ids along with announced channel info.

0 commit comments

Comments
 (0)