diff options
Diffstat (limited to 'src/datacache/datacache.c')
-rw-r--r-- | src/datacache/datacache.c | 83 |
1 files changed, 6 insertions, 77 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c index 331a9b784..8b665e705 100644 --- a/src/datacache/datacache.c +++ b/src/datacache/datacache.c | |||
@@ -101,7 +101,9 @@ struct GNUNET_DATACACHE_Handle | |||
101 | * @param size number of bytes that were made available | 101 | * @param size number of bytes that were made available |
102 | */ | 102 | */ |
103 | static void | 103 | static void |
104 | env_delete_notify (void *cls, const struct GNUNET_HashCode *key, size_t size) | 104 | env_delete_notify (void *cls, |
105 | const struct GNUNET_HashCode *key, | ||
106 | size_t size) | ||
105 | { | 107 | { |
106 | struct GNUNET_DATACACHE_Handle *h = cls; | 108 | struct GNUNET_DATACACHE_Handle *h = cls; |
107 | 109 | ||
@@ -122,13 +124,6 @@ env_delete_notify (void *cls, const struct GNUNET_HashCode *key, size_t size) | |||
122 | } | 124 | } |
123 | 125 | ||
124 | 126 | ||
125 | /** | ||
126 | * Create a data cache. | ||
127 | * | ||
128 | * @param cfg configuration to use | ||
129 | * @param section section in the configuration that contains our options | ||
130 | * @return handle to use to access the service | ||
131 | */ | ||
132 | struct GNUNET_DATACACHE_Handle * | 127 | struct GNUNET_DATACACHE_Handle * |
133 | GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | 128 | GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, |
134 | const char *section) | 129 | const char *section) |
@@ -193,9 +188,9 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
193 | ret->lib_name = libname; | 188 | ret->lib_name = libname; |
194 | /* Load the plugin within GNUnet's default context */ | 189 | /* Load the plugin within GNUnet's default context */ |
195 | pd = GNUNET_OS_project_data_get (); | 190 | pd = GNUNET_OS_project_data_get (); |
196 | GNUNET_OS_init(GNUNET_OS_project_data_default ()); | 191 | GNUNET_OS_init (GNUNET_OS_project_data_default ()); |
197 | ret->api = GNUNET_PLUGIN_load (libname, &ret->env); | 192 | ret->api = GNUNET_PLUGIN_load (libname, &ret->env); |
198 | GNUNET_OS_init(pd); | 193 | GNUNET_OS_init (pd); |
199 | if (NULL == ret->api) | 194 | if (NULL == ret->api) |
200 | { | 195 | { |
201 | /* Try to load the plugin within the application's context | 196 | /* Try to load the plugin within the application's context |
@@ -215,11 +210,6 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
215 | } | 210 | } |
216 | 211 | ||
217 | 212 | ||
218 | /** | ||
219 | * Destroy a data cache (and free associated resources). | ||
220 | * | ||
221 | * @param h handle to the datastore | ||
222 | */ | ||
223 | void | 213 | void |
224 | GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) | 214 | GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) |
225 | { | 215 | { |
@@ -244,21 +234,7 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) | |||
244 | } | 234 | } |
245 | 235 | ||
246 | 236 | ||
247 | /** | 237 | enum GNUNET_GenericReturnValue |
248 | * Store an item in the datastore. | ||
249 | * | ||
250 | * @param h handle to the datacache | ||
251 | * @param key key to store data under | ||
252 | * @param xor_distance distance of @a key to our PID | ||
253 | * @param data_size number of bytes in @a data | ||
254 | * @param data data to store | ||
255 | * @param type type of the value | ||
256 | * @param discard_time when to discard the value in any case | ||
257 | * @param path_info_len number of entries in @a path_info | ||
258 | * @param path_info a path through the network | ||
259 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error, #GNUNET_NO if duplicate | ||
260 | */ | ||
261 | int | ||
262 | GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | 238 | GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, |
263 | const struct GNUNET_HashCode *key, | 239 | const struct GNUNET_HashCode *key, |
264 | uint32_t xor_distance, | 240 | uint32_t xor_distance, |
@@ -310,17 +286,6 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
310 | } | 286 | } |
311 | 287 | ||
312 | 288 | ||
313 | /** | ||
314 | * Iterate over the results for a particular key | ||
315 | * in the datacache. | ||
316 | * | ||
317 | * @param h handle to the datacache | ||
318 | * @param key what to look up | ||
319 | * @param type entries of which type are relevant? | ||
320 | * @param iter maybe NULL (to just count) | ||
321 | * @param iter_cls closure for @a iter | ||
322 | * @return the number of results found | ||
323 | */ | ||
324 | unsigned int | 289 | unsigned int |
325 | GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, | 290 | GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, |
326 | const struct GNUNET_HashCode *key, | 291 | const struct GNUNET_HashCode *key, |
@@ -352,42 +317,6 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, | |||
352 | } | 317 | } |
353 | 318 | ||
354 | 319 | ||
355 | /** | ||
356 | * Obtain a random element from the datacache. | ||
357 | * | ||
358 | * @param h handle to the datacache | ||
359 | * @param iter maybe NULL (to just count) | ||
360 | * @param iter_cls closure for @a iter | ||
361 | * @return the number of results found (zero or 1) | ||
362 | */ | ||
363 | unsigned int | ||
364 | GNUNET_DATACACHE_get_random (struct GNUNET_DATACACHE_Handle *h, | ||
365 | GNUNET_DATACACHE_Iterator iter, | ||
366 | void *iter_cls) | ||
367 | { | ||
368 | GNUNET_STATISTICS_update (h->stats, | ||
369 | gettext_noop ( | ||
370 | "# requests for random value received"), | ||
371 | 1, | ||
372 | GNUNET_NO); | ||
373 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for random value\n"); | ||
374 | return h->api->get_random (h->api->cls, iter, iter_cls); | ||
375 | } | ||
376 | |||
377 | |||
378 | /** | ||
379 | * Iterate over the results that are "close" to a particular key in | ||
380 | * the datacache. "close" is defined as numerically larger than @a | ||
381 | * key (when interpreted as a circular address space), with small | ||
382 | * distance. | ||
383 | * | ||
384 | * @param h handle to the datacache | ||
385 | * @param key area of the keyspace to look into | ||
386 | * @param num_results number of results that should be returned to @a iter | ||
387 | * @param iter maybe NULL (to just count) | ||
388 | * @param iter_cls closure for @a iter | ||
389 | * @return the number of results found | ||
390 | */ | ||
391 | unsigned int | 320 | unsigned int |
392 | GNUNET_DATACACHE_get_closest (struct GNUNET_DATACACHE_Handle *h, | 321 | GNUNET_DATACACHE_get_closest (struct GNUNET_DATACACHE_Handle *h, |
393 | const struct GNUNET_HashCode *key, | 322 | const struct GNUNET_HashCode *key, |