Skip to content

Commit

Permalink
f remove unnecessary hint_candidate_contribution_msat calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinewallace committed May 22, 2023
1 parent 6cc524b commit 2b0af98
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1839,12 +1839,8 @@ where L::Target: Logger {
})
.unwrap_or_else(|| CandidateRouteHop::PrivateHop { hint: hop });

let used_liquidity_msat = used_channel_liquidities
.get(&(hop.short_channel_id, source < target)).copied().unwrap_or(0);
let hint_candidate_contribution_msat = cmp::min(path_value_msat,
candidate.effective_capacity().as_msat().saturating_sub(used_liquidity_msat));
if !add_entry!(candidate, source, target, aggregate_next_hops_fee_msat,
hint_candidate_contribution_msat, aggregate_next_hops_path_htlc_minimum_msat,
path_value_msat, aggregate_next_hops_path_htlc_minimum_msat,
aggregate_next_hops_path_penalty_msat, aggregate_next_hops_cltv_delta,
aggregate_next_hops_path_length) {
// If this hop was not used then there is no use checking the preceding
Expand All @@ -1853,6 +1849,8 @@ where L::Target: Logger {
hop_used = false;
}

let used_liquidity_msat = used_channel_liquidities
.get(&(hop.short_channel_id, source < target)).copied().unwrap_or(0);
let channel_usage = ChannelUsage {
amount_msat: final_value_msat + aggregate_next_hops_fee_msat,
inflight_htlc_msat: used_liquidity_msat,
Expand All @@ -1871,6 +1869,8 @@ where L::Target: Logger {
.saturating_add(1);

// Searching for a direct channel between last checked hop and first_hop_targets
let hint_candidate_contribution_msat = cmp::min(path_value_msat,
candidate.effective_capacity().as_msat().saturating_sub(used_liquidity_msat));
if let Some(first_channels) = first_hop_targets.get(&NodeId::from_pubkey(&prev_hop_id)) {
for details in first_channels {
let first_hop_candidate = CandidateRouteHop::FirstHop { details };
Expand Down

0 comments on commit 2b0af98

Please sign in to comment.