Shave-off amounts that do not meet the liquidity constraints. Disable * channels that produce an htlc_max bottleneck. */
| 16 | /* Shave-off amounts that do not meet the liquidity constraints. Disable |
| 17 | * channels that produce an htlc_max bottleneck. */ |
| 18 | static enum renepay_errorcode |
| 19 | flow_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 | |
| 60 | static enum renepay_errorcode |
| 61 | route_check_constraints(struct route *route, struct gossmap *gossmap, |
no test coverage detected