@@ -331,11 +331,31 @@ const char *fmt_flow_full(const tal_t *ctx,
331
331
return str ;
332
332
}
333
333
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
+
334
352
struct getroutes_info {
335
353
struct command * cmd ;
336
354
struct node_id source , dest ;
337
355
struct amount_msat amount , maxfee ;
338
356
u32 finalcltv , maxdelay ;
357
+ /* algorithm selection, only dev */
358
+ enum algorithm dev_algo ;
339
359
const char * * layers ;
340
360
struct additional_cost_htable * additional_costs ;
341
361
/* Non-NULL if we are told to use "auto.localchans" */
@@ -567,8 +587,9 @@ static struct command_result *do_getroutes(struct command *cmd,
567
587
}
568
588
569
589
/* Compute the routes. At this point we might select between multiple
570
- * algorithms. */
590
+ * algorithms. Right now there is only one algorithm available. */
571
591
struct timemono time_start = time_mono ();
592
+ assert (info -> dev_algo == ALGO_DEFAULT );
572
593
err = default_routes (rq , rq , srcnode , dstnode , info -> amount ,
573
594
/* only one path? = */
574
595
have_layer (info -> layers , "auto.no_mpp_support" ),
@@ -722,6 +743,7 @@ static struct command_result *json_getroutes(struct command *cmd,
722
743
struct node_id * source , * dest ;
723
744
struct amount_msat * amount , * maxfee ;
724
745
u32 * finalcltv , * maxdelay ;
746
+ enum algorithm * dev_algo ;
725
747
726
748
if (!param_check (cmd , buffer , params ,
727
749
p_req ("source" , param_node_id , & source ),
@@ -732,6 +754,8 @@ static struct command_result *json_getroutes(struct command *cmd,
732
754
p_req ("final_cltv" , param_u32 , & finalcltv ),
733
755
p_opt_def ("maxdelay" , param_u32 , & maxdelay ,
734
756
maxdelay_allowed ),
757
+ p_opt_dev ("dev_algorithm" , param_algorithm ,
758
+ & dev_algo , ALGO_DEFAULT ),
735
759
NULL ))
736
760
return command_param_failed ();
737
761
plugin_log (cmd -> plugin , LOG_TRACE , "%s called: %.*s" , __func__ ,
@@ -758,6 +782,7 @@ static struct command_result *json_getroutes(struct command *cmd,
758
782
info -> maxfee = * maxfee ;
759
783
info -> finalcltv = * finalcltv ;
760
784
info -> maxdelay = * maxdelay ;
785
+ info -> dev_algo = * dev_algo ;
761
786
info -> additional_costs = tal (info , struct additional_cost_htable );
762
787
additional_cost_htable_init (info -> additional_costs );
763
788
0 commit comments