mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
libplugin: allow NULL calllbacks for jsonrpc_set_datastore.
You often don't care about the reply, so this is quite convenient. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
fb433a70f8
commit
b3b5b74069
2 changed files with 18 additions and 1 deletions
|
@ -617,6 +617,16 @@ bool rpc_scan_datastore_hex(struct plugin *plugin,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static struct command_result *datastore_fail(struct command *command,
|
||||
const char *buf,
|
||||
const jsmntok_t *result,
|
||||
void *unused)
|
||||
{
|
||||
plugin_err(command->plugin, "datastore failed: %.*s",
|
||||
json_tok_full_len(result),
|
||||
json_tok_full(buf, result));
|
||||
}
|
||||
|
||||
struct command_result *jsonrpc_set_datastore_(struct plugin *plugin,
|
||||
struct command *cmd,
|
||||
const char *path,
|
||||
|
@ -635,6 +645,11 @@ struct command_result *jsonrpc_set_datastore_(struct plugin *plugin,
|
|||
{
|
||||
struct out_req *req;
|
||||
|
||||
if (!cb)
|
||||
cb = ignore_cb;
|
||||
if (!errcb)
|
||||
errcb = datastore_fail;
|
||||
|
||||
req = jsonrpc_request_start(plugin, cmd, "datastore", cb, errcb, arg);
|
||||
|
||||
json_add_keypath(req->js->jout, "key", path);
|
||||
|
|
|
@ -161,7 +161,9 @@ struct json_stream *jsonrpc_stream_fail_data(struct command *cmd,
|
|||
int code,
|
||||
const char *err);
|
||||
|
||||
/* Helper to jsonrpc_request_start() and send_outreq() to update datastore. */
|
||||
/* Helper to jsonrpc_request_start() and send_outreq() to update datastore.
|
||||
* NULL cb means ignore, NULL errcb means plugin_error.
|
||||
*/
|
||||
struct command_result *jsonrpc_set_datastore_(struct plugin *plugin,
|
||||
struct command *cmd,
|
||||
const char *path,
|
||||
|
|
Loading…
Add table
Reference in a new issue