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

Function json_listpeers

lightningd/peer_control.c:1940–1969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1938}
1939
1940static struct command_result *json_listpeers(struct command *cmd,
1941 const char *buffer,
1942 const jsmntok_t *obj UNNEEDED,
1943 const jsmntok_t *params)
1944{
1945 enum log_level *ll;
1946 struct node_id *specific_id;
1947 struct peer *peer;
1948 struct json_stream *response;
1949
1950 if (!param(cmd, buffer, params,
1951 p_opt("id", param_node_id, &specific_id),
1952 p_opt("level", param_loglevel, &ll),
1953 NULL))
1954 return command_param_failed();
1955
1956 response = json_stream_success(cmd);
1957 json_array_start(response, "peers");
1958 if (specific_id) {
1959 peer = peer_by_id(cmd->ld, specific_id);
1960 if (peer)
1961 json_add_peer(cmd->ld, response, peer, ll);
1962 } else {
1963 list_for_each(&cmd->ld->peers, peer, list)
1964 json_add_peer(cmd->ld, response, peer, ll);
1965 }
1966 json_array_end(response);
1967
1968 return command_success(cmd, response);
1969}
1970
1971static const struct json_command listpeers_command = {
1972 "listpeers",

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected