aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_datastore_plugin.h
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amat.us>2017-03-19 15:55:32 -0500
committerDavid Barksdale <amatus@amat.us>2017-03-19 17:38:36 -0500
commit2dde0202c5590eeb051c1346f2b66293d83b87ce (patch)
tree7997191912ee4c70959934d6c9783a0c9f450fec /src/include/gnunet_datastore_plugin.h
parentd17d833dfd93a81f3540d472d1be4dfb7e9cbd03 (diff)
downloadgnunet-2dde0202c5590eeb051c1346f2b66293d83b87ce.tar.gz
gnunet-2dde0202c5590eeb051c1346f2b66293d83b87ce.zip
[datastore] Fix #3743
This change adds support for key == NULL to the datastore plugins and replaces the offset argument with a next_uid and random arguments to increase performance in the key == NULL case. With the offset argument a datastore plugin would have to count all matching keys before fetching the key at the right offset, which would iterate over the entire database in the case of key == NULL. The offset argument was used in two ways: to iterate over a set of matching values and to start iteration at a random matching value. The new API seperates these into two arguments: if random is true it will return a random matching value, otherwise next_uid can be set to uid + 1 to return the next matching value. The random argument was not added to get_zero_anonymity. This function is used to periodically insert zero anonymity values into the DHT. I don't think it's necessary to randomize this.
Diffstat (limited to 'src/include/gnunet_datastore_plugin.h')
-rw-r--r--src/include/gnunet_datastore_plugin.h41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/include/gnunet_datastore_plugin.h b/src/include/gnunet_datastore_plugin.h
index 2295d4e72..b1c9cb7c3 100644
--- a/src/include/gnunet_datastore_plugin.h
+++ b/src/include/gnunet_datastore_plugin.h
@@ -204,9 +204,9 @@ typedef void
204 * Get one of the results for a particular key in the datastore. 204 * Get one of the results for a particular key in the datastore.
205 * 205 *
206 * @param cls closure 206 * @param cls closure
207 * @param offset offset of the result (modulo num-results); 207 * @param next_uid return the result with lowest uid >= next_uid
208 * specific ordering does not matter for the offset 208 * @param random if true, return a random result instead of using next_uid
209 * @param key key to match, never NULL 209 * @param key maybe NULL (to match all entries)
210 * @param vhash hash of the value, maybe NULL (to 210 * @param vhash hash of the value, maybe NULL (to
211 * match all values that have the right key). 211 * match all values that have the right key).
212 * Note that for DBlocks there is no difference 212 * Note that for DBlocks there is no difference
@@ -215,17 +215,18 @@ typedef void
215 * @param type entries of which type are relevant? 215 * @param type entries of which type are relevant?
216 * Use 0 for any type. 216 * Use 0 for any type.
217 * @param proc function to call on the matching value; 217 * @param proc function to call on the matching value;
218 * proc should be called with NULL if there is no result 218 * will be called with NULL if nothing matches
219 * @param proc_cls closure for @a proc 219 * @param proc_cls closure for @a proc
220 */ 220 */
221typedef void 221typedef void
222(*PluginGetKey) (void *cls, 222(*PluginGetKey) (void *cls,
223 uint64_t offset, 223 uint64_t next_uid,
224 const struct GNUNET_HashCode *key, 224 bool random,
225 const struct GNUNET_HashCode *vhash, 225 const struct GNUNET_HashCode *key,
226 enum GNUNET_BLOCK_Type type, 226 const struct GNUNET_HashCode *vhash,
227 PluginDatumProcessor proc, 227 enum GNUNET_BLOCK_Type type,
228 void *proc_cls); 228 PluginDatumProcessor proc,
229 void *proc_cls);
229 230
230 231
231/** 232/**
@@ -285,23 +286,22 @@ typedef void
285 286
286 287
287/** 288/**
288 * Select a single item from the datastore at the specified offset 289 * Select a single item from the datastore (among those applicable).
289 * (among those applicable).
290 * 290 *
291 * @param cls closure 291 * @param cls closure
292 * @param offset offset of the result (modulo num-results); 292 * @param next_uid return the result with lowest uid >= next_uid
293 * specific ordering does not matter for the offset
294 * @param type entries of which type should be considered? 293 * @param type entries of which type should be considered?
295 * Must not be zero (ANY). 294 * Must not be zero (ANY).
296 * @param proc function to call on the matching value 295 * @param proc function to call on the matching value;
296 * will be called with NULL if no value matches
297 * @param proc_cls closure for @a proc 297 * @param proc_cls closure for @a proc
298 */ 298 */
299typedef void 299typedef void
300(*PluginGetType) (void *cls, 300(*PluginGetType) (void *cls,
301 uint64_t offset, 301 uint64_t next_uid,
302 enum GNUNET_BLOCK_Type type, 302 enum GNUNET_BLOCK_Type type,
303 PluginDatumProcessor proc, 303 PluginDatumProcessor proc,
304 void *proc_cls); 304 void *proc_cls);
305 305
306 306
307/** 307/**
@@ -354,9 +354,6 @@ struct GNUNET_DATASTORE_PluginFunctions
354 354
355 /** 355 /**
356 * Get datum (of the specified type) with anonymity level zero. 356 * Get datum (of the specified type) with anonymity level zero.
357 * This function is allowed to ignore the 'offset' argument
358 * and instead return a random result (with zero anonymity of
359 * the correct type) if implementing an offset is expensive.
360 */ 357 */
361 PluginGetType get_zero_anonymity; 358 PluginGetType get_zero_anonymity;
362 359