diff options
author | David Barksdale <amatus@amat.us> | 2017-03-19 15:55:32 -0500 |
---|---|---|
committer | David Barksdale <amatus@amat.us> | 2017-03-19 17:38:36 -0500 |
commit | 2dde0202c5590eeb051c1346f2b66293d83b87ce (patch) | |
tree | 7997191912ee4c70959934d6c9783a0c9f450fec /src/include/gnunet_datastore_service.h | |
parent | d17d833dfd93a81f3540d472d1be4dfb7e9cbd03 (diff) | |
download | gnunet-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_service.h')
-rw-r--r-- | src/include/gnunet_datastore_service.h | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index 233598667..830e7da86 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h | |||
@@ -261,10 +261,8 @@ typedef void | |||
261 | * will only be called once. | 261 | * will only be called once. |
262 | * | 262 | * |
263 | * @param h handle to the datastore | 263 | * @param h handle to the datastore |
264 | * @param offset offset of the result (modulo num-results); set to | 264 | * @param next_uid return the result with lowest uid >= next_uid |
265 | * a random 64-bit value initially; then increment by | 265 | * @param random if true, return a random result instead of using next_uid |
266 | * one each time; detect that all results have been found by uid | ||
267 | * being again the first uid ever returned. | ||
268 | * @param key maybe NULL (to match all entries) | 266 | * @param key maybe NULL (to match all entries) |
269 | * @param type desired type, 0 for any | 267 | * @param type desired type, 0 for any |
270 | * @param queue_priority ranking of this request in the priority queue | 268 | * @param queue_priority ranking of this request in the priority queue |
@@ -278,7 +276,8 @@ typedef void | |||
278 | */ | 276 | */ |
279 | struct GNUNET_DATASTORE_QueueEntry * | 277 | struct GNUNET_DATASTORE_QueueEntry * |
280 | GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, | 278 | GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, |
281 | uint64_t offset, | 279 | uint64_t next_uid, |
280 | bool random, | ||
282 | const struct GNUNET_HashCode *key, | 281 | const struct GNUNET_HashCode *key, |
283 | enum GNUNET_BLOCK_Type type, | 282 | enum GNUNET_BLOCK_Type type, |
284 | unsigned int queue_priority, | 283 | unsigned int queue_priority, |
@@ -289,16 +288,9 @@ GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, | |||
289 | 288 | ||
290 | /** | 289 | /** |
291 | * Get a single zero-anonymity value from the datastore. | 290 | * Get a single zero-anonymity value from the datastore. |
292 | * Note that some implementations can ignore the 'offset' and | ||
293 | * instead return a random zero-anonymity value. In that case, | ||
294 | * detecting the wrap-around based on a repeating UID is at best | ||
295 | * probabilistic. | ||
296 | * | 291 | * |
297 | * @param h handle to the datastore | 292 | * @param h handle to the datastore |
298 | * @param offset offset of the result (modulo num-results); set to | 293 | * @param next_uid return the result with lowest uid >= next_uid |
299 | * a random 64-bit value initially; then increment by | ||
300 | * one each time; detect that all results have been found by uid | ||
301 | * being again the first uid ever returned. | ||
302 | * @param queue_priority ranking of this request in the priority queue | 294 | * @param queue_priority ranking of this request in the priority queue |
303 | * @param max_queue_size at what queue size should this request be dropped | 295 | * @param max_queue_size at what queue size should this request be dropped |
304 | * (if other requests of higher priority are in the queue) | 296 | * (if other requests of higher priority are in the queue) |
@@ -312,7 +304,7 @@ GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, | |||
312 | */ | 304 | */ |
313 | struct GNUNET_DATASTORE_QueueEntry * | 305 | struct GNUNET_DATASTORE_QueueEntry * |
314 | GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, | 306 | GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, |
315 | uint64_t offset, | 307 | uint64_t next_uid, |
316 | unsigned int queue_priority, | 308 | unsigned int queue_priority, |
317 | unsigned int max_queue_size, | 309 | unsigned int max_queue_size, |
318 | enum GNUNET_BLOCK_Type type, | 310 | enum GNUNET_BLOCK_Type type, |