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

Function json_add_layer

plugins/askrene/layer.c:1252–1313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1250}
1251
1252static void json_add_layer(struct json_stream *js,
1253 const char *fieldname,
1254 const struct layer *layer)
1255{
1256 struct local_channel_hash_iter lcit;
1257 const struct local_channel *lc;
1258 const struct local_update *lu;
1259 struct local_update_hash_iter luit;
1260 struct constraint_hash_iter conit;
1261 const struct constraint *c;
1262 struct bias_hash_iter biasit;
1263 const struct bias *b;
1264 struct node_bias_hash_iter node_it;
1265 const struct node_bias *node_bias;
1266
1267 json_object_start(js, fieldname);
1268 json_add_string(js, "layer", layer->name);
1269 json_add_bool(js, "persistent", layer->persistent);
1270 json_array_start(js, "disabled_nodes");
1271 for (size_t i = 0; i < tal_count(layer->disabled_nodes); i++)
1272 json_add_node_id(js, NULL, &layer->disabled_nodes[i]);
1273 json_array_end(js);
1274 json_array_start(js, "created_channels");
1275 for (lc = local_channel_hash_first(layer->local_channels, &lcit);
1276 lc;
1277 lc = local_channel_hash_next(layer->local_channels, &lcit)) {
1278 json_add_local_channel(js, NULL, lc);
1279 }
1280 json_array_end(js);
1281 json_array_start(js, "channel_updates");
1282 for (lu = local_update_hash_first(layer->local_updates, &luit);
1283 lu;
1284 lu = local_update_hash_next(layer->local_updates, &luit)) {
1285 json_add_local_update(js, NULL, lu);
1286 }
1287 json_array_end(js);
1288 json_array_start(js, "constraints");
1289 for (c = constraint_hash_first(layer->constraints, &conit);
1290 c;
1291 c = constraint_hash_next(layer->constraints, &conit)) {
1292 /* Don't show ones we generated internally */
1293 if (c->timestamp == UINT64_MAX)
1294 continue;
1295 json_add_constraint(js, NULL, c, NULL);
1296 }
1297 json_array_end(js);
1298 json_array_start(js, "biases");
1299 for (b = bias_hash_first(layer->biases, &biasit);
1300 b;
1301 b = bias_hash_next(layer->biases, &biasit)) {
1302 json_add_bias(js, NULL, b, NULL);
1303 }
1304 json_array_end(js);
1305 json_array_start(js, "node_biases");
1306 for (node_bias = node_bias_hash_first(layer->node_biases, &node_it);
1307 node_bias;
1308 node_bias = node_bias_hash_next(layer->node_biases, &node_it)) {
1309 json_add_node_bias(js, NULL, node_bias, NULL);

Callers 1

json_add_layersFunction · 0.85

Calls 12

json_object_startFunction · 0.85
json_add_boolFunction · 0.85
json_array_startFunction · 0.85
json_add_node_idFunction · 0.85
json_array_endFunction · 0.85
json_add_local_channelFunction · 0.85
json_add_local_updateFunction · 0.85
json_add_constraintFunction · 0.85
json_add_biasFunction · 0.85
json_add_node_biasFunction · 0.85
json_object_endFunction · 0.85
json_add_stringFunction · 0.50

Tested by

no test coverage detected