Skip to content

Commit 937ad6f

Browse files
committed
Let scorer methods take params by reference
1 parent ad178b2 commit 937ad6f

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
@@ -5723,7 +5723,7 @@ mod tests {
57235723
let random_seed_bytes = keys_manager.get_secure_random_bytes();
57245724

57255725
let scorer_params = ProbabilisticScoringParameters::default();
5726-
let mut scorer = ProbabilisticScorer::new(scorer_params.clone(), Arc::clone(&network_graph), Arc::clone(&logger));
5726+
let mut scorer = ProbabilisticScorer::new(scorer_params, Arc::clone(&network_graph), Arc::clone(&logger));
57275727

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

lightning/src/routing/scoring.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ const AMOUNT_PENALTY_DIVISOR: u64 = 1 << 20;
574574
impl<L: Deref<Target = u64>, T: Time, U: Deref<Target = T>> DirectedChannelLiquidity<L, T, U> {
575575
/// Returns a penalty for routing the given HTLC `amount_msat` through the channel in this
576576
/// direction.
577-
fn penalty_msat(&self, amount_msat: u64, params: ProbabilisticScoringParameters) -> u64 {
577+
fn penalty_msat(&self, amount_msat: u64, params: &ProbabilisticScoringParameters) -> u64 {
578578
let max_liquidity_msat = self.max_liquidity_msat();
579579
let min_liquidity_msat = core::cmp::min(self.min_liquidity_msat(), max_liquidity_msat);
580580
if amount_msat <= min_liquidity_msat {
@@ -611,7 +611,7 @@ impl<L: Deref<Target = u64>, T: Time, U: Deref<Target = T>> DirectedChannelLiqui
611611
#[inline(always)]
612612
fn combined_penalty_msat(
613613
&self, amount_msat: u64, negative_log10_times_2048: u64,
614-
params: ProbabilisticScoringParameters
614+
params: &ProbabilisticScoringParameters
615615
) -> u64 {
616616
let liquidity_penalty_msat = {
617617
// Upper bound the liquidity penalty to ensure some channel is selected.
@@ -723,7 +723,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> Score for Probabilis
723723
.get(&short_channel_id)
724724
.unwrap_or(&ChannelLiquidity::new())
725725
.as_directed(source, target, capacity_msat, liquidity_offset_half_life)
726-
.penalty_msat(amount_msat, self.params.clone())
726+
.penalty_msat(amount_msat, &self.params)
727727
}
728728

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

0 commit comments

Comments
 (0)