| 27 | } |
| 28 | |
| 29 | static 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 */ |
| 72 | static void json_add_route_hop(struct json_stream *js, |
nothing calls this directly
no test coverage detected