MCPcopy Create free account
hub / github.com/ElementsProject/lightning / flow_adjust_htlcmax_constraints

Function flow_adjust_htlcmax_constraints

plugins/renepay/routebuilder.c:18–58  ·  view source on GitHub ↗

Shave-off amounts that do not meet the liquidity constraints. Disable * channels that produce an htlc_max bottleneck. */

Source from the content-addressed store, hash-verified

16/* Shave-off amounts that do not meet the liquidity constraints. Disable
17 * channels that produce an htlc_max bottleneck. */
18static enum renepay_errorcode
19flow_adjust_htlcmax_constraints(struct flow *flow, struct gossmap *gossmap,
20 struct chan_extra_map *chan_extra_map,
21 bitmap *disabled_bitmap)
22{
23 assert(flow);
24 assert(gossmap);
25 assert(chan_extra_map);
26 assert(disabled_bitmap);
27 assert(!amount_msat_is_zero(flow_delivers(flow)));
28
29 enum renepay_errorcode errorcode;
30
31 struct amount_msat max_deliverable;
32 const struct gossmap_chan *bad_channel;
33
34 errorcode = flow_maximum_deliverable(&max_deliverable, flow, gossmap,
35 chan_extra_map, &bad_channel);
36
37 if (!errorcode) {
38 assert(!amount_msat_is_zero(max_deliverable));
39
40 // no issues
41 flow->amount =
42 amount_msat_min(flow_delivers(flow), max_deliverable);
43
44 return errorcode;
45 }
46
47 if (errorcode == RENEPAY_BAD_CHANNEL) {
48 // this is a channel that we can disable
49 // FIXME: log this error? disabling both directions?
50 bitmap_set_bit(disabled_bitmap,
51 gossmap_chan_idx(gossmap, bad_channel) * 2 + 0);
52 bitmap_set_bit(disabled_bitmap,
53 gossmap_chan_idx(gossmap, bad_channel) * 2 + 1);
54 }
55
56 // we had an unexpected error
57 return errorcode;
58}
59
60static enum renepay_errorcode
61route_check_constraints(struct route *route, struct gossmap *gossmap,

Callers 1

get_routesFunction · 0.85

Calls 6

amount_msat_is_zeroFunction · 0.85
flow_deliversFunction · 0.85
flow_maximum_deliverableFunction · 0.85
amount_msat_minFunction · 0.85
bitmap_set_bitFunction · 0.85
gossmap_chan_idxFunction · 0.85

Tested by

no test coverage detected