@@ -948,8 +948,7 @@ struct flow **minflow(const tal_t *ctx,
948948 const struct gossmap_node * target ,
949949 struct amount_msat amount ,
950950 u32 mu ,
951- double delay_feefactor ,
952- bool single_part )
951+ double delay_feefactor )
953952{
954953 struct flow * * flow_paths ;
955954 /* We allocate everything off this, and free it at the end,
@@ -1040,31 +1039,6 @@ struct flow **minflow(const tal_t *ctx,
10401039 goto fail ;
10411040 }
10421041 tal_free (working_ctx );
1043-
1044- /* This is dumb, but if you don't support MPP you don't deserve any
1045- * better. Pile it into the largest part if not already. */
1046- if (single_part ) {
1047- struct flow * best = flow_paths [0 ];
1048- for (size_t i = 1 ; i < tal_count (flow_paths ); i ++ ) {
1049- if (amount_msat_greater (flow_paths [i ]-> delivers , best -> delivers ))
1050- best = flow_paths [i ];
1051- }
1052- for (size_t i = 0 ; i < tal_count (flow_paths ); i ++ ) {
1053- if (flow_paths [i ] == best )
1054- continue ;
1055- if (!amount_msat_accumulate (& best -> delivers ,
1056- flow_paths [i ]-> delivers )) {
1057- rq_log (tmpctx , rq , LOG_BROKEN ,
1058- "%s: failed to extract accumulate flow paths %s+%s" ,
1059- __func__ ,
1060- fmt_amount_msat (tmpctx , best -> delivers ),
1061- fmt_amount_msat (tmpctx , flow_paths [i ]-> delivers ));
1062- goto fail ;
1063- }
1064- }
1065- flow_paths [0 ] = best ;
1066- tal_resize (& flow_paths , 1 );
1067- }
10681042 return flow_paths ;
10691043
10701044fail :
@@ -1269,13 +1243,16 @@ struct flow **single_path_flow(const tal_t *ctx, const struct route_query *rq,
12691243 return NULL ;
12701244}
12711245
1272- const char * default_routes (const tal_t * ctx , struct route_query * rq ,
1273- const struct gossmap_node * srcnode ,
1274- const struct gossmap_node * dstnode ,
1275- struct amount_msat amount , bool single_path ,
1276- struct amount_msat maxfee , u32 finalcltv ,
1277- u32 maxdelay , struct flow * * * flows ,
1278- double * probability )
1246+ static const char *
1247+ linear_routes (const tal_t * ctx , struct route_query * rq ,
1248+ const struct gossmap_node * srcnode ,
1249+ const struct gossmap_node * dstnode , struct amount_msat amount ,
1250+ struct amount_msat maxfee , u32 finalcltv , u32 maxdelay ,
1251+ struct flow * * * flows , double * probability ,
1252+ struct flow * * (* solver )(const tal_t * , const struct route_query * ,
1253+ const struct gossmap_node * ,
1254+ const struct gossmap_node * ,
1255+ struct amount_msat , u32 , double ))
12791256{
12801257 * flows = NULL ;
12811258 const char * ret ;
@@ -1284,8 +1261,7 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
12841261 /* First up, don't care about fees (well, just enough to tiebreak!) */
12851262 u32 mu = 1 ;
12861263 tal_free (* flows );
1287- * flows = minflow (ctx , rq , srcnode , dstnode , amount , mu , delay_feefactor ,
1288- single_path );
1264+ * flows = solver (ctx , rq , srcnode , dstnode , amount , mu , delay_feefactor );
12891265 if (!* flows ) {
12901266 ret = explain_failure (ctx , rq , srcnode , dstnode , amount );
12911267 goto fail ;
@@ -1300,8 +1276,8 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
13001276 flows_worst_delay (* flows ), maxdelay - finalcltv ,
13011277 delay_feefactor );
13021278 tal_free (* flows );
1303- * flows = minflow (ctx , rq , srcnode , dstnode , amount , mu ,
1304- delay_feefactor , single_path );
1279+ * flows = solver (ctx , rq , srcnode , dstnode , amount , mu ,
1280+ delay_feefactor );
13051281 if (!* flows || delay_feefactor > 10 ) {
13061282 ret = rq_log (
13071283 ctx , rq , LOG_UNUSUAL ,
@@ -1324,9 +1300,8 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
13241300 "retrying with mu of %u%%..." ,
13251301 fmt_amount_msat (tmpctx , flowset_fee (rq -> plugin , * flows )),
13261302 fmt_amount_msat (tmpctx , maxfee ), mu );
1327- new_flows =
1328- minflow (ctx , rq , srcnode , dstnode , amount ,
1329- mu > 100 ? 100 : mu , delay_feefactor , single_path );
1303+ new_flows = solver (ctx , rq , srcnode , dstnode , amount ,
1304+ mu > 100 ? 100 : mu , delay_feefactor );
13301305 if (!* flows || mu >= 100 ) {
13311306 ret = rq_log (
13321307 ctx , rq , LOG_UNUSUAL ,
@@ -1407,3 +1382,27 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
14071382 assert (ret != NULL );
14081383 return ret ;
14091384}
1385+
1386+ const char * default_routes (const tal_t * ctx , struct route_query * rq ,
1387+ const struct gossmap_node * srcnode ,
1388+ const struct gossmap_node * dstnode ,
1389+ struct amount_msat amount , struct amount_msat maxfee ,
1390+ u32 finalcltv , u32 maxdelay , struct flow * * * flows ,
1391+ double * probability )
1392+ {
1393+ return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1394+ finalcltv , maxdelay , flows , probability , minflow );
1395+ }
1396+
1397+ const char * single_path_routes (const tal_t * ctx , struct route_query * rq ,
1398+ const struct gossmap_node * srcnode ,
1399+ const struct gossmap_node * dstnode ,
1400+ struct amount_msat amount ,
1401+ struct amount_msat maxfee , u32 finalcltv ,
1402+ u32 maxdelay , struct flow * * * flows ,
1403+ double * probability )
1404+ {
1405+ return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1406+ finalcltv , maxdelay , flows , probability ,
1407+ single_path_flow );
1408+ }
0 commit comments