| 1106 | } |
| 1107 | |
| 1108 | void layer_add_localmods(const struct layer *layer, |
| 1109 | const struct gossmap *gossmap, |
| 1110 | struct gossmap_localmods *localmods) |
| 1111 | { |
| 1112 | const struct local_channel *lc; |
| 1113 | struct local_channel_hash_iter lcit; |
| 1114 | const struct local_update *lu; |
| 1115 | struct local_update_hash_iter luit; |
| 1116 | |
| 1117 | /* First, disable all channels into blocked nodes (local updates |
| 1118 | * can add new ones)! */ |
| 1119 | for (size_t i = 0; i < tal_count(layer->disabled_nodes); i++) { |
| 1120 | const struct gossmap_node *node; |
| 1121 | |
| 1122 | node = gossmap_find_node(gossmap, &layer->disabled_nodes[i]); |
| 1123 | if (!node) |
| 1124 | continue; |
| 1125 | for (size_t n = 0; n < node->num_chans; n++) { |
| 1126 | struct short_channel_id_dir scidd; |
| 1127 | struct gossmap_chan *c; |
| 1128 | bool enabled = false; |
| 1129 | c = gossmap_nth_chan(gossmap, node, n, &scidd.dir); |
| 1130 | scidd.scid = gossmap_chan_scid(gossmap, c); |
| 1131 | |
| 1132 | /* Disabled zero-capacity on incoming */ |
| 1133 | gossmap_local_updatechan(localmods, |
| 1134 | &scidd, |
| 1135 | &enabled, |
| 1136 | NULL, NULL, NULL, NULL, NULL); |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | /* Now create new channels */ |
| 1141 | for (lc = local_channel_hash_first(layer->local_channels, &lcit); |
| 1142 | lc; |
| 1143 | lc = local_channel_hash_next(layer->local_channels, &lcit)) { |
| 1144 | gossmap_local_addchan(localmods, |
| 1145 | &lc->n1, &lc->n2, lc->scid, lc->capacity, |
| 1146 | NULL); |
| 1147 | } |
| 1148 | |
| 1149 | /* Now update channels */ |
| 1150 | /* Now modify channels, if they exist */ |
| 1151 | for (lu = local_update_hash_first(layer->local_updates, &luit); |
| 1152 | lu; |
| 1153 | lu = local_update_hash_next(layer->local_updates, &luit)) { |
| 1154 | gossmap_local_updatechan(localmods, &lu->scidd, |
| 1155 | lu->enabled, |
| 1156 | lu->htlc_min, |
| 1157 | lu->htlc_max, |
| 1158 | lu->base_fee, |
| 1159 | lu->proportional_fee, |
| 1160 | lu->delay); |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | static void json_add_local_channel(struct json_stream *response, |
| 1165 | const char *fieldname, |
no test coverage detected