@@ -365,9 +365,13 @@ static void linearize_channel(const struct pay_parameters *params,
365
365
b = 1 + amount_msat_ratio_floor (maxcap , params -> accuracy );
366
366
367
367
/* An extra bound on capacity, here we use it to reduce the flow such
368
- * that it does not exceed htlcmax. */
368
+ * that it does not exceed htlcmax.
369
+ * Also there is no need to keep track of more capacity than the payment
370
+ * amount, this can help us prune some arcs. */
369
371
u64 cap_on_capacity =
370
- amount_msat_ratio_floor (gossmap_chan_htlc_max (c , dir ), params -> accuracy );
372
+ MIN (amount_msat_ratio_floor (gossmap_chan_htlc_max (c , dir ),
373
+ params -> accuracy ),
374
+ amount_msat_ratio_ceil (params -> amount , params -> accuracy ));
371
375
372
376
set_capacity (& capacity [0 ], a , & cap_on_capacity );
373
377
cost [0 ]= 0 ;
@@ -603,8 +607,9 @@ static void init_linear_network(const tal_t *ctx,
603
607
// when the `i` hits the `next` node.
604
608
for (size_t k = 0 ;k < CHANNEL_PARTS ;++ k )
605
609
{
606
- /* FIXME: Can we prune arcs with 0 capacity?
607
- * if(capacity[k]==0)continue; */
610
+ /* prune arcs with 0 capacity */
611
+ if (capacity [k ] == 0 )
612
+ continue ;
608
613
609
614
struct arc arc = arc_from_parts (chan_id , half , k , false);
610
615
@@ -964,10 +969,14 @@ struct flow **minflow(const tal_t *ctx,
964
969
params -> source = source ;
965
970
params -> target = target ;
966
971
params -> amount = amount ;
967
- params -> accuracy = AMOUNT_MSAT (1000 );
968
- /* FIXME: params->accuracy = amount_msat_max(amount_msat_div(amount,
969
- * 1000), AMOUNT_MSAT(1));
972
+ /* -> At most 1M units of flow are allowed, that reduces the
973
+ * computational burden for algorithms that depend on it, eg. "capacity
974
+ * scaling" and "successive shortest path".
975
+ * -> Using Ceil operation instead of Floor so that
976
+ * accuracy x 1M >= amount
970
977
* */
978
+ params -> accuracy = amount_msat_max (
979
+ AMOUNT_MSAT (1 ), amount_msat_div_ceil (amount , 1000000 ));
971
980
972
981
// template the channel partition into linear arcs
973
982
params -> cap_fraction [0 ]= 0 ;
0 commit comments