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

Function can_carry

plugins/topology.c:29–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29static bool can_carry(const struct gossmap *map,
30 const struct gossmap_chan *c,
31 int dir,
32 struct amount_msat amount,
33 struct route_exclusion **excludes)
34{
35 struct node_id dstid;
36
37 /* First do generic check */
38 if (!route_can_carry(map, c, dir, amount, NULL)) {
39 return false;
40 }
41
42 /* Now check exclusions. Premature optimization: */
43 if (!tal_count(excludes)) {
44 return true;
45 }
46
47 gossmap_node_get_id(map, gossmap_nth_node(map, c, !dir), &dstid);
48 for (size_t i = 0; i < tal_count(excludes); i++) {
49 struct short_channel_id scid;
50
51 switch (excludes[i]->type) {
52 case EXCLUDE_CHANNEL:
53 scid = gossmap_chan_scid(map, c);
54 if (short_channel_id_eq(excludes[i]->u.chan_id.scid, scid)
55 && dir == excludes[i]->u.chan_id.dir)
56 return false;
57 continue;
58
59 case EXCLUDE_NODE:
60 if (node_id_eq(&dstid, &excludes[i]->u.node_id))
61 return false;
62 continue;
63 }
64 /* No other cases should be possible! */
65 plugin_err(plugin, "Invalid type %i in exclusion[%zu]",
66 excludes[i]->type, i);
67 }
68 return true;
69}
70
71/* Output a route hop */
72static void json_add_route_hop(struct json_stream *js,

Callers

nothing calls this directly

Calls 7

route_can_carryFunction · 0.85
gossmap_node_get_idFunction · 0.85
gossmap_nth_nodeFunction · 0.85
gossmap_chan_scidFunction · 0.85
short_channel_id_eqFunction · 0.85
node_id_eqFunction · 0.85
plugin_errFunction · 0.70

Tested by

no test coverage detected