@@ -331,11 +331,31 @@ 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+
334352struct getroutes_info {
335353 struct command * cmd ;
336354 struct node_id source , dest ;
337355 struct amount_msat amount , maxfee ;
338356 u32 finalcltv , maxdelay ;
357+ /* algorithm selection, only dev */
358+ enum algorithm dev_algo ;
339359 const char * * layers ;
340360 struct additional_cost_htable * additional_costs ;
341361 /* Non-NULL if we are told to use "auto.localchans" */
@@ -567,8 +587,9 @@ static struct command_result *do_getroutes(struct command *cmd,
567587 }
568588
569589 /* Compute the routes. At this point we might select between multiple
570- * algorithms. */
590+ * algorithms. Right now there is only one algorithm available. */
571591 struct timemono time_start = time_mono ();
592+ assert (info -> dev_algo == ALGO_DEFAULT );
572593 err = default_routes (rq , rq , srcnode , dstnode , info -> amount ,
573594 /* only one path? = */
574595 have_layer (info -> layers , "auto.no_mpp_support" ),
@@ -722,6 +743,7 @@ static struct command_result *json_getroutes(struct command *cmd,
722743 struct node_id * source , * dest ;
723744 struct amount_msat * amount , * maxfee ;
724745 u32 * finalcltv , * maxdelay ;
746+ enum algorithm * dev_algo ;
725747
726748 if (!param_check (cmd , buffer , params ,
727749 p_req ("source" , param_node_id , & source ),
@@ -732,6 +754,8 @@ static struct command_result *json_getroutes(struct command *cmd,
732754 p_req ("final_cltv" , param_u32 , & finalcltv ),
733755 p_opt_def ("maxdelay" , param_u32 , & maxdelay ,
734756 maxdelay_allowed ),
757+ p_opt_dev ("dev_algorithm" , param_algorithm ,
758+ & dev_algo , ALGO_DEFAULT ),
735759 NULL ))
736760 return command_param_failed ();
737761 plugin_log (cmd -> plugin , LOG_TRACE , "%s called: %.*s" , __func__ ,
@@ -758,6 +782,7 @@ static struct command_result *json_getroutes(struct command *cmd,
758782 info -> maxfee = * maxfee ;
759783 info -> finalcltv = * finalcltv ;
760784 info -> maxdelay = * maxdelay ;
785+ info -> dev_algo = * dev_algo ;
761786 info -> additional_costs = tal (info , struct additional_cost_htable );
762787 additional_cost_htable_init (info -> additional_costs );
763788
0 commit comments