Skip to content

Commit c31eed4

Browse files
committed
askrene: expose fmt_flow_full and make more generic.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 3387bba commit c31eed4

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

plugins/askrene/askrene.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,12 @@ static const char *fmt_route(const tal_t *ctx,
265265
return str;
266266
}
267267

268-
static const char *fmt_flow_full(const tal_t *ctx,
269-
const struct route_query *rq,
270-
const struct flow *flow,
271-
struct amount_msat total_delivered,
272-
double delay_feefactor)
268+
const char *fmt_flow_full(const tal_t *ctx,
269+
const struct route_query *rq,
270+
const struct flow *flow)
273271
{
274272
struct amount_msat amt = flow->delivers;
275-
char *str = tal_fmt(ctx, "%s (linear cost %s)",
276-
fmt_amount_msat(tmpctx, amt),
277-
fmt_amount_msat(tmpctx, linear_flow_cost(flow,
278-
total_delivered,
279-
delay_feefactor)));
273+
char *str = fmt_amount_msat(ctx, flow->delivers);
280274

281275
for (int i = tal_count(flow->path) - 1; i >= 0; i--) {
282276
struct short_channel_id_dir scidd;
@@ -465,15 +459,21 @@ static const char *get_routes(const tal_t *ctx,
465459
fmt_amount_msat(tmpctx, old_cost));
466460
for (size_t i = 0; i < tal_count(flows); i++) {
467461
rq_log(tmpctx, rq, LOG_BROKEN,
468-
"Flow %zu/%zu: %s", i, tal_count(flows),
469-
fmt_flow_full(tmpctx, rq, flows[i], amount, delay_feefactor));
462+
"Flow %zu/%zu: %s (linear cost %s)", i, tal_count(flows),
463+
fmt_flow_full(tmpctx, rq, flows[i]),
464+
fmt_amount_msat(tmpctx, linear_flow_cost(flows[i],
465+
amount,
466+
delay_feefactor)));
470467
}
471468
rq_log(tmpctx, rq, LOG_BROKEN, "Old flows cost %s:",
472469
fmt_amount_msat(tmpctx, new_cost));
473470
for (size_t i = 0; i < tal_count(new_flows); i++) {
474471
rq_log(tmpctx, rq, LOG_BROKEN,
475-
"Flow %zu/%zu: %s", i, tal_count(new_flows),
476-
fmt_flow_full(tmpctx, rq, new_flows[i], amount, delay_feefactor));
472+
"Flow %zu/%zu: %s (linear cost %s)", i, tal_count(new_flows),
473+
fmt_flow_full(tmpctx, rq, new_flows[i]),
474+
fmt_amount_msat(tmpctx, linear_flow_cost(new_flows[i],
475+
amount,
476+
delay_feefactor)));
477477
}
478478
}
479479
}

plugins/askrene/flow.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ u64 flows_worst_delay(struct flow **flows);
6161
const char *fmt_flows_step_scid(const tal_t *ctx,
6262
const struct route_query *rq,
6363
const struct flow *flow, size_t i);
64+
65+
/* When we need to debug */
66+
const char *fmt_flow_full(const tal_t *ctx,
67+
const struct route_query *rq,
68+
const struct flow *flow);
6469
#endif /* LIGHTNING_PLUGINS_ASKRENE_FLOW_H */

0 commit comments

Comments
 (0)