Skip to content

Commit c69f400

Browse files
committed
Let scorer methods take params by reference
1 parent 58bca11 commit c69f400

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lightning/src/routing/router.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5722,7 +5722,7 @@ mod tests {
57225722
let random_seed_bytes = keys_manager.get_secure_random_bytes();
57235723

57245724
let scorer_params = ProbabilisticScoringParameters::default();
5725-
let mut scorer = ProbabilisticScorer::new(scorer_params.clone(), Arc::clone(&network_graph), Arc::clone(&logger));
5725+
let mut scorer = ProbabilisticScorer::new(scorer_params, Arc::clone(&network_graph), Arc::clone(&logger));
57265726

57275727
// First check we can get a route.
57285728
let payment_params = PaymentParameters::from_node_id(nodes[10]);

lightning/src/routing/scoring.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ const AMOUNT_PENALTY_DIVISOR: u64 = 1 << 20;
557557
impl<L: Deref<Target = u64>, T: Time, U: Deref<Target = T>> DirectedChannelLiquidity<L, T, U> {
558558
/// Returns a penalty for routing the given HTLC `amount_msat` through the channel in this
559559
/// direction.
560-
fn penalty_msat(&self, amount_msat: u64, params: ProbabilisticScoringParameters) -> u64 {
560+
fn penalty_msat(&self, amount_msat: u64, params: &ProbabilisticScoringParameters) -> u64 {
561561
let max_liquidity_msat = self.max_liquidity_msat();
562562
let min_liquidity_msat = core::cmp::min(self.min_liquidity_msat(), max_liquidity_msat);
563563
if amount_msat <= min_liquidity_msat {
@@ -594,7 +594,7 @@ impl<L: Deref<Target = u64>, T: Time, U: Deref<Target = T>> DirectedChannelLiqui
594594
#[inline(always)]
595595
fn combined_penalty_msat(
596596
&self, amount_msat: u64, negative_log10_times_2048: u64,
597-
params: ProbabilisticScoringParameters
597+
params: &ProbabilisticScoringParameters
598598
) -> u64 {
599599
let liquidity_penalty_msat = {
600600
// Upper bound the liquidity penalty to ensure some channel is selected.
@@ -706,7 +706,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> Score for Probabilis
706706
.get(&short_channel_id)
707707
.unwrap_or(&ChannelLiquidity::new())
708708
.as_directed(source, target, capacity_msat, liquidity_offset_half_life)
709-
.penalty_msat(amount_msat, self.params.clone())
709+
.penalty_msat(amount_msat, &self.params)
710710
}
711711

712712
fn payment_path_failed(&mut self, path: &[&RouteHop], short_channel_id: u64) {

0 commit comments

Comments
 (0)