mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +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:
committed by
Rusty Russell
parent
544e110c96
commit
4d6b4a0445
@@ -1525,7 +1525,18 @@ static void payment_compute_onion_payloads(struct payment *p)
|
||||
p->step = PAYMENT_STEP_ONION_PAYLOAD;
|
||||
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` */
|
||||
cr = p->createonion_request = tal(p, struct createonion_request);
|
||||
@@ -1873,6 +1884,7 @@ void payment_continue(struct payment *p)
|
||||
p->current_modifier = -1;
|
||||
switch (p->step) {
|
||||
case PAYMENT_STEP_INITIALIZED:
|
||||
case PAYMENT_STEP_RETRY_GETROUTE:
|
||||
payment_getroute(p);
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user