mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-07 15:14:21 +01:00
libplugin: more datastore helpers.
These ones to fetch inside callbacks. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
68f3e3fba9
commit
7b24ea60e3
@@ -165,7 +165,7 @@ struct json_stream *jsonrpc_stream_fail_data(struct command *cmd,
|
||||
|
||||
/* 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,
|
||||
@@ -210,6 +210,41 @@ struct command_result *jsonrpc_set_datastore_(struct plugin *plugin,
|
||||
const jsmntok_t *result), \
|
||||
(arg))
|
||||
|
||||
/* Helper to jsonrpc_request_start() and send_outreq() to read datastore.
|
||||
* If the value not found, cb gets NULL @val.
|
||||
*/
|
||||
struct command_result *jsonrpc_get_datastore_(struct plugin *plugin,
|
||||
struct command *cmd,
|
||||
const char *path,
|
||||
struct command_result *(*string_cb)(struct command *command,
|
||||
const char *val,
|
||||
void *arg),
|
||||
struct command_result *(*binary_cb)(struct command *command,
|
||||
const u8 *val,
|
||||
void *arg),
|
||||
void *arg);
|
||||
|
||||
#define jsonrpc_get_datastore_string(plugin, cmd, path, cb, arg) \
|
||||
jsonrpc_get_datastore_((plugin), (cmd), (path), \
|
||||
typesafe_cb_preargs(struct command_result *, \
|
||||
void *, \
|
||||
(cb), (arg), \
|
||||
struct command *command, \
|
||||
const char *val), \
|
||||
NULL, \
|
||||
(arg))
|
||||
|
||||
#define jsonrpc_get_datastore_binary(plugin, cmd, path, cb, arg) \
|
||||
jsonrpc_get_datastore_((plugin), (cmd), (path), \
|
||||
NULL, \
|
||||
typesafe_cb_preargs(struct command_result *, \
|
||||
void *, \
|
||||
(cb), (arg), \
|
||||
struct command *command, \
|
||||
const u8 *val), \
|
||||
(arg))
|
||||
|
||||
|
||||
/* This command is finished, here's the response (the content of the
|
||||
* "result" or "error" field) */
|
||||
WARN_UNUSED_RESULT
|
||||
|
||||
Reference in New Issue
Block a user