| 88 | } |
| 89 | |
| 90 | bitmap *tal_disabledmap_get_bitmap(const tal_t *ctx, struct disabledmap *p, |
| 91 | const struct gossmap *gossmap) |
| 92 | { |
| 93 | bitmap *disabled = tal_arrz( |
| 94 | ctx, bitmap, 2 * BITMAP_NWORDS(gossmap_max_chan_idx(gossmap))); |
| 95 | if (!disabled) |
| 96 | return NULL; |
| 97 | |
| 98 | /* Disable every channel in the list of disabled scids. */ |
| 99 | struct scidd_map_iter it; |
| 100 | for(struct short_channel_id_dir *scidd = scidd_map_first(p->disabled_map,&it); |
| 101 | scidd; |
| 102 | scidd = scidd_map_next(p->disabled_map, &it)){ |
| 103 | |
| 104 | struct gossmap_chan *c = |
| 105 | gossmap_find_chan(gossmap, &scidd->scid); |
| 106 | if (c) |
| 107 | bitmap_set_bit(disabled, |
| 108 | gossmap_chan_idx(gossmap, c) * 2 + |
| 109 | scidd->dir); |
| 110 | } |
| 111 | |
| 112 | /* Disable all channels that lead to a disabled node. */ |
| 113 | for (size_t i = 0; i < tal_count(p->disabled_nodes); i++) { |
| 114 | const struct gossmap_node *node = |
| 115 | gossmap_find_node(gossmap, &p->disabled_nodes[i]); |
| 116 | |
| 117 | for (size_t j = 0; j < node->num_chans; j++) { |
| 118 | int half; |
| 119 | const struct gossmap_chan *c = |
| 120 | gossmap_nth_chan(gossmap, node, j, &half); |
| 121 | bitmap_set_bit(disabled, |
| 122 | gossmap_chan_idx(gossmap, c) * 2 + half); |
| 123 | } |
| 124 | } |
| 125 | return disabled; |
| 126 | } |
no test coverage detected