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

Function retry_step_cb

plugins/libplugin-pay.c:2529–2581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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