mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
pay: Retry the route computation if we could not apply the chanhints
This adds a new state `PAYMENT_STEP_RETRY_GETROUTE` which is used to retry just that one step, without spawning a completely new attempt. It's a new state so that modifiers do not act on it twice. Changelog-Fixed: pay: Improved the performance of the `pay` command considerably by avoiding conflicting changes to our local network view.
This commit is contained in:
parent
544e110c96
commit
4d6b4a0445
2 changed files with 18 additions and 1 deletions
|
@ -1525,7 +1525,18 @@ static void payment_compute_onion_payloads(struct payment *p)
|
||||||
p->step = PAYMENT_STEP_ONION_PAYLOAD;
|
p->step = PAYMENT_STEP_ONION_PAYLOAD;
|
||||||
hopcount = tal_count(p->route);
|
hopcount = tal_count(p->route);
|
||||||
|
|
||||||
payment_chanhints_apply_route(p, false);
|
/* Now that we are about to fix the route parameters by
|
||||||
|
* encoding them in an onion is the right time to update the
|
||||||
|
* channel hints. */
|
||||||
|
if (!payment_chanhints_apply_route(p, false)) {
|
||||||
|
/* We can still end up with a failed channel_hints
|
||||||
|
* update, either because a plugin changed the route,
|
||||||
|
* or because a modifier was not synchronous, allowing
|
||||||
|
* for multiple concurrent routes being built. If that
|
||||||
|
* is the case, discard this route and retry. */
|
||||||
|
payment_set_step(p, PAYMENT_STEP_RETRY_GETROUTE);
|
||||||
|
return payment_continue(p);
|
||||||
|
}
|
||||||
|
|
||||||
/* Now compute the payload we're about to pass to `createonion` */
|
/* Now compute the payload we're about to pass to `createonion` */
|
||||||
cr = p->createonion_request = tal(p, struct createonion_request);
|
cr = p->createonion_request = tal(p, struct createonion_request);
|
||||||
|
@ -1873,6 +1884,7 @@ void payment_continue(struct payment *p)
|
||||||
p->current_modifier = -1;
|
p->current_modifier = -1;
|
||||||
switch (p->step) {
|
switch (p->step) {
|
||||||
case PAYMENT_STEP_INITIALIZED:
|
case PAYMENT_STEP_INITIALIZED:
|
||||||
|
case PAYMENT_STEP_RETRY_GETROUTE:
|
||||||
payment_getroute(p);
|
payment_getroute(p);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,11 @@ enum payment_step {
|
||||||
* to amend the route. */
|
* to amend the route. */
|
||||||
PAYMENT_STEP_GOT_ROUTE = 2,
|
PAYMENT_STEP_GOT_ROUTE = 2,
|
||||||
|
|
||||||
|
/* Something went wrong with the route returned by the
|
||||||
|
previous step, so retry, but do not rerun the INITIALIZED
|
||||||
|
modifiers. */
|
||||||
|
PAYMENT_STEP_RETRY_GETROUTE = 3,
|
||||||
|
|
||||||
/* We just computed the onion payload, allow modifiers to amend,
|
/* We just computed the onion payload, allow modifiers to amend,
|
||||||
* before constructing the onion packet. */
|
* before constructing the onion packet. */
|
||||||
PAYMENT_STEP_ONION_PAYLOAD = 4,
|
PAYMENT_STEP_ONION_PAYLOAD = 4,
|
||||||
|
|
Loading…
Add table
Reference in a new issue