Skip to content

Commit 080a4dd

Browse files
ShahanaFarooquirustyrussell
authored andcommitted
commando: save runes as we generate them
In preparation for the listrunes command.
1 parent 415b7d5 commit 080a4dd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

plugins/commando.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,19 @@ static struct command_result *reply_with_rune(struct command *cmd,
925925
return command_finished(cmd, js);
926926
}
927927

928+
static struct command_result *save_rune(struct command *cmd,
929+
const char *buf UNUSED,
930+
const jsmntok_t *result UNUSED,
931+
struct rune *rune)
932+
{
933+
const char *path = tal_fmt(cmd, "commando/runes/%s", rune->unique_id);
934+
return jsonrpc_set_datastore_string(plugin, cmd, path,
935+
rune_to_base64(tmpctx, rune),
936+
"must-create", reply_with_rune,
937+
forward_error, rune);
938+
}
939+
940+
928941
static struct command_result *json_commando_rune(struct command *cmd,
929942
const char *buffer,
930943
const jsmntok_t *params)
@@ -953,7 +966,7 @@ static struct command_result *json_commando_rune(struct command *cmd,
953966

954967
/* Now update datastore, before returning rune */
955968
req = jsonrpc_request_start(plugin, cmd, "datastore",
956-
reply_with_rune, forward_error, rune);
969+
save_rune, forward_error, rune);
957970
json_array_start(req->js, "key");
958971
json_add_string(req->js, NULL, "commando");
959972
json_add_string(req->js, NULL, "rune_counter");

0 commit comments

Comments
 (0)