@@ -184,33 +184,24 @@ static int revcmp_flows(struct flow *const *a, struct flow *const *b, void *unus
184184// -> check that htlc_max are all satisfied
185185// -> check that (x+1) at least one htlc_max is violated
186186/* Given the channel constraints, return the maximum amount that can be
187- * delivered. Sets *bottleneck_idx to one of the contraining channels' idx, if non-NULL */
187+ * delivered. */
188188static struct amount_msat flow_max_deliverable (const struct route_query * rq ,
189- const struct flow * flow ,
190- u32 * bottleneck_idx )
189+ const struct flow * flow )
191190{
192191 struct amount_msat deliver = AMOUNT_MSAT (-1 );
193192 for (size_t i = 0 ; i < tal_count (flow -> path ); i ++ ) {
194193 const struct half_chan * hc = & flow -> path [i ]-> half [flow -> dirs [i ]];
195194 struct amount_msat unused , known_max , htlc_max ;
196- size_t idx = flow -> dirs [i ]
197- + 2 * gossmap_chan_idx (rq -> gossmap , flow -> path [i ]);
198-
199195 deliver = amount_msat_sub_fee (deliver , hc -> base_fee ,
200196 hc -> proportional_fee );
201197 htlc_max = get_chan_htlc_max (rq , flow -> path [i ], flow -> dirs [i ]);
202- if (amount_msat_greater (deliver , htlc_max )) {
203- if (bottleneck_idx )
204- * bottleneck_idx = idx ;
198+ if (amount_msat_greater (deliver , htlc_max ))
205199 deliver = htlc_max ;
206- }
200+
207201 get_constraints (rq , flow -> path [i ], flow -> dirs [i ],
208202 & unused , & known_max );
209- if (amount_msat_greater (deliver , known_max )) {
210- if (bottleneck_idx )
211- * bottleneck_idx = idx ;
203+ if (amount_msat_greater (deliver , known_max ))
212204 deliver = known_max ;
213- }
214205 }
215206 return deliver ;
216207}
@@ -436,7 +427,7 @@ static bool increase_flows(const struct route_query *rq,
436427 * htlc_max. So remove this reservation, to get the
437428 * real maximum for one flow, then replace it. */
438429 tal_free (reservations [i ]);
439- capacity = flow_max_deliverable (rq , flows [i ], NULL );
430+ capacity = flow_max_deliverable (rq , flows [i ]);
440431 reservations [i ] = new_reservations (reservations , rq );
441432 create_flow_reservations (rq , & reservations [i ], flows [i ]);
442433
@@ -475,8 +466,7 @@ static bool increase_flows(const struct route_query *rq,
475466}
476467
477468const char * refine_flows (const tal_t * ctx , struct route_query * rq ,
478- struct amount_msat deliver , struct flow * * * flows ,
479- u32 * bottleneck_idx )
469+ struct amount_msat deliver , struct flow * * * flows )
480470{
481471 const tal_t * working_ctx = tal (ctx , tal_t );
482472 const char * error_message = NULL ;
@@ -487,7 +477,7 @@ const char *refine_flows(const tal_t *ctx, struct route_query *rq,
487477 for (size_t i = 0 ; i < tal_count (* flows ); i ++ ) {
488478 (* flows )[i ]-> delivers =
489479 amount_msat_min ((* flows )[i ]-> delivers ,
490- flow_max_deliverable (rq , (* flows )[i ], bottleneck_idx ));
480+ flow_max_deliverable (rq , (* flows )[i ]));
491481 }
492482
493483 /* remove excess from MCF granularity if any */
@@ -570,7 +560,7 @@ void squash_flows(const tal_t *ctx, struct route_query *rq,
570560 /* same path? We merge */
571561 while (i + 1 < tal_count (* flows ) &&
572562 cmppath_flows (& flow , & (* flows )[i + 1 ], NULL ) == 0 ) {
573- struct amount_msat combined , max = flow_max_deliverable (rq , flow , NULL );
563+ struct amount_msat combined , max = flow_max_deliverable (rq , flow );
574564
575565 if (!amount_msat_add (& combined , flow -> delivers , (* flows )[i + 1 ]-> delivers ))
576566 abort ();
0 commit comments