mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
pay: Factor out execution of getroute from starting of payment attempt.
This commit is contained in:
committed by
Christian Decker
parent
54cc735201
commit
e9aa690d44
@@ -724,35 +724,18 @@ static const char **dup_excludes(const tal_t *ctx, const char **excludes)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct command_result *start_pay_attempt(struct command *cmd,
|
/* Get a route from the lightningd. */
|
||||||
struct pay_command *pc,
|
static struct command_result *execute_getroute(struct command *cmd,
|
||||||
const char *fmt, ...)
|
struct pay_command *pc)
|
||||||
{
|
{
|
||||||
|
struct pay_attempt *attempt = current_attempt(pc);
|
||||||
|
|
||||||
|
u32 max_hops = ROUTING_MAX_HOPS;
|
||||||
struct amount_msat msat;
|
struct amount_msat msat;
|
||||||
const char *dest;
|
const char *dest;
|
||||||
u32 max_hops = ROUTING_MAX_HOPS;
|
|
||||||
u32 cltv;
|
u32 cltv;
|
||||||
struct pay_attempt *attempt;
|
|
||||||
va_list ap;
|
|
||||||
size_t n;
|
|
||||||
struct json_out *params;
|
struct json_out *params;
|
||||||
|
|
||||||
n = tal_count(pc->ps->attempts);
|
|
||||||
tal_resize(&pc->ps->attempts, n+1);
|
|
||||||
attempt = &pc->ps->attempts[n];
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
attempt->start = time_now();
|
|
||||||
/* Mark it unfinished */
|
|
||||||
attempt->end.ts.tv_sec = -1;
|
|
||||||
attempt->excludes = dup_excludes(pc->ps, pc->excludes);
|
|
||||||
attempt->route = NULL;
|
|
||||||
attempt->failure = NULL;
|
|
||||||
attempt->result = NULL;
|
|
||||||
attempt->sendpay = false;
|
|
||||||
attempt->why = tal_vfmt(pc->ps, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
/* routehint set below. */
|
/* routehint set below. */
|
||||||
|
|
||||||
/* If we have a routehint, try that first; we need to do extra
|
/* If we have a routehint, try that first; we need to do extra
|
||||||
@@ -804,6 +787,33 @@ static struct command_result *start_pay_attempt(struct command *cmd,
|
|||||||
take(params));
|
take(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct command_result *start_pay_attempt(struct command *cmd,
|
||||||
|
struct pay_command *pc,
|
||||||
|
const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct pay_attempt *attempt;
|
||||||
|
va_list ap;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
|
n = tal_count(pc->ps->attempts);
|
||||||
|
tal_resize(&pc->ps->attempts, n+1);
|
||||||
|
attempt = &pc->ps->attempts[n];
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
attempt->start = time_now();
|
||||||
|
/* Mark it unfinished */
|
||||||
|
attempt->end.ts.tv_sec = -1;
|
||||||
|
attempt->excludes = dup_excludes(pc->ps, pc->excludes);
|
||||||
|
attempt->route = NULL;
|
||||||
|
attempt->failure = NULL;
|
||||||
|
attempt->result = NULL;
|
||||||
|
attempt->sendpay = false;
|
||||||
|
attempt->why = tal_vfmt(pc->ps, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return execute_getroute(cmd, pc);
|
||||||
|
}
|
||||||
|
|
||||||
/* BOLT #7:
|
/* BOLT #7:
|
||||||
*
|
*
|
||||||
* If a route is computed by simply routing to the intended recipient and
|
* If a route is computed by simply routing to the intended recipient and
|
||||||
|
|||||||
Reference in New Issue
Block a user