MCPcopy Create free account
hub / github.com/ElementsProject/lightning / retry_step_cb

Function retry_step_cb

plugins/libplugin-pay.c:2545–2597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2543}
2544
2545static struct command_result *retry_step_cb(struct retry_mod_data *rd,
2546 struct payment *p)
2547{
2548 struct payment *subpayment, *root = payment_root(p);
2549 struct retry_mod_data *rdata = payment_mod_retry_get_data(p);
2550 struct timemono now = time_mono();
2551
2552 if (p->step != PAYMENT_STEP_FAILED)
2553 return payment_continue(p);
2554
2555 if (timemono_after(now, p->deadline)) {
2556 paymod_log(
2557 p, LOG_INFORM,
2558 "Payment deadline expired, not retrying (partial-)payment "
2559 "%s/%d",
2560 fmt_sha256(tmpctx, p->payment_hash),
2561 p->partid);
2562 root->abort = true;
2563 return payment_continue(p);
2564 }
2565
2566 /* If we failed to find a route, it's unlikely we can suddenly find a
2567 * new one without any other changes, so it's time to give up. */
2568 if (p->route == NULL && !p->failroute_retry)
2569 return payment_continue(p);
2570
2571 /* If the root is marked as abort, we do not retry anymore */
2572 if (payment_root(p)->abort)
2573 return payment_continue(p);
2574
2575 if (!payment_can_retry(p))
2576 return payment_continue(p);
2577
2578 /* If the failure was not final, and we tried a route, try again. */
2579 if (rdata->retries > 0) {
2580 payment_set_step(p, PAYMENT_STEP_RETRY);
2581 subpayment = payment_new(p, NULL, p, NULL, p->modifiers);
2582 payment_start(subpayment);
2583 subpayment->why =
2584 tal_fmt(subpayment, "Still have %d attempts left",
2585 rdata->retries - 1);
2586 paymod_log(
2587 p, LOG_DBG,
2588 "Retrying %s/%d (%s), new partid %d. %d attempts left\n",
2589 fmt_sha256(tmpctx, p->payment_hash),
2590 p->partid,
2591 fmt_amount_msat(tmpctx, p->our_amount),
2592 subpayment->partid,
2593 rdata->retries - 1);
2594 }
2595
2596 return payment_continue(p);
2597}
2598
2599REGISTER_PAYMENT_MODIFIER(retry, struct retry_mod_data *, retry_data_init,
2600 retry_step_cb);

Callers

nothing calls this directly

Calls 11

payment_rootFunction · 0.85
time_monoFunction · 0.85
timemono_afterFunction · 0.85
paymod_logFunction · 0.85
fmt_sha256Function · 0.85
payment_can_retryFunction · 0.85
payment_set_stepFunction · 0.85
payment_continueFunction · 0.70
payment_newFunction · 0.70
payment_startFunction · 0.70
fmt_amount_msatFunction · 0.50

Tested by

no test coverage detected