mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pay: Cleanup the route applicability checks for channel hints
I previously mistyped the rather lengthy conditions for failures, so let's dissect it into its smaller components and add rationale behind the individual parts of the decision.
This commit is contained in:
committed by
Rusty Russell
parent
4d6b4a0445
commit
313976e2f4
@@ -470,6 +470,7 @@ static struct channel_hint *payment_chanhints_get(struct payment *p,
|
|||||||
* prior application (`remove=true`). */
|
* prior application (`remove=true`). */
|
||||||
static bool payment_chanhints_apply_route(struct payment *p, bool remove)
|
static bool payment_chanhints_apply_route(struct payment *p, bool remove)
|
||||||
{
|
{
|
||||||
|
bool apply;
|
||||||
struct route_hop *curhop;
|
struct route_hop *curhop;
|
||||||
struct channel_hint *curhint;
|
struct channel_hint *curhint;
|
||||||
struct payment *root = payment_root(p);
|
struct payment *root = payment_root(p);
|
||||||
@@ -489,12 +490,17 @@ static bool payment_chanhints_apply_route(struct payment *p, bool remove)
|
|||||||
if (!curhint)
|
if (!curhint)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* A failure can happen if we add an HTLC, and either
|
/* For local channels we check that we don't overwhelm
|
||||||
* the local htlc_budget is exhausted, or the capacity
|
* them with too many HTLCs. */
|
||||||
* is exceeded. */
|
apply = (!curhint->local) || curhint->htlc_budget > 0;
|
||||||
if ((curhint->local && curhint->htlc_budget <= 0) ||
|
|
||||||
amount_msat_greater(curhop->amount,
|
/* For all channels we check that they have a
|
||||||
curhint->estimated_capacity)) {
|
* sufficiently large estimated capacity to have some
|
||||||
|
* chance of succeeding. */
|
||||||
|
apply &= amount_msat_greater(curhint->estimated_capacity,
|
||||||
|
curhop->amount);
|
||||||
|
|
||||||
|
if (!apply) {
|
||||||
/* This can happen in case of multiple
|
/* This can happen in case of multiple
|
||||||
* concurrent getroute calls using the
|
* concurrent getroute calls using the
|
||||||
* same channel_hints, no biggy, it's
|
* same channel_hints, no biggy, it's
|
||||||
|
|||||||
Reference in New Issue
Block a user