Skip to content

Commit da220a8

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

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
@@ -347,6 +347,24 @@ static struct amount_msat linear_flows_cost(struct flow **flows,
347347
return total;
348348
}
349349

350+
enum algorithm {
351+
ALGO_DEFAULT,
352+
};
353+
354+
static struct command_result *
355+
param_algorithm(struct command *cmd, const char *name, const char *buffer,
356+
const jsmntok_t *tok, enum algorithm **algo)
357+
{
358+
const char *algo_str = json_strdup(cmd, buffer, tok);
359+
*algo = tal(cmd, enum algorithm);
360+
if (streq(algo_str, "default"))
361+
**algo = ALGO_DEFAULT;
362+
else
363+
return command_fail_badparam(cmd, name, buffer, tok,
364+
"unknown algorithm");
365+
return NULL;
366+
}
367+
350368
struct getroutes_info {
351369
struct command *cmd;
352370
struct node_id *source, *dest;
@@ -356,6 +374,8 @@ struct getroutes_info {
356374
struct additional_cost_htable *additional_costs;
357375
/* Non-NULL if we are told to use "auto.localchans" */
358376
struct layer *local_layer;
377+
/* algorithm selection, only dev */
378+
enum algorithm *dev_algo;
359379
};
360380

361381
static void apply_layers(struct askrene *askrene, struct route_query *rq,
@@ -582,8 +602,9 @@ static struct command_result *do_getroutes(struct command *cmd,
582602
}
583603

584604
/* Compute the routes. At this point we might select between multiple
585-
* algorithms. */
605+
* algorithms. Right now there is only one algorithm available. */
586606
struct timemono time_start = time_mono();
607+
assert(*info->dev_algo == ALGO_DEFAULT);
587608
err = default_routes(rq, rq, srcnode, dstnode, *info->amount,
588609
/* only one path? = */
589610
have_layer(info->layers, "auto.no_mpp_support"),
@@ -750,6 +771,8 @@ static struct command_result *json_getroutes(struct command *cmd,
750771
p_req("final_cltv", param_u32, &info->finalcltv),
751772
p_opt_def("maxdelay", param_u32, &info->maxdelay,
752773
maxdelay_allowed),
774+
p_opt_dev("dev_algorithm", param_algorithm,
775+
&info->dev_algo, ALGO_DEFAULT),
753776
NULL))
754777
return command_param_failed();
755778

0 commit comments

Comments
 (0)