| 53 | } |
| 54 | |
| 55 | static 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 */ |
| 98 | static void json_add_route_hop(struct json_stream *js, |
nothing calls this directly
no test coverage detected