Skip to content

Commit 69adf38

Browse files
committed
askrene: remove now-unused bottleneck_idx from flow_max_deliverable.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 8c7ac33 commit 69adf38

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

plugins/askrene/mcf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,7 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
14121412
}
14131413

14141414
error_message =
1415-
refine_flows(ctx, rq, amount_to_deliver, &new_flows, NULL);
1415+
refine_flows(ctx, rq, amount_to_deliver, &new_flows);
14161416
if (error_message)
14171417
goto fail;
14181418

plugins/askrene/refine.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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. */
188188
static 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

477468
const 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();

plugins/askrene/refine.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ bool create_flow_reservations_verify(const struct route_query *rq,
2323

2424
/* Modify flows to meet HTLC min/max requirements.
2525
* It takes into account the exact value of the fees expected at each hop.
26-
* If we reduce flows because it's too large for one channel, *bottleneck_idx
27-
* is set to the idx of a channel which caused a reduction (if non-NULL).
2826
*/
2927
const char *refine_flows(const tal_t *ctx, struct route_query *rq,
30-
struct amount_msat deliver, struct flow ***flows,
31-
u32 *bottleneck_idx);
28+
struct amount_msat deliver, struct flow ***flows);
3229

3330
/* Duplicated flows are merged into one. This saves in base fee and HTLC fees.
3431
*/

0 commit comments

Comments
 (0)