From a58d36b8da7afa42410bac54f57d5f3b6b6c4391 Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Sun, 16 Apr 2017 20:46:21 -0500 Subject: [datastore] Create remove plugin API call The only use of vhash in the get_key call was for removing, split that out into its own function. This simplifies the get_key call and removes the need for some indexes, speeding up insertion into the database. --- src/include/gnunet_datastore_plugin.h | 47 ++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'src/include/gnunet_datastore_plugin.h') diff --git a/src/include/gnunet_datastore_plugin.h b/src/include/gnunet_datastore_plugin.h index 28c8241b1..36a3fbec2 100644 --- a/src/include/gnunet_datastore_plugin.h +++ b/src/include/gnunet_datastore_plugin.h @@ -212,11 +212,6 @@ typedef void * @param next_uid return the result with lowest uid >= next_uid * @param random if true, return a random result instead of using next_uid * @param key maybe NULL (to match all entries) - * @param vhash hash of the value, maybe NULL (to - * match all values that have the right key). - * Note that for DBlocks there is no difference - * betwen key and vhash, but for other blocks - * there may be! * @param type entries of which type are relevant? * Use 0 for any type. * @param proc function to call on the matching value; @@ -228,12 +223,48 @@ typedef void uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, - const struct GNUNET_HashCode *vhash, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls); +/** + * Remove continuation. + * + * @param cls closure + * @param key key for the content removed + * @param size number of bytes removed + * @param status #GNUNET_OK if removed, #GNUNET_NO if not found, + * or #GNUNET_SYSERROR if error + * @param msg error message on error + */ +typedef void +(*PluginRemoveCont) (void *cls, + const struct GNUNET_HashCode *key, + uint32_t size, + int status, + const char *msg); + + +/** + * Remove a particular key in the datastore. + * + * @param cls closure + * @param key key for the content + * @param size number of bytes in data + * @param data content stored + * @param cont continuation called with success or failure status + * @param cont_cls continuation closure for @a cont + */ +typedef void +(*PluginRemoveKey) (void *cls, + const struct GNUNET_HashCode *key, + uint32_t size, + const void *data, + PluginRemoveCont cont, + void *cont_cls); + + /** * Get a random item (additional constraints may apply depending on * the specific implementation). Calls @a proc with all values ZERO or @@ -339,6 +370,10 @@ struct GNUNET_DATASTORE_PluginFunctions */ PluginGetKeys get_keys; + /** + * Function to remove an item from the database. + */ + PluginRemoveKey remove_key; }; #endif -- cgit v1.2.3