diff options
author | David Barksdale <amatus@amat.us> | 2017-04-16 20:46:21 -0500 |
---|---|---|
committer | David Barksdale <amatus@amat.us> | 2017-04-16 20:49:27 -0500 |
commit | a58d36b8da7afa42410bac54f57d5f3b6b6c4391 (patch) | |
tree | 87b00f07dda6a5c28a9d65ef9c05044cab2336fd /src/datastore/plugin_datastore_template.c | |
parent | 4907330f51ffd48af1f7bac6f43c7c7f78c37818 (diff) | |
download | gnunet-a58d36b8da7afa42410bac54f57d5f3b6b6c4391.tar.gz gnunet-a58d36b8da7afa42410bac54f57d5f3b6b6c4391.zip |
[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.
Diffstat (limited to 'src/datastore/plugin_datastore_template.c')
-rw-r--r-- | src/datastore/plugin_datastore_template.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/datastore/plugin_datastore_template.c b/src/datastore/plugin_datastore_template.c index 704d586bc..16bda45d4 100644 --- a/src/datastore/plugin_datastore_template.c +++ b/src/datastore/plugin_datastore_template.c | |||
@@ -99,11 +99,6 @@ template_plugin_put (void *cls, | |||
99 | * @param next_uid return the result with lowest uid >= next_uid | 99 | * @param next_uid return the result with lowest uid >= next_uid |
100 | * @param random if true, return a random result instead of using next_uid | 100 | * @param random if true, return a random result instead of using next_uid |
101 | * @param key maybe NULL (to match all entries) | 101 | * @param key maybe NULL (to match all entries) |
102 | * @param vhash hash of the value, maybe NULL (to | ||
103 | * match all values that have the right key). | ||
104 | * Note that for DBlocks there is no difference | ||
105 | * betwen key and vhash, but for other blocks | ||
106 | * there may be! | ||
107 | * @param type entries of which type are relevant? | 102 | * @param type entries of which type are relevant? |
108 | * Use 0 for any type. | 103 | * Use 0 for any type. |
109 | * @param proc function to call on each matching value; | 104 | * @param proc function to call on each matching value; |
@@ -111,10 +106,12 @@ template_plugin_put (void *cls, | |||
111 | * @param proc_cls closure for proc | 106 | * @param proc_cls closure for proc |
112 | */ | 107 | */ |
113 | static void | 108 | static void |
114 | template_plugin_get_key (void *cls, uint64_t next_uid, bool random, | 109 | template_plugin_get_key (void *cls, |
115 | const struct GNUNET_HashCode * key, | 110 | uint64_t next_uid, |
116 | const struct GNUNET_HashCode * vhash, | 111 | bool random, |
117 | enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, | 112 | const struct GNUNET_HashCode *key, |
113 | enum GNUNET_BLOCK_Type type, | ||
114 | PluginDatumProcessor proc, | ||
118 | void *proc_cls) | 115 | void *proc_cls) |
119 | { | 116 | { |
120 | GNUNET_break (0); | 117 | GNUNET_break (0); |
@@ -204,6 +201,29 @@ template_get_keys (void *cls, | |||
204 | 201 | ||
205 | 202 | ||
206 | /** | 203 | /** |
204 | * Remove a particular key in the datastore. | ||
205 | * | ||
206 | * @param cls closure | ||
207 | * @param key key for the content | ||
208 | * @param size number of bytes in data | ||
209 | * @param data content stored | ||
210 | * @param cont continuation called with success or failure status | ||
211 | * @param cont_cls continuation closure for @a cont | ||
212 | */ | ||
213 | static void | ||
214 | template_plugin_remove_key (void *cls, | ||
215 | const struct GNUNET_HashCode *key, | ||
216 | uint32_t size, | ||
217 | const void *data, | ||
218 | PluginRemoveCont cont, | ||
219 | void *cont_cls) | ||
220 | { | ||
221 | GNUNET_break (0); | ||
222 | cont (cont_cls, key, size, GNUNET_SYSERR, "not implemented"); | ||
223 | } | ||
224 | |||
225 | |||
226 | /** | ||
207 | * Entry point for the plugin. | 227 | * Entry point for the plugin. |
208 | * | 228 | * |
209 | * @param cls the "struct GNUNET_DATASTORE_PluginEnvironment*" | 229 | * @param cls the "struct GNUNET_DATASTORE_PluginEnvironment*" |
@@ -228,6 +248,7 @@ libgnunet_plugin_datastore_template_init (void *cls) | |||
228 | api->get_zero_anonymity = &template_plugin_get_zero_anonymity; | 248 | api->get_zero_anonymity = &template_plugin_get_zero_anonymity; |
229 | api->drop = &template_plugin_drop; | 249 | api->drop = &template_plugin_drop; |
230 | api->get_keys = &template_get_keys; | 250 | api->get_keys = &template_get_keys; |
251 | api->remove_key = &template_plugin_remove_key; | ||
231 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "template", | 252 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "template", |
232 | _("Template database running\n")); | 253 | _("Template database running\n")); |
233 | return api; | 254 | return api; |