We're going to abuse MCF, and take the largest flow it gives and ram everything * through it. This is more effective if there's at least a *chance* that can handle * the full amount. * * It's far from perfect, but I have very little sympathy: if you want * to receive amounts reliably, enable MPP. */
| 265 | * to receive amounts reliably, enable MPP. |
| 266 | */ |
| 267 | static struct layer *remove_small_channel_layer(const tal_t *ctx, |
| 268 | struct askrene *askrene, |
| 269 | struct amount_msat min_amount, |
| 270 | struct gossmap_localmods *localmods) |
| 271 | { |
| 272 | /* We use the prefix auto. to avoid clashing */ |
| 273 | struct layer *layer = new_temp_layer(ctx, askrene, "auto.remove_small_channels"); |
| 274 | struct gossmap *gossmap = askrene->gossmap; |
| 275 | struct gossmap_chan *c; |
| 276 | |
| 277 | /* We apply this so we see any created channels */ |
| 278 | gossmap_apply_localmods(gossmap, localmods); |
| 279 | |
| 280 | for (c = gossmap_first_chan(gossmap); c; c = gossmap_next_chan(gossmap, c)) { |
| 281 | struct short_channel_id_dir scidd; |
| 282 | if (amount_msat_greater_eq(gossmap_chan_get_capacity(gossmap, c), |
| 283 | min_amount)) |
| 284 | continue; |
| 285 | |
| 286 | scidd.scid = gossmap_chan_scid(gossmap, c); |
| 287 | /* Layer will disable this in both directions */ |
| 288 | for (scidd.dir = 0; scidd.dir < 2; scidd.dir++) { |
| 289 | const bool enabled = false; |
| 290 | layer_add_update_channel(layer, &scidd, &enabled, |
| 291 | NULL, NULL, NULL, NULL, NULL); |
| 292 | } |
| 293 | } |
| 294 | gossmap_remove_localmods(gossmap, localmods); |
| 295 | |
| 296 | return layer; |
| 297 | } |
| 298 | |
| 299 | PRINTF_FMT(4, 5) |
| 300 | static const char *cmd_log(const tal_t *ctx, |
no test coverage detected