| 3278 | AUTODATA(json_command, &disconnect_command); |
| 3279 | |
| 3280 | static struct command_result *json_getinfo(struct command *cmd, |
| 3281 | const char *buffer, |
| 3282 | const jsmntok_t *obj UNNEEDED, |
| 3283 | const jsmntok_t *params) |
| 3284 | { |
| 3285 | struct json_stream *response; |
| 3286 | struct peer *peer; |
| 3287 | struct channel *channel; |
| 3288 | unsigned int pending_channels = 0, active_channels = 0, |
| 3289 | inactive_channels = 0, num_peers = 0; |
| 3290 | size_t count_announceable; |
| 3291 | struct peer_node_id_map_iter it; |
| 3292 | |
| 3293 | if (!param(cmd, buffer, params, NULL)) |
| 3294 | return command_param_failed(); |
| 3295 | |
| 3296 | response = json_stream_success(cmd); |
| 3297 | json_add_node_id(response, "id", &cmd->ld->our_nodeid); |
| 3298 | json_add_string(response, "alias", (const char *)cmd->ld->alias); |
| 3299 | json_add_hex_talarr(response, "color", cmd->ld->rgb); |
| 3300 | |
| 3301 | /* Add some peer and channel stats */ |
| 3302 | for (peer = peer_node_id_map_first(cmd->ld->peers, &it); |
| 3303 | peer; |
| 3304 | peer = peer_node_id_map_next(cmd->ld->peers, &it)) { |
| 3305 | num_peers++; |
| 3306 | |
| 3307 | list_for_each(&peer->channels, channel, list) { |
| 3308 | switch (channel->state) { |
| 3309 | case CHANNELD_AWAITING_LOCKIN: |
| 3310 | case DUALOPEND_OPEN_INIT: |
| 3311 | case DUALOPEND_OPEN_COMMIT_READY: |
| 3312 | case DUALOPEND_OPEN_COMMITTED: |
| 3313 | case DUALOPEND_AWAITING_LOCKIN: |
| 3314 | pending_channels++; |
| 3315 | continue; |
| 3316 | case CHANNELD_AWAITING_SPLICE: |
| 3317 | case CHANNELD_SHUTTING_DOWN: |
| 3318 | case CHANNELD_NORMAL: |
| 3319 | case CLOSINGD_SIGEXCHANGE: |
| 3320 | active_channels++; |
| 3321 | continue; |
| 3322 | case CLOSINGD_COMPLETE: |
| 3323 | case AWAITING_UNILATERAL: |
| 3324 | case FUNDING_SPEND_SEEN: |
| 3325 | case ONCHAIN: |
| 3326 | case CLOSED: |
| 3327 | inactive_channels++; |
| 3328 | continue; |
| 3329 | } |
| 3330 | abort(); |
| 3331 | } |
| 3332 | } |
| 3333 | json_add_num(response, "num_peers", num_peers); |
| 3334 | json_add_num(response, "num_pending_channels", pending_channels); |
| 3335 | json_add_num(response, "num_active_channels", active_channels); |
| 3336 | json_add_num(response, "num_inactive_channels", inactive_channels); |
| 3337 |
nothing calls this directly
no test coverage detected