Skip to content
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

libplugin-pay: use map for channel hints #7636

Closed
Closed
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
21 changes: 10 additions & 11 deletions plugins/libplugin-pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -2909,18 +2909,17 @@ static bool routehint_excluded(struct payment *p,
* channel, which is greater than the destination.
*/
struct channel_hint *hint;
struct channel_hint_map_iter iter;
for (hint = channel_hint_map_first(hints, &iter);
hint;
hint = channel_hint_map_next(hints, &iter)) {
if (!short_channel_id_eq(hint->scid.scid, r->short_channel_id))
continue;
/* We exclude on equality because we set the estimate
* to the smallest failed attempt. */
if (amount_msat_greater_eq(needed_capacity,
struct short_channel_id_dir scidd;
scidd.scid = r->short_channel_id;
scidd.dir = node_id_cmp(&routehint->pubkey,
p->pay_destination) > 0 ? 1 : 0;
Comment on lines +2914 to +2915
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think something like this should do the trick.

Suggested change
scidd.dir = node_id_cmp(&routehint->pubkey,
p->pay_destination) > 0 ? 1 : 0;
scidd.dir = node_id_idx(&r->pubkey, p->pay_destination);

Also notice that I replaced routehint with r.


hint = channel_hint_map_get(hints, &scidd);
/* We exclude on equality because we set the estimate
* to the smallest failed attempt. */
if (hint && amount_msat_greater_eq(needed_capacity,
hint->estimated_capacity))
return true;
}
return true;
}
return false;
}
Expand Down
Loading