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

Function json_listnodes

plugins/topology.c:408–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406}
407
408static struct command_result *json_listnodes(struct command *cmd,
409 const char *buffer,
410 const jsmntok_t *params)
411{
412 struct node_id *id;
413 struct json_stream *js;
414 struct gossmap *gossmap;
415
416 if (!param(cmd, buffer, params,
417 p_opt("id", param_node_id, &id),
418 NULL))
419 return command_param_failed();
420
421 gossmap = get_gossmap();
422 js = jsonrpc_stream_success(cmd);
423 json_array_start(js, "nodes");
424 if (id) {
425 struct gossmap_node *n = gossmap_find_node(gossmap, id);
426 if (n)
427 json_add_node(js, gossmap, n);
428 } else {
429 for (struct gossmap_node *n = gossmap_first_node(gossmap);
430 n;
431 n = gossmap_next_node(gossmap, n)) {
432 json_add_node(js, gossmap, n);
433 }
434 }
435 json_array_end(js);
436
437 return command_finished(cmd, js);
438}
439
440/* What is capacity of peer attached to chan #n? */
441static struct amount_msat peer_capacity(const struct gossmap *gossmap,

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected