MCPcopy Create free account
hub / github.com/ElementsProject/lightning / listdatastore_done

Function listdatastore_done

plugins/libplugin.c:980–1018  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978};
979
980static struct command_result *listdatastore_done(struct command *cmd,
981 const char *method,
982 const char *buf,
983 const jsmntok_t *result,
984 struct get_ds_info *dsi)
985{
986 const jsmntok_t *ds = json_get_member(buf, result, "datastore");
987 void *val;
988
989 if (ds->size == 0)
990 val = NULL;
991 else {
992 /* First element in array is object */
993 ds = ds + 1;
994 if (dsi->string_cb) {
995 const jsmntok_t *s;
996 s = json_get_member(buf, ds, "string");
997 if (!s) {
998 /* Complain loudly, since they
999 * expected string! */
1000 plugin_log(cmd->plugin, LOG_BROKEN,
1001 "Datastore gave nonstring result %.*s",
1002 json_tok_full_len(result),
1003 json_tok_full(buf, result));
1004 val = NULL;
1005 } else {
1006 val = json_strdup(cmd, buf, s);
1007 }
1008 } else {
1009 const jsmntok_t *hex;
1010 hex = json_get_member(buf, ds, "hex");
1011 val = json_tok_bin_from_hex(cmd, buf, hex);
1012 }
1013 }
1014
1015 if (dsi->string_cb)
1016 return dsi->string_cb(cmd, val, dsi->arg);
1017 return dsi->binary_cb(cmd, val, dsi->arg);
1018}
1019
1020struct command_result *jsonrpc_get_datastore_(struct command *cmd,
1021 const char **keys,

Callers

nothing calls this directly

Calls 6

json_get_memberFunction · 0.85
plugin_logFunction · 0.70
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_strdupFunction · 0.50
json_tok_bin_from_hexFunction · 0.50

Tested by

no test coverage detected