| 1938 | } |
| 1939 | |
| 1940 | static 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 | |
| 1971 | static const struct json_command listpeers_command = { |
| 1972 | "listpeers", |
nothing calls this directly
no test coverage detected