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

Function json_deldatastore

lightningd/datastore.c:282–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282static struct command_result *json_deldatastore(struct command *cmd,
283 const char *buffer,
284 const jsmntok_t *obj UNNEEDED,
285 const jsmntok_t *params)
286{
287 struct json_stream *response;
288 const char **key, **k;
289 const u8 *data;
290 u64 *generation;
291 u64 actual_gen;
292 struct db_stmt *stmt;
293
294 if (!param(cmd, buffer, params,
295 p_req("key", param_list_or_string, &key),
296 p_opt("generation", param_u64, &generation),
297 NULL))
298 return command_param_failed();
299
300 stmt = wallet_datastore_first(cmd, cmd->ld->wallet, key,
301 &k, &data, &actual_gen);
302 tal_free(stmt);
303
304 if (!stmt || !datastore_key_eq(k, key)) {
305 return command_fail(cmd, DATASTORE_DEL_DOES_NOT_EXIST,
306 "Key does not exist");
307 }
308 if (generation && actual_gen != *generation)
309 return command_fail(cmd, DATASTORE_DEL_WRONG_GENERATION,
310 "generation is different");
311
312 wallet_datastore_remove(cmd->ld->wallet, key);
313
314 response = json_stream_success(cmd);
315 json_add_datastore(response, key, data, actual_gen);
316 return command_success(cmd, response);
317}
318
319static const struct json_command datastore_command = {
320 "datastore",

Callers

nothing calls this directly

Calls 10

wallet_datastore_firstFunction · 0.85
tal_freeFunction · 0.85
datastore_key_eqFunction · 0.85
wallet_datastore_removeFunction · 0.85
json_add_datastoreFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected