From a456d08ad00d22668e5bf7b90eedb22f181dc610 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 27 Jul 2020 17:42:54 +0200 Subject: [PATCH] pay: Be less aggressive when estimating channel capacity We'd previously take the failed attempt and estimate the failing channel's capacity at 3/4 of the attempted amount, which is rather aggressive. This reduces this aggressiveness to use the exact amount tried, but excluding on equality. This still skips attempting the same route with the same amount, but also permits attempts that are in the range [3/4, 1] of the failed attempt amount to still be attempted. --- plugins/libplugin-pay.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index 965fff5cf..f1b7ba6e5 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -186,7 +186,7 @@ void payment_start(struct payment *p) static void channel_hints_update(struct payment *p, const struct short_channel_id scid, int direction, bool enabled, bool local, - struct amount_msat *estimated_capacity, + const struct amount_msat *estimated_capacity, u16 *htlc_budget) { struct payment *root = payment_root(p); @@ -448,7 +448,10 @@ payment_get_excluded_channels(const tal_t *ctx, struct payment *p) else if (amount_msat_greater_eq(p->amount, hint->estimated_capacity)) + /* We exclude on equality because we've set the + * estimate to the smallest failed attempt. */ tal_arr_expand(&res, hint->scid); + else if (hint->local && hint->htlc_budget == 0) /* If we cannot add any HTLCs to the channel we * shouldn't look for a route through that channel */ @@ -850,11 +853,9 @@ handle_intermediate_failure(struct command *cmd, case WIRE_TEMPORARY_CHANNEL_FAILURE: { /* These are an indication that the capacity was insufficient, * remember the amount we tried as an estimate. */ - struct amount_msat est = errchan->amount; - est.millisatoshis *= 0.75; /* Raw: Multiplication */ channel_hints_update(root, errchan->channel_id, - errchan->direction, true, false, &est, - NULL); + errchan->direction, true, false, + &errchan->amount, NULL); goto error; }