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

Function remove_small_channel_layer

plugins/askrene/askrene.c:267–297  ·  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

265 * to receive amounts reliably, enable MPP.
266 */
267static 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
299PRINTF_FMT(4, 5)
300static 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