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

Function layer_add_localmods

plugins/askrene/layer.c:1137–1191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1135}
1136
1137void layer_add_localmods(const struct layer *layer,
1138 const struct gossmap *gossmap,
1139 struct gossmap_localmods *localmods)
1140{
1141 const struct local_channel *lc;
1142 struct local_channel_hash_iter lcit;
1143 const struct local_update *lu;
1144 struct local_update_hash_iter luit;
1145
1146 /* First, disable all channels into blocked nodes (local updates
1147 * can add new ones)! */
1148 for (size_t i = 0; i < tal_count(layer->disabled_nodes); i++) {
1149 const struct gossmap_node *node;
1150
1151 node = gossmap_find_node(gossmap, &layer->disabled_nodes[i]);
1152 if (!node)
1153 continue;
1154 for (size_t n = 0; n < node->num_chans; n++) {
1155 struct short_channel_id_dir scidd;
1156 struct gossmap_chan *c;
1157 bool enabled = false;
1158 c = gossmap_nth_chan(gossmap, node, n, &scidd.dir);
1159 scidd.scid = gossmap_chan_scid(gossmap, c);
1160
1161 /* Disabled zero-capacity on incoming */
1162 gossmap_local_updatechan(localmods,
1163 &scidd,
1164 &enabled,
1165 NULL, NULL, NULL, NULL, NULL);
1166 }
1167 }
1168
1169 /* Now create new channels */
1170 for (lc = local_channel_hash_first(layer->local_channels, &lcit);
1171 lc;
1172 lc = local_channel_hash_next(layer->local_channels, &lcit)) {
1173 gossmap_local_addchan(localmods,
1174 &lc->n1, &lc->n2, lc->scid, lc->capacity,
1175 NULL);
1176 }
1177
1178 /* Now update channels */
1179 /* Now modify channels, if they exist */
1180 for (lu = local_update_hash_first(layer->local_updates, &luit);
1181 lu;
1182 lu = local_update_hash_next(layer->local_updates, &luit)) {
1183 gossmap_local_updatechan(localmods, &lu->scidd,
1184 lu->enabled,
1185 lu->htlc_min,
1186 lu->htlc_max,
1187 lu->base_fee,
1188 lu->proportional_fee,
1189 lu->delay);
1190 }
1191}
1192
1193static void json_add_local_channel(struct json_stream *response,
1194 const char *fieldname,

Callers 1

add_layerFunction · 0.85

Calls 5

gossmap_find_nodeFunction · 0.85
gossmap_nth_chanFunction · 0.85
gossmap_chan_scidFunction · 0.85
gossmap_local_updatechanFunction · 0.85
gossmap_local_addchanFunction · 0.85

Tested by

no test coverage detected