[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -dce
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -dce |
Date: |
Sun, 02 Jan 2022 22:10:19 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 1b39a3933 -dce
1b39a3933 is described below
commit 1b39a393307288188d790c8e89f794a136a2653f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Jan 2 22:10:16 2022 +0100
-dce
---
src/datacache/datacache.c | 83 ++------------------------
src/datacache/plugin_datacache_heap.c | 28 ---------
src/datacache/plugin_datacache_postgres.c | 99 +------------------------------
src/datacache/plugin_datacache_sqlite.c | 90 ----------------------------
src/datacache/plugin_datacache_template.c | 19 ------
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
* @param size number of bytes that were made available
*/
static void
-env_delete_notify (void *cls, const struct GNUNET_HashCode *key, size_t size)
+env_delete_notify (void *cls,
+ const struct GNUNET_HashCode *key,
+ size_t size)
{
struct GNUNET_DATACACHE_Handle *h = cls;
@@ -122,13 +124,6 @@ env_delete_notify (void *cls, const struct GNUNET_HashCode
*key, size_t size)
}
-/**
- * Create a data cache.
- *
- * @param cfg configuration to use
- * @param section section in the configuration that contains our options
- * @return handle to use to access the service
- */
struct GNUNET_DATACACHE_Handle *
GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
const char *section)
@@ -193,9 +188,9 @@ GNUNET_DATACACHE_create (const struct
GNUNET_CONFIGURATION_Handle *cfg,
ret->lib_name = libname;
/* Load the plugin within GNUnet's default context */
pd = GNUNET_OS_project_data_get ();
- GNUNET_OS_init(GNUNET_OS_project_data_default ());
+ GNUNET_OS_init (GNUNET_OS_project_data_default ());
ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
- GNUNET_OS_init(pd);
+ GNUNET_OS_init (pd);
if (NULL == ret->api)
{
/* Try to load the plugin within the application's context
@@ -215,11 +210,6 @@ GNUNET_DATACACHE_create (const struct
GNUNET_CONFIGURATION_Handle *cfg,
}
-/**
- * Destroy a data cache (and free associated resources).
- *
- * @param h handle to the datastore
- */
void
GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h)
{
@@ -244,21 +234,7 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle
*h)
}
-/**
- * Store an item in the datastore.
- *
- * @param h handle to the datacache
- * @param key key to store data under
- * @param xor_distance distance of @a key to our PID
- * @param data_size number of bytes in @a data
- * @param data data to store
- * @param type type of the value
- * @param discard_time when to discard the value in any case
- * @param path_info_len number of entries in @a path_info
- * @param path_info a path through the network
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error, #GNUNET_NO if
duplicate
- */
-int
+enum GNUNET_GenericReturnValue
GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
const struct GNUNET_HashCode *key,
uint32_t xor_distance,
@@ -310,17 +286,6 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
}
-/**
- * Iterate over the results for a particular key
- * in the datacache.
- *
- * @param h handle to the datacache
- * @param key what to look up
- * @param type entries of which type are relevant?
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for @a iter
- * @return the number of results found
- */
unsigned int
GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
const struct GNUNET_HashCode *key,
@@ -352,42 +317,6 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
}
-/**
- * Obtain a random element from the datacache.
- *
- * @param h handle to the datacache
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for @a iter
- * @return the number of results found (zero or 1)
- */
-unsigned int
-GNUNET_DATACACHE_get_random (struct GNUNET_DATACACHE_Handle *h,
- GNUNET_DATACACHE_Iterator iter,
- void *iter_cls)
-{
- GNUNET_STATISTICS_update (h->stats,
- gettext_noop (
- "# requests for random value received"),
- 1,
- GNUNET_NO);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for random value\n");
- return h->api->get_random (h->api->cls, iter, iter_cls);
-}
-
-
-/**
- * Iterate over the results that are "close" to a particular key in
- * the datacache. "close" is defined as numerically larger than @a
- * key (when interpreted as a circular address space), with small
- * distance.
- *
- * @param h handle to the datacache
- * @param key area of the keyspace to look into
- * @param num_results number of results that should be returned to @a iter
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for @a iter
- * @return the number of results found
- */
unsigned int
GNUNET_DATACACHE_get_closest (struct GNUNET_DATACACHE_Handle *h,
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
@@ -401,33 +401,6 @@ heap_plugin_del (void *cls)
}
-/**
- * Return a random value from the datastore.
- *
- * @param cls closure (our `struct Plugin`)
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for @a iter
- * @return the number of results found
- */
-static unsigned int
-heap_plugin_get_random (void *cls,
- GNUNET_DATACACHE_Iterator iter,
- void *iter_cls)
-{
- struct Plugin *plugin = cls;
- struct GetContext get_ctx;
-
- get_ctx.type = GNUNET_BLOCK_TYPE_ANY;
- get_ctx.iter = iter;
- get_ctx.iter_cls = iter_cls;
- get_ctx.cnt = 0;
- GNUNET_CONTAINER_multihashmap_get_random (plugin->map,
- &get_cb,
- &get_ctx);
- return get_ctx.cnt;
-}
-
-
/**
* Closure for #find_closest().
*/
@@ -548,7 +521,6 @@ libgnunet_plugin_datacache_heap_init (void *cls)
api->get = &heap_plugin_get;
api->put = &heap_plugin_put;
api->del = &heap_plugin_del;
- api->get_random = &heap_plugin_get_random;
api->get_closest = &heap_plugin_get_closest;
LOG (GNUNET_ERROR_TYPE_INFO,
_ ("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
init_connection (struct Plugin *plugin)
{
struct GNUNET_PQ_ExecuteStatement es[] = {
- GNUNET_PQ_make_try_execute ("CREATE TEMPORARY SEQUENCE IF NOT EXISTS
gn011dc_oid_seq"),
+ GNUNET_PQ_make_try_execute (
+ "CREATE TEMPORARY SEQUENCE IF NOT EXISTS gn011dc_oid_seq"),
GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS gn011dc ("
" oid OID NOT NULL DEFAULT
nextval('gn011dc_oid_seq'),"
" type INTEGER NOT NULL,"
@@ -107,11 +108,6 @@ init_connection (struct Plugin *plugin)
"SELECT length(value) AS len,oid,key FROM gn011dc"
" ORDER BY prox ASC, discard_time ASC LIMIT 1",
0),
- GNUNET_PQ_make_prepare ("get_random",
- "SELECT discard_time,type,value,path,key FROM
gn011dc"
- " WHERE discard_time >= $1"
- " ORDER BY key ASC LIMIT 1 OFFSET $2",
- 2),
GNUNET_PQ_make_prepare ("get_closest",
"SELECT discard_time,type,value,path,key FROM
gn011dc "
"WHERE key>=$1 AND discard_time >= $2 ORDER BY key
ASC LIMIT $3",
@@ -409,96 +405,6 @@ postgres_plugin_del (void *cls)
}
-/**
- * Obtain a random key-value pair from the datacache.
- *
- * @param cls closure (our `struct Plugin`)
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for @a iter
- * @return the number of results found, zero (datacache empty) or one
- */
-static unsigned int
-postgres_plugin_get_random (void *cls,
- GNUNET_DATACACHE_Iterator iter,
- void *iter_cls)
-{
- struct Plugin *plugin = cls;
- uint32_t off;
- struct GNUNET_TIME_Absolute now = { 0 };
- struct GNUNET_TIME_Absolute expiration_time;
- size_t data_size;
- void *data;
- size_t path_len;
- struct GNUNET_PeerIdentity *path;
- struct GNUNET_HashCode key;
- uint32_t type;
- enum GNUNET_DB_QueryStatus res;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_absolute_time (&now),
- GNUNET_PQ_query_param_uint32 (&off),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_absolute_time ("discard_time",
- &expiration_time),
- GNUNET_PQ_result_spec_uint32 ("type",
- &type),
- GNUNET_PQ_result_spec_variable_size ("value",
- &data,
- &data_size),
- GNUNET_PQ_result_spec_variable_size ("path",
- (void **) &path,
- &path_len),
- GNUNET_PQ_result_spec_auto_from_type ("key",
- &key),
- GNUNET_PQ_result_spec_end
- };
-
- if (0 == plugin->num_items)
- return 0;
- if (NULL == iter)
- return 1;
- now = GNUNET_TIME_absolute_get ();
- off = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
- plugin->num_items);
- res = GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh,
- "get_random",
- params,
- rs);
- if (0 > res)
- {
- GNUNET_break (0);
- return 0;
- }
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == res)
- {
- GNUNET_break (0);
- return 0;
- }
- if (0 != (path_len % sizeof(struct GNUNET_PeerIdentity)))
- {
- GNUNET_break (0);
- path_len = 0;
- }
- path_len %= sizeof(struct GNUNET_PeerIdentity);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Found random value with key %s of size %u bytes and type %u in
database\n",
- GNUNET_h2s (&key),
- (unsigned int) data_size,
- (unsigned int) type);
- (void) iter (iter_cls,
- &key,
- data_size,
- data,
- (enum GNUNET_BLOCK_Type) type,
- expiration_time,
- path_len,
- path);
- GNUNET_PQ_cleanup_result (rs);
- return 1;
-}
-
-
/**
* Closure for #extract_result_cb.
*/
@@ -681,7 +587,6 @@ libgnunet_plugin_datacache_postgres_init (void *cls)
api->get = &postgres_plugin_get;
api->put = &postgres_plugin_put;
api->del = &postgres_plugin_del;
- api->get_random = &postgres_plugin_get_random;
api->get_closest = &postgres_plugin_get_closest;
LOG (GNUNET_ERROR_TYPE_INFO,
"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
@@ -91,11 +91,6 @@ struct Plugin
*/
sqlite3_stmt *del_stmt;
- /**
- * Prepared statement for #sqlite_plugin_get_random.
- */
- sqlite3_stmt *get_random_stmt;
-
/**
* Prepared statement for #sqlite_plugin_get_closest.
*/
@@ -451,85 +446,6 @@ sqlite_plugin_del (void *cls)
}
-/**
- * Obtain a random key-value pair from the datacache.
- *
- * @param cls closure (our `struct Plugin`)
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for @a iter
- * @return the number of results found, zero (datacache empty) or one
- */
-static unsigned int
-sqlite_plugin_get_random (void *cls,
- GNUNET_DATACACHE_Iterator iter,
- void *iter_cls)
-{
- struct Plugin *plugin = cls;
- struct GNUNET_TIME_Absolute exp;
- size_t size;
- void *dat;
- uint32_t off = 0;
- size_t psize;
- uint32_t type;
- struct GNUNET_PeerIdentity *path;
- struct GNUNET_HashCode key;
- struct GNUNET_SQ_QueryParam params[] = { GNUNET_SQ_query_param_uint32 (&off),
- GNUNET_SQ_query_param_end };
- struct GNUNET_SQ_ResultSpec rs[] =
- { GNUNET_SQ_result_spec_variable_size (&dat, &size),
- GNUNET_SQ_result_spec_absolute_time (&exp),
- GNUNET_SQ_result_spec_variable_size ((void **) &path, &psize),
- GNUNET_SQ_result_spec_auto_from_type (&key),
- GNUNET_SQ_result_spec_uint32 (&type),
- GNUNET_SQ_result_spec_end };
-
- if (0 == plugin->num_items)
- return 0;
- if (NULL == iter)
- return 1;
- off =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, plugin->num_items);
- if (GNUNET_OK != GNUNET_SQ_bind (plugin->get_random_stmt, params))
- {
- return 0;
- }
- if (SQLITE_ROW != sqlite3_step (plugin->get_random_stmt))
- {
- GNUNET_break (0);
- GNUNET_SQ_reset (plugin->dbh, plugin->get_random_stmt);
- return 0;
- }
- if (GNUNET_OK != GNUNET_SQ_extract_result (plugin->get_random_stmt, rs))
- {
- GNUNET_break (0);
- GNUNET_SQ_reset (plugin->dbh, plugin->get_random_stmt);
- return 0;
- }
- if (0 != psize % sizeof(struct GNUNET_PeerIdentity))
- {
- GNUNET_break (0);
- psize = 0;
- path = NULL;
- }
- psize /= sizeof(struct GNUNET_PeerIdentity);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Found %u-byte result with key %s when processing GET-RANDOM\n",
- (unsigned int) size,
- GNUNET_h2s (&key));
- (void) iter (iter_cls,
- &key,
- size,
- dat,
- (enum GNUNET_BLOCK_Type) type,
- exp,
- psize,
- path);
- GNUNET_SQ_cleanup_result (rs);
- GNUNET_SQ_reset (plugin->dbh, plugin->get_random_stmt);
- return 1;
-}
-
-
/**
* Iterate over the results that are "close" to a particular key in
* the datacache. "close" is defined as numerically larger than @a
@@ -714,10 +630,6 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
(SQLITE_OK != sq_prepare (plugin->dbh,
"DELETE FROM ds091 WHERE _ROWID_=?",
&plugin->del_stmt)) ||
- (SQLITE_OK != sq_prepare (plugin->dbh,
- "SELECT value,expire,path,key,type FROM ds091 "
- "ORDER BY key LIMIT 1 OFFSET ?",
- &plugin->get_random_stmt)) ||
(SQLITE_OK !=
sq_prepare (plugin->dbh,
"SELECT value,expire,path,type,key FROM ds091 "
@@ -737,7 +649,6 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
api->get = &sqlite_plugin_get;
api->put = &sqlite_plugin_put;
api->del = &sqlite_plugin_del;
- api->get_random = &sqlite_plugin_get_random;
api->get_closest = &sqlite_plugin_get_closest;
LOG (GNUNET_ERROR_TYPE_INFO, "Sqlite datacache running\n");
return api;
@@ -772,7 +683,6 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
sqlite3_finalize (plugin->del_select_stmt);
sqlite3_finalize (plugin->del_expired_stmt);
sqlite3_finalize (plugin->del_stmt);
- sqlite3_finalize (plugin->get_random_stmt);
sqlite3_finalize (plugin->get_closest_stmt);
result = sqlite3_close (plugin->dbh);
#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
@@ -108,24 +108,6 @@ template_plugin_del (void *cls)
}
-/**
- * Return a random value from the datastore.
- *
- * @param cls closure (internal context for the plugin)
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for @a iter
- * @return the number of results found (zero or one)
- */
-static unsigned int
-template_plugin_get_random (void *cls,
- GNUNET_DATACACHE_Iterator iter,
- void *iter_cls)
-{
- GNUNET_break (0);
- return 0;
-}
-
-
/**
* Iterate over the results that are "close" to a particular key in
* the datacache. "close" is defined as numerically larger than @a
@@ -171,7 +153,6 @@ libgnunet_plugin_datacache_template_init (void *cls)
api->get = &template_plugin_get;
api->put = &template_plugin_put;
api->del = &template_plugin_del;
- api->get_random = &template_plugin_get_random;
api->get_closest = &template_plugin_get_closest;
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
"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
@@ -145,20 +145,6 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
void *iter_cls);
-/**
- * Obtain a random element from the datacache.
- *
- * @param h handle to the datacache
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for @a iter
- * @return the number of results found (zero or 1)
- */
-unsigned int
-GNUNET_DATACACHE_get_random (struct GNUNET_DATACACHE_Handle *h,
- GNUNET_DATACACHE_Iterator iter,
- void *iter_cls);
-
-
/**
* Iterate over the results that are "close" to a particular key in
* the datacache. "close" is defined as numerically larger than @a
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -dce,
gnunet <=