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

Function can_carry

plugins/topology.c:55–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55static bool can_carry(const struct gossmap *map,
56 const struct gossmap_chan *c,
57 int dir,
58 struct amount_msat amount,
59 struct route_exclusion **excludes)
60{
61 struct node_id dstid;
62
63 /* First do generic check */
64 if (!route_can_carry(map, c, dir, amount, NULL)) {
65 return false;
66 }
67
68 /* Now check exclusions. Premature optimization: */
69 if (!tal_count(excludes)) {
70 return true;
71 }
72
73 gossmap_node_get_id(map, gossmap_nth_node(map, c, !dir), &dstid);
74 for (size_t i = 0; i < tal_count(excludes); i++) {
75 struct short_channel_id scid;
76
77 switch (excludes[i]->type) {
78 case EXCLUDE_CHANNEL:
79 scid = gossmap_chan_scid(map, c);
80 if (short_channel_id_eq(&excludes[i]->u.chan_id.scid, &scid)
81 && dir == excludes[i]->u.chan_id.dir)
82 return false;
83 continue;
84
85 case EXCLUDE_NODE:
86 if (node_id_eq(&dstid, &excludes[i]->u.node_id))
87 return false;
88 continue;
89 }
90 /* No other cases should be possible! */
91 plugin_err(plugin, "Invalid type %i in exclusion[%zu]",
92 excludes[i]->type, i);
93 }
94 return true;
95}
96
97/* Output a route hop */
98static void json_add_route_hop(struct json_stream *js,

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected