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

Function json_listpeers

lightningd/peer_control.c:2621–2655  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2619}
2620
2621static struct command_result *json_listpeers(struct command *cmd,
2622 const char *buffer,
2623 const jsmntok_t *obj UNNEEDED,
2624 const jsmntok_t *params)
2625{
2626 enum log_level *ll;
2627 struct node_id *specific_id;
2628 struct peer *peer;
2629 struct json_stream *response;
2630
2631 if (!param(cmd, buffer, params,
2632 p_opt("id", param_node_id, &specific_id),
2633 p_opt("level", param_loglevel, &ll),
2634 NULL))
2635 return command_param_failed();
2636
2637 response = json_stream_success(cmd);
2638 json_array_start(response, "peers");
2639 if (specific_id) {
2640 peer = peer_by_id(cmd->ld, specific_id);
2641 if (peer)
2642 json_add_peer(cmd->ld, response, peer, ll);
2643 } else {
2644 struct peer_node_id_map_iter it;
2645
2646 for (peer = peer_node_id_map_first(cmd->ld->peers, &it);
2647 peer;
2648 peer = peer_node_id_map_next(cmd->ld->peers, &it)) {
2649 json_add_peer(cmd->ld, response, peer, ll);
2650 }
2651 }
2652 json_array_end(response);
2653
2654 return command_success(cmd, response);
2655}
2656
2657static const struct json_command listpeers_command = {
2658 "listpeers",

Callers

nothing calls this directly

Calls 8

json_array_startFunction · 0.85
peer_by_idFunction · 0.85
json_add_peerFunction · 0.85
json_array_endFunction · 0.85
command_param_failedFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected