| 2897 | } |
| 2898 | |
| 2899 | static struct command_result *json_dev_quiesce(struct command *cmd, |
| 2900 | const char *buffer, |
| 2901 | const jsmntok_t *obj UNNEEDED, |
| 2902 | const jsmntok_t *params) |
| 2903 | { |
| 2904 | struct node_id *id; |
| 2905 | struct peer *peer; |
| 2906 | struct channel *channel; |
| 2907 | const u8 *msg; |
| 2908 | bool more_than_one; |
| 2909 | |
| 2910 | if (!param_check(cmd, buffer, params, |
| 2911 | p_req("id", param_node_id, &id), |
| 2912 | NULL)) |
| 2913 | return command_param_failed(); |
| 2914 | |
| 2915 | peer = peer_by_id(cmd->ld, id); |
| 2916 | if (!peer) |
| 2917 | return command_fail(cmd, LIGHTNINGD, "Peer not connected"); |
| 2918 | |
| 2919 | /* FIXME: If this becomes a real API, check for OPT_QUIESCE! */ |
| 2920 | channel = peer_any_channel_bystate(peer, channel_state_wants_peercomms, |
| 2921 | &more_than_one); |
| 2922 | if (!channel || !channel->owner) |
| 2923 | return command_fail(cmd, LIGHTNINGD, "Peer bad state"); |
| 2924 | /* This is a dev command: fix the api if you need this! */ |
| 2925 | if (more_than_one) |
| 2926 | return command_fail(cmd, LIGHTNINGD, "More than one channel"); |
| 2927 | |
| 2928 | if (command_check_only(cmd)) |
| 2929 | return command_check_done(cmd); |
| 2930 | |
| 2931 | msg = towire_channeld_dev_quiesce(NULL); |
| 2932 | subd_req(channel->owner, channel->owner, take(msg), -1, 0, |
| 2933 | quiesce_reply, cmd); |
| 2934 | return command_still_pending(cmd); |
| 2935 | } |
| 2936 | |
| 2937 | static const struct json_command dev_quiesce_command = { |
| 2938 | "dev-quiesce", |
nothing calls this directly
no test coverage detected