From 17c35819d84a0c0984c048777298dcb3d6d93565 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 4 Feb 2023 16:22:29 +1030 Subject: [PATCH] plugins/chanbackup: neaten a little. node_id can be on the stack, avoiding a tal call. Signed-off-by: Rusty Russell --- plugins/chanbackup.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/chanbackup.c b/plugins/chanbackup.c index 3cf736f87..79a758dd7 100644 --- a/plugins/chanbackup.c +++ b/plugins/chanbackup.c @@ -425,11 +425,10 @@ static struct command_result *after_listpeers(struct command *cmd, const jsmntok_t *params, void *cb_arg UNUSED) { - const jsmntok_t *peers, *peer, *nodeid; + const jsmntok_t *peers, *peer; struct out_req *req; size_t i; struct info *info = tal(cmd, struct info); - struct node_id *node_id = tal(cmd, struct node_id); bool is_connected; u8 *scb = get_file_data(cmd->plugin); @@ -444,8 +443,11 @@ static struct command_result *after_listpeers(struct command *cmd, &is_connected); if (is_connected) { + const jsmntok_t *nodeid; + struct node_id node_id; + nodeid = json_get_member(buf, peer, "id"); - json_to_node_id(buf, nodeid, node_id); + json_to_node_id(buf, nodeid, &node_id); req = jsonrpc_request_start(cmd->plugin, cmd, @@ -454,7 +456,7 @@ static struct command_result *after_listpeers(struct command *cmd, after_send_scb_single_fail, info); - json_add_node_id(req->js, "node_id", node_id); + json_add_node_id(req->js, "node_id", &node_id); json_add_hex(req->js, "msg", serialise_scb, tal_bytelen(serialise_scb)); info->idx++;