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