@@ -974,8 +974,7 @@ struct flow **minflow(const tal_t *ctx,
974
974
const struct gossmap_node * target ,
975
975
struct amount_msat amount ,
976
976
u32 mu ,
977
- double delay_feefactor ,
978
- bool single_part )
977
+ double delay_feefactor )
979
978
{
980
979
struct flow * * flow_paths ;
981
980
/* We allocate everything off this, and free it at the end,
@@ -1068,31 +1067,6 @@ struct flow **minflow(const tal_t *ctx,
1068
1067
goto fail ;
1069
1068
}
1070
1069
tal_free (working_ctx );
1071
-
1072
- /* This is dumb, but if you don't support MPP you don't deserve any
1073
- * better. Pile it into the largest part if not already. */
1074
- if (single_part ) {
1075
- struct flow * best = flow_paths [0 ];
1076
- for (size_t i = 1 ; i < tal_count (flow_paths ); i ++ ) {
1077
- if (amount_msat_greater (flow_paths [i ]-> delivers , best -> delivers ))
1078
- best = flow_paths [i ];
1079
- }
1080
- for (size_t i = 0 ; i < tal_count (flow_paths ); i ++ ) {
1081
- if (flow_paths [i ] == best )
1082
- continue ;
1083
- if (!amount_msat_accumulate (& best -> delivers ,
1084
- flow_paths [i ]-> delivers )) {
1085
- rq_log (tmpctx , rq , LOG_BROKEN ,
1086
- "%s: failed to extract accumulate flow paths %s+%s" ,
1087
- __func__ ,
1088
- fmt_amount_msat (tmpctx , best -> delivers ),
1089
- fmt_amount_msat (tmpctx , flow_paths [i ]-> delivers ));
1090
- goto fail ;
1091
- }
1092
- }
1093
- flow_paths [0 ] = best ;
1094
- tal_resize (& flow_paths , 1 );
1095
- }
1096
1070
return flow_paths ;
1097
1071
1098
1072
fail :
@@ -1286,21 +1260,23 @@ struct flow **single_path_flow(const tal_t *ctx, const struct route_query *rq,
1286
1260
return NULL ;
1287
1261
}
1288
1262
1289
- const char * default_routes (const tal_t * ctx , struct route_query * rq ,
1290
- const struct gossmap_node * srcnode ,
1291
- const struct gossmap_node * dstnode ,
1292
- struct amount_msat amount , bool single_path ,
1293
- struct amount_msat maxfee , u32 finalcltv ,
1294
- u32 maxdelay , struct flow * * * flows ,
1295
- double * probability )
1263
+ static const char *
1264
+ linear_routes (const tal_t * ctx , struct route_query * rq ,
1265
+ const struct gossmap_node * srcnode ,
1266
+ const struct gossmap_node * dstnode , struct amount_msat amount ,
1267
+ struct amount_msat maxfee , u32 finalcltv , u32 maxdelay ,
1268
+ struct flow * * * flows , double * probability ,
1269
+ struct flow * * (* solver )(const tal_t * , const struct route_query * ,
1270
+ const struct gossmap_node * ,
1271
+ const struct gossmap_node * ,
1272
+ struct amount_msat , u32 , double ))
1296
1273
{
1297
1274
const char * ret ;
1298
1275
double delay_feefactor = 1.0 / 1000000 ;
1299
1276
1300
1277
/* First up, don't care about fees (well, just enough to tiebreak!) */
1301
1278
u32 mu = 1 ;
1302
- * flows = minflow (ctx , rq , srcnode , dstnode , amount , mu , delay_feefactor ,
1303
- single_path );
1279
+ * flows = solver (ctx , rq , srcnode , dstnode , amount , mu , delay_feefactor );
1304
1280
if (!* flows ) {
1305
1281
ret = explain_failure (ctx , rq , srcnode , dstnode , amount );
1306
1282
goto fail ;
@@ -1314,8 +1290,8 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
1314
1290
" (> %i), retrying with delay_feefactor %f..." ,
1315
1291
flows_worst_delay (* flows ), maxdelay - finalcltv ,
1316
1292
delay_feefactor );
1317
- * flows = minflow (ctx , rq , srcnode , dstnode , amount , mu ,
1318
- delay_feefactor , single_path );
1293
+ * flows = solver (ctx , rq , srcnode , dstnode , amount , mu ,
1294
+ delay_feefactor );
1319
1295
if (!* flows || delay_feefactor > 10 ) {
1320
1296
ret = rq_log (
1321
1297
ctx , rq , LOG_UNUSUAL ,
@@ -1338,9 +1314,8 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
1338
1314
"retrying with mu of %u%%..." ,
1339
1315
fmt_amount_msat (tmpctx , flowset_fee (rq -> plugin , * flows )),
1340
1316
fmt_amount_msat (tmpctx , maxfee ), mu );
1341
- new_flows =
1342
- minflow (ctx , rq , srcnode , dstnode , amount ,
1343
- mu > 100 ? 100 : mu , delay_feefactor , single_path );
1317
+ new_flows = solver (ctx , rq , srcnode , dstnode , amount ,
1318
+ mu > 100 ? 100 : mu , delay_feefactor );
1344
1319
if (!* flows || mu >= 100 ) {
1345
1320
ret = rq_log (
1346
1321
ctx , rq , LOG_UNUSUAL ,
@@ -1421,3 +1396,27 @@ const char *default_routes(const tal_t *ctx, struct route_query *rq,
1421
1396
assert (ret != NULL );
1422
1397
return ret ;
1423
1398
}
1399
+
1400
+ const char * default_routes (const tal_t * ctx , struct route_query * rq ,
1401
+ const struct gossmap_node * srcnode ,
1402
+ const struct gossmap_node * dstnode ,
1403
+ struct amount_msat amount , struct amount_msat maxfee ,
1404
+ u32 finalcltv , u32 maxdelay , struct flow * * * flows ,
1405
+ double * probability )
1406
+ {
1407
+ return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1408
+ finalcltv , maxdelay , flows , probability , minflow );
1409
+ }
1410
+
1411
+ const char * single_path_routes (const tal_t * ctx , struct route_query * rq ,
1412
+ const struct gossmap_node * srcnode ,
1413
+ const struct gossmap_node * dstnode ,
1414
+ struct amount_msat amount ,
1415
+ struct amount_msat maxfee , u32 finalcltv ,
1416
+ u32 maxdelay , struct flow * * * flows ,
1417
+ double * probability )
1418
+ {
1419
+ return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1420
+ finalcltv , maxdelay , flows , probability ,
1421
+ single_path_flow );
1422
+ }
0 commit comments