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

Function json_listpeers

lightningd/peer_control.c:2895–2929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2893}
2894
2895static struct command_result *json_listpeers(struct command *cmd,
2896 const char *buffer,
2897 const jsmntok_t *obj UNNEEDED,
2898 const jsmntok_t *params)
2899{
2900 enum log_level *ll;
2901 struct node_id *specific_id;
2902 struct peer *peer;
2903 struct json_stream *response;
2904
2905 if (!param(cmd, buffer, params,
2906 p_opt("id", param_node_id, &specific_id),
2907 p_opt("level", param_loglevel, &ll),
2908 NULL))
2909 return command_param_failed();
2910
2911 response = json_stream_success(cmd);
2912 json_array_start(response, "peers");
2913 if (specific_id) {
2914 peer = peer_by_id(cmd->ld, specific_id);
2915 if (peer)
2916 json_add_peer(cmd->ld, response, peer, ll);
2917 } else {
2918 struct peer_node_id_map_iter it;
2919
2920 for (peer = peer_node_id_map_first(cmd->ld->peers, &it);
2921 peer;
2922 peer = peer_node_id_map_next(cmd->ld->peers, &it)) {
2923 json_add_peer(cmd->ld, response, peer, ll);
2924 }
2925 }
2926 json_array_end(response);
2927
2928 return command_success(cmd, response);
2929}
2930
2931static const struct json_command listpeers_command = {
2932 "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