diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-01-02 22:10:16 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-01-02 22:10:16 +0100 |
commit | 1b39a393307288188d790c8e89f794a136a2653f (patch) | |
tree | 1c50c7c21afb4072758709be239813afe66c1536 | |
parent | 0eca5d452354979721c52ba8e0e583d063b92d3d (diff) | |
download | gnunet-1b39a393307288188d790c8e89f794a136a2653f.tar.gz gnunet-1b39a393307288188d790c8e89f794a136a2653f.zip |
-dce
-rw-r--r-- | src/datacache/datacache.c | 83 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_heap.c | 28 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_postgres.c | 99 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_sqlite.c | 90 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_template.c | 19 | ||||
-rw-r--r-- | src/include/gnunet_datacache_lib.h | 14 |
6 files changed, 8 insertions, 325 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, |
diff --git a/src/datacache/plugin_datacache_heap.c b/src/datacache/plugin_datacache_heap.c index 074437e7d..20d18458d 100644 --- a/src/datacache/plugin_datacache_heap.c +++ b/src/datacache/plugin_datacache_heap.c | |||
@@ -402,33 +402,6 @@ heap_plugin_del (void *cls) | |||
402 | 402 | ||
403 | 403 | ||
404 | /** | 404 | /** |
405 | * Return a random value from the datastore. | ||
406 | * | ||
407 | * @param cls closure (our `struct Plugin`) | ||
408 | * @param iter maybe NULL (to just count) | ||
409 | * @param iter_cls closure for @a iter | ||
410 | * @return the number of results found | ||
411 | */ | ||
412 | static unsigned int | ||
413 | heap_plugin_get_random (void *cls, | ||
414 | GNUNET_DATACACHE_Iterator iter, | ||
415 | void *iter_cls) | ||
416 | { | ||
417 | struct Plugin *plugin = cls; | ||
418 | struct GetContext get_ctx; | ||
419 | |||
420 | get_ctx.type = GNUNET_BLOCK_TYPE_ANY; | ||
421 | get_ctx.iter = iter; | ||
422 | get_ctx.iter_cls = iter_cls; | ||
423 | get_ctx.cnt = 0; | ||
424 | GNUNET_CONTAINER_multihashmap_get_random (plugin->map, | ||
425 | &get_cb, | ||
426 | &get_ctx); | ||
427 | return get_ctx.cnt; | ||
428 | } | ||
429 | |||
430 | |||
431 | /** | ||
432 | * Closure for #find_closest(). | 405 | * Closure for #find_closest(). |
433 | */ | 406 | */ |
434 | struct GetClosestContext | 407 | struct GetClosestContext |
@@ -548,7 +521,6 @@ libgnunet_plugin_datacache_heap_init (void *cls) | |||
548 | api->get = &heap_plugin_get; | 521 | api->get = &heap_plugin_get; |
549 | api->put = &heap_plugin_put; | 522 | api->put = &heap_plugin_put; |
550 | api->del = &heap_plugin_del; | 523 | api->del = &heap_plugin_del; |
551 | api->get_random = &heap_plugin_get_random; | ||
552 | api->get_closest = &heap_plugin_get_closest; | 524 | api->get_closest = &heap_plugin_get_closest; |
553 | LOG (GNUNET_ERROR_TYPE_INFO, | 525 | LOG (GNUNET_ERROR_TYPE_INFO, |
554 | _ ("Heap datacache running\n")); | 526 | _ ("Heap datacache running\n")); |
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c index 6613ae928..070619137 100644 --- a/src/datacache/plugin_datacache_postgres.c +++ b/src/datacache/plugin_datacache_postgres.c | |||
@@ -67,7 +67,8 @@ static int | |||
67 | init_connection (struct Plugin *plugin) | 67 | init_connection (struct Plugin *plugin) |
68 | { | 68 | { |
69 | struct GNUNET_PQ_ExecuteStatement es[] = { | 69 | struct GNUNET_PQ_ExecuteStatement es[] = { |
70 | GNUNET_PQ_make_try_execute ("CREATE TEMPORARY SEQUENCE IF NOT EXISTS gn011dc_oid_seq"), | 70 | GNUNET_PQ_make_try_execute ( |
71 | "CREATE TEMPORARY SEQUENCE IF NOT EXISTS gn011dc_oid_seq"), | ||
71 | GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS gn011dc (" | 72 | GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS gn011dc (" |
72 | " oid OID NOT NULL DEFAULT nextval('gn011dc_oid_seq')," | 73 | " oid OID NOT NULL DEFAULT nextval('gn011dc_oid_seq')," |
73 | " type INTEGER NOT NULL," | 74 | " type INTEGER NOT NULL," |
@@ -107,11 +108,6 @@ init_connection (struct Plugin *plugin) | |||
107 | "SELECT length(value) AS len,oid,key FROM gn011dc" | 108 | "SELECT length(value) AS len,oid,key FROM gn011dc" |
108 | " ORDER BY prox ASC, discard_time ASC LIMIT 1", | 109 | " ORDER BY prox ASC, discard_time ASC LIMIT 1", |
109 | 0), | 110 | 0), |
110 | GNUNET_PQ_make_prepare ("get_random", | ||
111 | "SELECT discard_time,type,value,path,key FROM gn011dc" | ||
112 | " WHERE discard_time >= $1" | ||
113 | " ORDER BY key ASC LIMIT 1 OFFSET $2", | ||
114 | 2), | ||
115 | GNUNET_PQ_make_prepare ("get_closest", | 111 | GNUNET_PQ_make_prepare ("get_closest", |
116 | "SELECT discard_time,type,value,path,key FROM gn011dc " | 112 | "SELECT discard_time,type,value,path,key FROM gn011dc " |
117 | "WHERE key>=$1 AND discard_time >= $2 ORDER BY key ASC LIMIT $3", | 113 | "WHERE key>=$1 AND discard_time >= $2 ORDER BY key ASC LIMIT $3", |
@@ -410,96 +406,6 @@ postgres_plugin_del (void *cls) | |||
410 | 406 | ||
411 | 407 | ||
412 | /** | 408 | /** |
413 | * Obtain a random key-value pair from the datacache. | ||
414 | * | ||
415 | * @param cls closure (our `struct Plugin`) | ||
416 | * @param iter maybe NULL (to just count) | ||
417 | * @param iter_cls closure for @a iter | ||
418 | * @return the number of results found, zero (datacache empty) or one | ||
419 | */ | ||
420 | static unsigned int | ||
421 | postgres_plugin_get_random (void *cls, | ||
422 | GNUNET_DATACACHE_Iterator iter, | ||
423 | void *iter_cls) | ||
424 | { | ||
425 | struct Plugin *plugin = cls; | ||
426 | uint32_t off; | ||
427 | struct GNUNET_TIME_Absolute now = { 0 }; | ||
428 | struct GNUNET_TIME_Absolute expiration_time; | ||
429 | size_t data_size; | ||
430 | void *data; | ||
431 | size_t path_len; | ||
432 | struct GNUNET_PeerIdentity *path; | ||
433 | struct GNUNET_HashCode key; | ||
434 | uint32_t type; | ||
435 | enum GNUNET_DB_QueryStatus res; | ||
436 | struct GNUNET_PQ_QueryParam params[] = { | ||
437 | GNUNET_PQ_query_param_absolute_time (&now), | ||
438 | GNUNET_PQ_query_param_uint32 (&off), | ||
439 | GNUNET_PQ_query_param_end | ||
440 | }; | ||
441 | struct GNUNET_PQ_ResultSpec rs[] = { | ||
442 | GNUNET_PQ_result_spec_absolute_time ("discard_time", | ||
443 | &expiration_time), | ||
444 | GNUNET_PQ_result_spec_uint32 ("type", | ||
445 | &type), | ||
446 | GNUNET_PQ_result_spec_variable_size ("value", | ||
447 | &data, | ||
448 | &data_size), | ||
449 | GNUNET_PQ_result_spec_variable_size ("path", | ||
450 | (void **) &path, | ||
451 | &path_len), | ||
452 | GNUNET_PQ_result_spec_auto_from_type ("key", | ||
453 | &key), | ||
454 | GNUNET_PQ_result_spec_end | ||
455 | }; | ||
456 | |||
457 | if (0 == plugin->num_items) | ||
458 | return 0; | ||
459 | if (NULL == iter) | ||
460 | return 1; | ||
461 | now = GNUNET_TIME_absolute_get (); | ||
462 | off = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, | ||
463 | plugin->num_items); | ||
464 | res = GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, | ||
465 | "get_random", | ||
466 | params, | ||
467 | rs); | ||
468 | if (0 > res) | ||
469 | { | ||
470 | GNUNET_break (0); | ||
471 | return 0; | ||
472 | } | ||
473 | if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == res) | ||
474 | { | ||
475 | GNUNET_break (0); | ||
476 | return 0; | ||
477 | } | ||
478 | if (0 != (path_len % sizeof(struct GNUNET_PeerIdentity))) | ||
479 | { | ||
480 | GNUNET_break (0); | ||
481 | path_len = 0; | ||
482 | } | ||
483 | path_len %= sizeof(struct GNUNET_PeerIdentity); | ||
484 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
485 | "Found random value with key %s of size %u bytes and type %u in database\n", | ||
486 | GNUNET_h2s (&key), | ||
487 | (unsigned int) data_size, | ||
488 | (unsigned int) type); | ||
489 | (void) iter (iter_cls, | ||
490 | &key, | ||
491 | data_size, | ||
492 | data, | ||
493 | (enum GNUNET_BLOCK_Type) type, | ||
494 | expiration_time, | ||
495 | path_len, | ||
496 | path); | ||
497 | GNUNET_PQ_cleanup_result (rs); | ||
498 | return 1; | ||
499 | } | ||
500 | |||
501 | |||
502 | /** | ||
503 | * Closure for #extract_result_cb. | 409 | * Closure for #extract_result_cb. |
504 | */ | 410 | */ |
505 | struct ExtractResultContext | 411 | struct ExtractResultContext |
@@ -681,7 +587,6 @@ libgnunet_plugin_datacache_postgres_init (void *cls) | |||
681 | api->get = &postgres_plugin_get; | 587 | api->get = &postgres_plugin_get; |
682 | api->put = &postgres_plugin_put; | 588 | api->put = &postgres_plugin_put; |
683 | api->del = &postgres_plugin_del; | 589 | api->del = &postgres_plugin_del; |
684 | api->get_random = &postgres_plugin_get_random; | ||
685 | api->get_closest = &postgres_plugin_get_closest; | 590 | api->get_closest = &postgres_plugin_get_closest; |
686 | LOG (GNUNET_ERROR_TYPE_INFO, | 591 | LOG (GNUNET_ERROR_TYPE_INFO, |
687 | "Postgres datacache running\n"); | 592 | "Postgres datacache running\n"); |
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 66ff9e82c..0c894556b 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c | |||
@@ -92,11 +92,6 @@ struct Plugin | |||
92 | sqlite3_stmt *del_stmt; | 92 | sqlite3_stmt *del_stmt; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Prepared statement for #sqlite_plugin_get_random. | ||
96 | */ | ||
97 | sqlite3_stmt *get_random_stmt; | ||
98 | |||
99 | /** | ||
100 | * Prepared statement for #sqlite_plugin_get_closest. | 95 | * Prepared statement for #sqlite_plugin_get_closest. |
101 | */ | 96 | */ |
102 | sqlite3_stmt *get_closest_stmt; | 97 | sqlite3_stmt *get_closest_stmt; |
@@ -452,85 +447,6 @@ sqlite_plugin_del (void *cls) | |||
452 | 447 | ||
453 | 448 | ||
454 | /** | 449 | /** |
455 | * Obtain a random key-value pair from the datacache. | ||
456 | * | ||
457 | * @param cls closure (our `struct Plugin`) | ||
458 | * @param iter maybe NULL (to just count) | ||
459 | * @param iter_cls closure for @a iter | ||
460 | * @return the number of results found, zero (datacache empty) or one | ||
461 | */ | ||
462 | static unsigned int | ||
463 | sqlite_plugin_get_random (void *cls, | ||
464 | GNUNET_DATACACHE_Iterator iter, | ||
465 | void *iter_cls) | ||
466 | { | ||
467 | struct Plugin *plugin = cls; | ||
468 | struct GNUNET_TIME_Absolute exp; | ||
469 | size_t size; | ||
470 | void *dat; | ||
471 | uint32_t off = 0; | ||
472 | size_t psize; | ||
473 | uint32_t type; | ||
474 | struct GNUNET_PeerIdentity *path; | ||
475 | struct GNUNET_HashCode key; | ||
476 | struct GNUNET_SQ_QueryParam params[] = { GNUNET_SQ_query_param_uint32 (&off), | ||
477 | GNUNET_SQ_query_param_end }; | ||
478 | struct GNUNET_SQ_ResultSpec rs[] = | ||
479 | { GNUNET_SQ_result_spec_variable_size (&dat, &size), | ||
480 | GNUNET_SQ_result_spec_absolute_time (&exp), | ||
481 | GNUNET_SQ_result_spec_variable_size ((void **) &path, &psize), | ||
482 | GNUNET_SQ_result_spec_auto_from_type (&key), | ||
483 | GNUNET_SQ_result_spec_uint32 (&type), | ||
484 | GNUNET_SQ_result_spec_end }; | ||
485 | |||
486 | if (0 == plugin->num_items) | ||
487 | return 0; | ||
488 | if (NULL == iter) | ||
489 | return 1; | ||
490 | off = | ||
491 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, plugin->num_items); | ||
492 | if (GNUNET_OK != GNUNET_SQ_bind (plugin->get_random_stmt, params)) | ||
493 | { | ||
494 | return 0; | ||
495 | } | ||
496 | if (SQLITE_ROW != sqlite3_step (plugin->get_random_stmt)) | ||
497 | { | ||
498 | GNUNET_break (0); | ||
499 | GNUNET_SQ_reset (plugin->dbh, plugin->get_random_stmt); | ||
500 | return 0; | ||
501 | } | ||
502 | if (GNUNET_OK != GNUNET_SQ_extract_result (plugin->get_random_stmt, rs)) | ||
503 | { | ||
504 | GNUNET_break (0); | ||
505 | GNUNET_SQ_reset (plugin->dbh, plugin->get_random_stmt); | ||
506 | return 0; | ||
507 | } | ||
508 | if (0 != psize % sizeof(struct GNUNET_PeerIdentity)) | ||
509 | { | ||
510 | GNUNET_break (0); | ||
511 | psize = 0; | ||
512 | path = NULL; | ||
513 | } | ||
514 | psize /= sizeof(struct GNUNET_PeerIdentity); | ||
515 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
516 | "Found %u-byte result with key %s when processing GET-RANDOM\n", | ||
517 | (unsigned int) size, | ||
518 | GNUNET_h2s (&key)); | ||
519 | (void) iter (iter_cls, | ||
520 | &key, | ||
521 | size, | ||
522 | dat, | ||
523 | (enum GNUNET_BLOCK_Type) type, | ||
524 | exp, | ||
525 | psize, | ||
526 | path); | ||
527 | GNUNET_SQ_cleanup_result (rs); | ||
528 | GNUNET_SQ_reset (plugin->dbh, plugin->get_random_stmt); | ||
529 | return 1; | ||
530 | } | ||
531 | |||
532 | |||
533 | /** | ||
534 | * Iterate over the results that are "close" to a particular key in | 450 | * Iterate over the results that are "close" to a particular key in |
535 | * the datacache. "close" is defined as numerically larger than @a | 451 | * the datacache. "close" is defined as numerically larger than @a |
536 | * key (when interpreted as a circular address space), with small | 452 | * key (when interpreted as a circular address space), with small |
@@ -714,10 +630,6 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) | |||
714 | (SQLITE_OK != sq_prepare (plugin->dbh, | 630 | (SQLITE_OK != sq_prepare (plugin->dbh, |
715 | "DELETE FROM ds091 WHERE _ROWID_=?", | 631 | "DELETE FROM ds091 WHERE _ROWID_=?", |
716 | &plugin->del_stmt)) || | 632 | &plugin->del_stmt)) || |
717 | (SQLITE_OK != sq_prepare (plugin->dbh, | ||
718 | "SELECT value,expire,path,key,type FROM ds091 " | ||
719 | "ORDER BY key LIMIT 1 OFFSET ?", | ||
720 | &plugin->get_random_stmt)) || | ||
721 | (SQLITE_OK != | 633 | (SQLITE_OK != |
722 | sq_prepare (plugin->dbh, | 634 | sq_prepare (plugin->dbh, |
723 | "SELECT value,expire,path,type,key FROM ds091 " | 635 | "SELECT value,expire,path,type,key FROM ds091 " |
@@ -737,7 +649,6 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) | |||
737 | api->get = &sqlite_plugin_get; | 649 | api->get = &sqlite_plugin_get; |
738 | api->put = &sqlite_plugin_put; | 650 | api->put = &sqlite_plugin_put; |
739 | api->del = &sqlite_plugin_del; | 651 | api->del = &sqlite_plugin_del; |
740 | api->get_random = &sqlite_plugin_get_random; | ||
741 | api->get_closest = &sqlite_plugin_get_closest; | 652 | api->get_closest = &sqlite_plugin_get_closest; |
742 | LOG (GNUNET_ERROR_TYPE_INFO, "Sqlite datacache running\n"); | 653 | LOG (GNUNET_ERROR_TYPE_INFO, "Sqlite datacache running\n"); |
743 | return api; | 654 | return api; |
@@ -772,7 +683,6 @@ libgnunet_plugin_datacache_sqlite_done (void *cls) | |||
772 | sqlite3_finalize (plugin->del_select_stmt); | 683 | sqlite3_finalize (plugin->del_select_stmt); |
773 | sqlite3_finalize (plugin->del_expired_stmt); | 684 | sqlite3_finalize (plugin->del_expired_stmt); |
774 | sqlite3_finalize (plugin->del_stmt); | 685 | sqlite3_finalize (plugin->del_stmt); |
775 | sqlite3_finalize (plugin->get_random_stmt); | ||
776 | sqlite3_finalize (plugin->get_closest_stmt); | 686 | sqlite3_finalize (plugin->get_closest_stmt); |
777 | result = sqlite3_close (plugin->dbh); | 687 | result = sqlite3_close (plugin->dbh); |
778 | #if SQLITE_VERSION_NUMBER >= 3007000 | 688 | #if SQLITE_VERSION_NUMBER >= 3007000 |
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c index 329bfd9a4..09279f55c 100644 --- a/src/datacache/plugin_datacache_template.c +++ b/src/datacache/plugin_datacache_template.c | |||
@@ -109,24 +109,6 @@ template_plugin_del (void *cls) | |||
109 | 109 | ||
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Return a random value from the datastore. | ||
113 | * | ||
114 | * @param cls closure (internal context for the plugin) | ||
115 | * @param iter maybe NULL (to just count) | ||
116 | * @param iter_cls closure for @a iter | ||
117 | * @return the number of results found (zero or one) | ||
118 | */ | ||
119 | static unsigned int | ||
120 | template_plugin_get_random (void *cls, | ||
121 | GNUNET_DATACACHE_Iterator iter, | ||
122 | void *iter_cls) | ||
123 | { | ||
124 | GNUNET_break (0); | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | |||
129 | /** | ||
130 | * Iterate over the results that are "close" to a particular key in | 112 | * Iterate over the results that are "close" to a particular key in |
131 | * the datacache. "close" is defined as numerically larger than @a | 113 | * the datacache. "close" is defined as numerically larger than @a |
132 | * key (when interpreted as a circular address space), with small | 114 | * key (when interpreted as a circular address space), with small |
@@ -171,7 +153,6 @@ libgnunet_plugin_datacache_template_init (void *cls) | |||
171 | api->get = &template_plugin_get; | 153 | api->get = &template_plugin_get; |
172 | api->put = &template_plugin_put; | 154 | api->put = &template_plugin_put; |
173 | api->del = &template_plugin_del; | 155 | api->del = &template_plugin_del; |
174 | api->get_random = &template_plugin_get_random; | ||
175 | api->get_closest = &template_plugin_get_closest; | 156 | api->get_closest = &template_plugin_get_closest; |
176 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, | 157 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, |
177 | "template", | 158 | "template", |
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h index 40885803b..519c36bb4 100644 --- a/src/include/gnunet_datacache_lib.h +++ b/src/include/gnunet_datacache_lib.h | |||
@@ -146,20 +146,6 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, | |||
146 | 146 | ||
147 | 147 | ||
148 | /** | 148 | /** |
149 | * Obtain a random element from the datacache. | ||
150 | * | ||
151 | * @param h handle to the datacache | ||
152 | * @param iter maybe NULL (to just count) | ||
153 | * @param iter_cls closure for @a iter | ||
154 | * @return the number of results found (zero or 1) | ||
155 | */ | ||
156 | unsigned int | ||
157 | GNUNET_DATACACHE_get_random (struct GNUNET_DATACACHE_Handle *h, | ||
158 | GNUNET_DATACACHE_Iterator iter, | ||
159 | void *iter_cls); | ||
160 | |||
161 | |||
162 | /** | ||
163 | * Iterate over the results that are "close" to a particular key in | 149 | * Iterate over the results that are "close" to a particular key in |
164 | * the datacache. "close" is defined as numerically larger than @a | 150 | * the datacache. "close" is defined as numerically larger than @a |
165 | * key (when interpreted as a circular address space), with small | 151 | * key (when interpreted as a circular address space), with small |