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

Function remove_small_channel_layer

plugins/askrene/askrene.c:316–346  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

314 * to receive amounts reliably, enable MPP.
315 */
316static struct layer *remove_small_channel_layer(const tal_t *ctx,
317 struct askrene *askrene,
318 struct amount_msat min_amount,
319 struct gossmap_localmods *localmods)
320{
321 /* We use the prefix auto. to avoid clashing */
322 struct layer *layer = new_temp_layer(ctx, askrene, "auto.remove_small_channels");
323 struct gossmap *gossmap = askrene->gossmap;
324 struct gossmap_chan *c;
325
326 /* We apply this so we see any created channels */
327 gossmap_apply_localmods(gossmap, localmods);
328
329 for (c = gossmap_first_chan(gossmap); c; c = gossmap_next_chan(gossmap, c)) {
330 struct short_channel_id_dir scidd;
331 if (amount_msat_greater_eq(gossmap_chan_get_capacity(gossmap, c),
332 min_amount))
333 continue;
334
335 scidd.scid = gossmap_chan_scid(gossmap, c);
336 /* Layer will disable this in both directions */
337 for (scidd.dir = 0; scidd.dir < 2; scidd.dir++) {
338 const bool enabled = false;
339 layer_add_update_channel(layer, &scidd, &enabled,
340 NULL, NULL, NULL, NULL, NULL);
341 }
342 }
343 gossmap_remove_localmods(gossmap, localmods);
344
345 return layer;
346}
347
348PRINTF_FMT(4, 5)
349static const char *cmd_log(const tal_t *ctx,

Callers 1

do_getroutesFunction · 0.85

Calls 9

new_temp_layerFunction · 0.85
gossmap_apply_localmodsFunction · 0.85
gossmap_first_chanFunction · 0.85
gossmap_next_chanFunction · 0.85
amount_msat_greater_eqFunction · 0.85
gossmap_chan_scidFunction · 0.85
layer_add_update_channelFunction · 0.85
gossmap_remove_localmodsFunction · 0.85

Tested by

no test coverage detected