Skip to content

Commit c194763

Browse files
committed
askrene: add a dev parameter to switch algorithm
Changelog-None Signed-off-by: Lagrang3 <[email protected]>
1 parent 1581ca2 commit c194763

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

plugins/askrene/askrene.c

+24-1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,24 @@ const char *fmt_flow_full(const tal_t *ctx,
331331
return str;
332332
}
333333

334+
enum algorithm {
335+
ALGO_DEFAULT,
336+
};
337+
338+
static struct command_result *
339+
param_algorithm(struct command *cmd, const char *name, const char *buffer,
340+
const jsmntok_t *tok, enum algorithm **algo)
341+
{
342+
const char *algo_str = json_strdup(cmd, buffer, tok);
343+
*algo = tal(cmd, enum algorithm);
344+
if (streq(algo_str, "default"))
345+
**algo = ALGO_DEFAULT;
346+
else
347+
return command_fail_badparam(cmd, name, buffer, tok,
348+
"unknown algorithm");
349+
return NULL;
350+
}
351+
334352
struct getroutes_info {
335353
struct command *cmd;
336354
struct node_id *source, *dest;
@@ -340,6 +358,8 @@ struct getroutes_info {
340358
struct additional_cost_htable *additional_costs;
341359
/* Non-NULL if we are told to use "auto.localchans" */
342360
struct layer *local_layer;
361+
/* algorithm selection, only dev */
362+
enum algorithm *dev_algo;
343363
};
344364

345365
static void apply_layers(struct askrene *askrene, struct route_query *rq,
@@ -564,8 +584,9 @@ static struct command_result *do_getroutes(struct command *cmd,
564584
}
565585

566586
/* Compute the routes. At this point we might select between multiple
567-
* algorithms. */
587+
* algorithms. Right now there is only one algorithm available. */
568588
struct timemono time_start = time_mono();
589+
assert(*info->dev_algo == ALGO_DEFAULT);
569590
err = default_routes(rq, rq, srcnode, dstnode, *info->amount,
570591
/* only one path? = */
571592
have_layer(info->layers, "auto.no_mpp_support"),
@@ -732,6 +753,8 @@ static struct command_result *json_getroutes(struct command *cmd,
732753
p_req("final_cltv", param_u32, &info->finalcltv),
733754
p_opt_def("maxdelay", param_u32, &info->maxdelay,
734755
maxdelay_allowed),
756+
p_opt_dev("dev_algorithm", param_algorithm,
757+
&info->dev_algo, ALGO_DEFAULT),
735758
NULL))
736759
return command_param_failed();
737760

0 commit comments

Comments
 (0)