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