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

Function json_add_layer

plugins/askrene/layer.c:1281–1342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1279}
1280
1281static void json_add_layer(struct json_stream *js,
1282 const char *fieldname,
1283 const struct layer *layer)
1284{
1285 struct local_channel_hash_iter lcit;
1286 const struct local_channel *lc;
1287 const struct local_update *lu;
1288 struct local_update_hash_iter luit;
1289 struct constraint_hash_iter conit;
1290 const struct constraint *c;
1291 struct bias_hash_iter biasit;
1292 const struct bias *b;
1293 struct node_bias_hash_iter node_it;
1294 const struct node_bias *node_bias;
1295
1296 json_object_start(js, fieldname);
1297 json_add_string(js, "layer", layer->name);
1298 json_add_bool(js, "persistent", layer->persistent);
1299 json_array_start(js, "disabled_nodes");
1300 for (size_t i = 0; i < tal_count(layer->disabled_nodes); i++)
1301 json_add_node_id(js, NULL, &layer->disabled_nodes[i]);
1302 json_array_end(js);
1303 json_array_start(js, "created_channels");
1304 for (lc = local_channel_hash_first(layer->local_channels, &lcit);
1305 lc;
1306 lc = local_channel_hash_next(layer->local_channels, &lcit)) {
1307 json_add_local_channel(js, NULL, lc);
1308 }
1309 json_array_end(js);
1310 json_array_start(js, "channel_updates");
1311 for (lu = local_update_hash_first(layer->local_updates, &luit);
1312 lu;
1313 lu = local_update_hash_next(layer->local_updates, &luit)) {
1314 json_add_local_update(js, NULL, lu);
1315 }
1316 json_array_end(js);
1317 json_array_start(js, "constraints");
1318 for (c = constraint_hash_first(layer->constraints, &conit);
1319 c;
1320 c = constraint_hash_next(layer->constraints, &conit)) {
1321 /* Don't show ones we generated internally */
1322 if (c->timestamp == UINT64_MAX)
1323 continue;
1324 json_add_constraint(js, NULL, c, NULL);
1325 }
1326 json_array_end(js);
1327 json_array_start(js, "biases");
1328 for (b = bias_hash_first(layer->biases, &biasit);
1329 b;
1330 b = bias_hash_next(layer->biases, &biasit)) {
1331 json_add_bias(js, NULL, b, NULL);
1332 }
1333 json_array_end(js);
1334 json_array_start(js, "node_biases");
1335 for (node_bias = node_bias_hash_first(layer->node_biases, &node_it);
1336 node_bias;
1337 node_bias = node_bias_hash_next(layer->node_biases, &node_it)) {
1338 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