@@ -973,8 +973,7 @@ struct flow **minflow(const tal_t *ctx,
973973 const struct gossmap_node * target ,
974974 struct amount_msat amount ,
975975 u32 mu ,
976- double delay_feefactor ,
977- bool single_part )
976+ double delay_feefactor )
978977{
979978 struct flow * * flow_paths ;
980979 /* We allocate everything off this, and free it at the end,
@@ -1067,31 +1066,6 @@ struct flow **minflow(const tal_t *ctx,
10671066 goto fail ;
10681067 }
10691068 tal_free (working_ctx );
1070-
1071- /* This is dumb, but if you don't support MPP you don't deserve any
1072- * better. Pile it into the largest part if not already. */
1073- if (single_part ) {
1074- struct flow * best = flow_paths [0 ];
1075- for (size_t i = 1 ; i < tal_count (flow_paths ); i ++ ) {
1076- if (amount_msat_greater (flow_paths [i ]-> delivers , best -> delivers ))
1077- best = flow_paths [i ];
1078- }
1079- for (size_t i = 0 ; i < tal_count (flow_paths ); i ++ ) {
1080- if (flow_paths [i ] == best )
1081- continue ;
1082- if (!amount_msat_accumulate (& best -> delivers ,
1083- flow_paths [i ]-> delivers )) {
1084- rq_log (tmpctx , rq , LOG_BROKEN ,
1085- "%s: failed to extract accumulate flow paths %s+%s" ,
1086- __func__ ,
1087- fmt_amount_msat (tmpctx , best -> delivers ),
1088- fmt_amount_msat (tmpctx , flow_paths [i ]-> delivers ));
1089- goto fail ;
1090- }
1091- }
1092- flow_paths [0 ] = best ;
1093- tal_resize (& flow_paths , 1 );
1094- }
10951069 return flow_paths ;
10961070
10971071fail :
@@ -1283,21 +1257,23 @@ struct flow **single_path_flow(const tal_t *ctx, const struct route_query *rq,
12831257 return NULL ;
12841258}
12851259
1286- const char * default_routes (const tal_t * ctx , struct route_query * rq ,
1287- const struct gossmap_node * srcnode ,
1288- const struct gossmap_node * dstnode ,
1289- struct amount_msat amount , bool single_path ,
1290- struct amount_msat maxfee , u32 finalcltv ,
1291- u32 maxdelay , struct flow * * * flows ,
1292- double * probability )
1260+ static const char *
1261+ linear_routes (const tal_t * ctx , struct route_query * rq ,
1262+ const struct gossmap_node * srcnode ,
1263+ const struct gossmap_node * dstnode , struct amount_msat amount ,
1264+ struct amount_msat maxfee , u32 finalcltv , u32 maxdelay ,
1265+ struct flow * * * flows , double * probability ,
1266+ struct flow * * (* solver )(const tal_t * , const struct route_query * ,
1267+ const struct gossmap_node * ,
1268+ const struct gossmap_node * ,
1269+ struct amount_msat , u32 , double ))
12931270{
12941271 const char * ret ;
12951272 double delay_feefactor = 1.0 / 1000000 ;
12961273
12971274 /* First up, don't care about fees (well, just enough to tiebreak!) */
12981275 u32 mu = 1 ;
1299- * flows = minflow (ctx , rq , srcnode , dstnode , amount , mu , delay_feefactor ,
1300- single_path );
1276+ * flows = solver (ctx , rq , srcnode , dstnode , amount , mu , delay_feefactor );
13011277 if (!* flows ) {
13021278 ret = explain_failure (ctx , rq , srcnode , dstnode , amount );
13031279 goto fail ;
@@ -1311,8 +1287,8 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
13111287 " (> %i), retrying with delay_feefactor %f..." ,
13121288 flows_worst_delay (* flows ), maxdelay - finalcltv ,
13131289 delay_feefactor );
1314- * flows = minflow (ctx , rq , srcnode , dstnode , amount , mu ,
1315- delay_feefactor , single_path );
1290+ * flows = solver (ctx , rq , srcnode , dstnode , amount , mu ,
1291+ delay_feefactor );
13161292 if (!* flows || delay_feefactor > 10 ) {
13171293 ret = rq_log (
13181294 ctx , rq , LOG_UNUSUAL ,
@@ -1335,9 +1311,8 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
13351311 "retrying with mu of %u%%..." ,
13361312 fmt_amount_msat (tmpctx , flowset_fee (rq -> plugin , * flows )),
13371313 fmt_amount_msat (tmpctx , maxfee ), mu );
1338- new_flows =
1339- minflow (ctx , rq , srcnode , dstnode , amount ,
1340- mu > 100 ? 100 : mu , delay_feefactor , single_path );
1314+ new_flows = solver (ctx , rq , srcnode , dstnode , amount ,
1315+ mu > 100 ? 100 : mu , delay_feefactor );
13411316 if (!* flows || mu >= 100 ) {
13421317 ret = rq_log (
13431318 ctx , rq , LOG_UNUSUAL ,
@@ -1418,3 +1393,27 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
14181393 assert (ret != NULL );
14191394 return ret ;
14201395}
1396+
1397+ const char * default_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 , struct amount_msat maxfee ,
1401+ u32 finalcltv , u32 maxdelay , struct flow * * * flows ,
1402+ double * probability )
1403+ {
1404+ return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1405+ finalcltv , maxdelay , flows , probability , minflow );
1406+ }
1407+
1408+ const char * single_path_routes (const tal_t * ctx , struct route_query * rq ,
1409+ const struct gossmap_node * srcnode ,
1410+ const struct gossmap_node * dstnode ,
1411+ struct amount_msat amount ,
1412+ struct amount_msat maxfee , u32 finalcltv ,
1413+ u32 maxdelay , struct flow * * * flows ,
1414+ double * probability )
1415+ {
1416+ return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1417+ finalcltv , maxdelay , flows , probability ,
1418+ single_path_flow );
1419+ }
0 commit comments