Skip to content

Misc routing optimization #2803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2425,14 +2425,15 @@ where L::Target: Logger {
// Can't overflow due to how the values were computed right above.
None => unreachable!(),
};
let htlc_minimum_msat = $candidate.htlc_minimum_msat();
#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
let over_path_minimum_msat = amount_to_transfer_over_msat >= $candidate.htlc_minimum_msat() &&
let over_path_minimum_msat = amount_to_transfer_over_msat >= htlc_minimum_msat &&
amount_to_transfer_over_msat >= $next_hops_path_htlc_minimum_msat;

#[allow(unused_comparisons)] // $next_hops_path_htlc_minimum_msat is 0 in some calls so rustc complains
let may_overpay_to_meet_path_minimum_msat =
((amount_to_transfer_over_msat < $candidate.htlc_minimum_msat() &&
recommended_value_msat >= $candidate.htlc_minimum_msat()) ||
((amount_to_transfer_over_msat < htlc_minimum_msat &&
recommended_value_msat >= htlc_minimum_msat) ||
Comment on lines +2431 to +2437
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #[allow(unused_comparisons)] attribute is used to suppress warnings about comparisons that are always true or false. This is a code smell and may indicate that the logic could be simplified or that the comparisons are unnecessary.

Review the logic involving amount_to_transfer_over_msat, htlc_minimum_msat, and $next_hops_path_htlc_minimum_msat to determine if the comparisons are necessary and remove them if they are not.

(amount_to_transfer_over_msat < $next_hops_path_htlc_minimum_msat &&
recommended_value_msat >= $next_hops_path_htlc_minimum_msat));

Expand Down