@@ -952,8 +952,7 @@ struct flow **minflow(const tal_t *ctx,
952952 const struct gossmap_node * target ,
953953 struct amount_msat amount ,
954954 u32 mu ,
955- double delay_feefactor ,
956- bool single_part )
955+ double delay_feefactor )
957956{
958957 struct flow * * flow_paths ;
959958 /* We allocate everything off this, and free it at the end,
@@ -1044,31 +1043,6 @@ struct flow **minflow(const tal_t *ctx,
10441043 goto fail ;
10451044 }
10461045 tal_free (working_ctx );
1047-
1048- /* This is dumb, but if you don't support MPP you don't deserve any
1049- * better. Pile it into the largest part if not already. */
1050- if (single_part ) {
1051- struct flow * best = flow_paths [0 ];
1052- for (size_t i = 1 ; i < tal_count (flow_paths ); i ++ ) {
1053- if (amount_msat_greater (flow_paths [i ]-> delivers , best -> delivers ))
1054- best = flow_paths [i ];
1055- }
1056- for (size_t i = 0 ; i < tal_count (flow_paths ); i ++ ) {
1057- if (flow_paths [i ] == best )
1058- continue ;
1059- if (!amount_msat_accumulate (& best -> delivers ,
1060- flow_paths [i ]-> delivers )) {
1061- rq_log (tmpctx , rq , LOG_BROKEN ,
1062- "%s: failed to extract accumulate flow paths %s+%s" ,
1063- __func__ ,
1064- fmt_amount_msat (tmpctx , best -> delivers ),
1065- fmt_amount_msat (tmpctx , flow_paths [i ]-> delivers ));
1066- goto fail ;
1067- }
1068- }
1069- flow_paths [0 ] = best ;
1070- tal_resize (& flow_paths , 1 );
1071- }
10721046 return flow_paths ;
10731047
10741048fail :
@@ -1273,21 +1247,23 @@ struct flow **single_path_flow(const tal_t *ctx, const struct route_query *rq,
12731247 return NULL ;
12741248}
12751249
1276- const char * default_routes (const tal_t * ctx , struct route_query * rq ,
1277- const struct gossmap_node * srcnode ,
1278- const struct gossmap_node * dstnode ,
1279- struct amount_msat amount , bool single_path ,
1280- struct amount_msat maxfee , u32 finalcltv ,
1281- u32 maxdelay , struct flow * * * flows ,
1282- double * probability )
1250+ static const char *
1251+ linear_routes (const tal_t * ctx , struct route_query * rq ,
1252+ const struct gossmap_node * srcnode ,
1253+ const struct gossmap_node * dstnode , struct amount_msat amount ,
1254+ struct amount_msat maxfee , u32 finalcltv , u32 maxdelay ,
1255+ struct flow * * * flows , double * probability ,
1256+ struct flow * * (* solver )(const tal_t * , const struct route_query * ,
1257+ const struct gossmap_node * ,
1258+ const struct gossmap_node * ,
1259+ struct amount_msat , u32 , double ))
12831260{
12841261 const char * ret ;
12851262 double delay_feefactor = 1.0 / 1000000 ;
12861263
12871264 /* First up, don't care about fees (well, just enough to tiebreak!) */
12881265 u32 mu = 1 ;
1289- * flows = minflow (ctx , rq , srcnode , dstnode , amount , mu , delay_feefactor ,
1290- single_path );
1266+ * flows = solver (ctx , rq , srcnode , dstnode , amount , mu , delay_feefactor );
12911267 if (!* flows ) {
12921268 ret = explain_failure (ctx , rq , srcnode , dstnode , amount );
12931269 goto fail ;
@@ -1301,8 +1277,8 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
13011277 " (> %i), retrying with delay_feefactor %f..." ,
13021278 flows_worst_delay (* flows ), maxdelay - finalcltv ,
13031279 delay_feefactor );
1304- * flows = minflow (ctx , rq , srcnode , dstnode , amount , mu ,
1305- delay_feefactor , single_path );
1280+ * flows = solver (ctx , rq , srcnode , dstnode , amount , mu ,
1281+ delay_feefactor );
13061282 if (!* flows || delay_feefactor > 10 ) {
13071283 ret = rq_log (
13081284 ctx , rq , LOG_UNUSUAL ,
@@ -1325,9 +1301,8 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
13251301 "retrying with mu of %u%%..." ,
13261302 fmt_amount_msat (tmpctx , flowset_fee (rq -> plugin , * flows )),
13271303 fmt_amount_msat (tmpctx , maxfee ), mu );
1328- new_flows =
1329- minflow (ctx , rq , srcnode , dstnode , amount ,
1330- mu > 100 ? 100 : mu , delay_feefactor , single_path );
1304+ new_flows = solver (ctx , rq , srcnode , dstnode , amount ,
1305+ mu > 100 ? 100 : mu , delay_feefactor );
13311306 if (!* flows || mu >= 100 ) {
13321307 ret = rq_log (
13331308 ctx , rq , LOG_UNUSUAL ,
@@ -1408,3 +1383,27 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
14081383 assert (ret != NULL );
14091384 return ret ;
14101385}
1386+
1387+ const char * default_routes (const tal_t * ctx , struct route_query * rq ,
1388+ const struct gossmap_node * srcnode ,
1389+ const struct gossmap_node * dstnode ,
1390+ struct amount_msat amount , struct amount_msat maxfee ,
1391+ u32 finalcltv , u32 maxdelay , struct flow * * * flows ,
1392+ double * probability )
1393+ {
1394+ return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1395+ finalcltv , maxdelay , flows , probability , minflow );
1396+ }
1397+
1398+ const char * single_path_routes (const tal_t * ctx , struct route_query * rq ,
1399+ const struct gossmap_node * srcnode ,
1400+ const struct gossmap_node * dstnode ,
1401+ struct amount_msat amount ,
1402+ struct amount_msat maxfee , u32 finalcltv ,
1403+ u32 maxdelay , struct flow * * * flows ,
1404+ double * probability )
1405+ {
1406+ return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1407+ finalcltv , maxdelay , flows , probability ,
1408+ single_path_flow );
1409+ }
0 commit comments