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

Function json_listnodes

plugins/topology.c:499–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499static struct command_result *json_listnodes(struct command *cmd,
500 const char *buffer,
501 const jsmntok_t *params)
502{
503 struct node_id *id;
504 struct json_stream *js;
505 struct gossmap *gossmap;
506
507 if (!param(cmd, buffer, params,
508 p_opt("id", param_node_id, &id),
509 NULL))
510 return command_param_failed();
511
512 gossmap = get_gossmap();
513 js = jsonrpc_stream_success(cmd);
514 json_array_start(js, "nodes");
515 if (id) {
516 struct gossmap_node *n = gossmap_find_node(gossmap, id);
517 if (n)
518 json_add_node(js, gossmap, n);
519 } else {
520 for (struct gossmap_node *n = gossmap_first_node(gossmap);
521 n;
522 n = gossmap_next_node(gossmap, n)) {
523 json_add_node(js, gossmap, n);
524 }
525 }
526 json_array_end(js);
527
528 return command_finished(cmd, js);
529}
530
531/* What is capacity of peer attached to chan #n? */
532static struct amount_msat peer_capacity(const struct gossmap *gossmap,

Callers

nothing calls this directly

Calls 11

gossmap_find_nodeFunction · 0.85
json_add_nodeFunction · 0.85
gossmap_first_nodeFunction · 0.85
gossmap_next_nodeFunction · 0.85
command_param_failedFunction · 0.70
get_gossmapFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
paramFunction · 0.50
json_array_startFunction · 0.50
json_array_endFunction · 0.50

Tested by

no test coverage detected