postgres-based namecache backend More...
#include "platform.h"
#include "gnunet_namecache_plugin.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_pq_lib.h"
Go to the source code of this file.
Data Structures | |
struct | Plugin |
Handle for a plugin. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "namecache-postgres", __VA_ARGS__) |
Functions | |
static enum GNUNET_GenericReturnValue | database_setup (struct Plugin *plugin) |
Initialize the database connections and associated data structures (create tables and indices as needed as well). More... | |
static void | namecache_postgres_expire_blocks (struct Plugin *plugin) |
Removes any expired block. More... | |
static void | delete_old_block (struct Plugin *plugin, const struct GNUNET_HashCode *query, struct GNUNET_TIME_Absolute expiration_time) |
Delete older block in the datastore. More... | |
static enum GNUNET_GenericReturnValue | namecache_postgres_cache_block (void *cls, const struct GNUNET_GNSRECORD_Block *block) |
Cache a block in the datastore. More... | |
static enum GNUNET_GenericReturnValue | namecache_postgres_lookup_block (void *cls, const struct GNUNET_HashCode *query, GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls) |
Get the block for a particular zone and label in the datastore. More... | |
static void | database_shutdown (struct Plugin *plugin) |
Shutdown database connection and associate data structures. More... | |
void * | libgnunet_plugin_namecache_postgres_init (void *cls) |
Entry point for the plugin. More... | |
void * | libgnunet_plugin_namecache_postgres_done (void *cls) |
Exit point from the plugin. More... | |
postgres-based namecache backend
Definition in file plugin_namecache_postgres.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "namecache-postgres", __VA_ARGS__) |
Definition at line 32 of file plugin_namecache_postgres.c.
|
static |
Initialize the database connections and associated data structures (create tables and indices as needed as well).
plugin | the plugin context (state for this module) |
Definition at line 58 of file plugin_namecache_postgres.c.
References GNUNET_OK, GNUNET_PQ_connect_with_cfg(), GNUNET_PQ_make_prepare(), GNUNET_PQ_PREPARED_STATEMENT_END, GNUNET_SYSERR, plugin, and ps.
Referenced by libgnunet_plugin_namecache_postgres_init().
|
static |
Removes any expired block.
plugin | the plugin |
Definition at line 97 of file plugin_namecache_postgres.c.
References GNUNET_break, GNUNET_DB_STATUS_HARD_ERROR, GNUNET_PQ_eval_prepared_non_select(), GNUNET_PQ_query_param_absolute_time(), GNUNET_PQ_query_param_end, GNUNET_TIME_absolute_get(), plugin, and res.
Referenced by namecache_postgres_cache_block().
|
static |
Delete older block in the datastore.
plugin | the plugin |
query | query for the block |
expiration_time | how old does the block have to be for deletion |
Definition at line 121 of file plugin_namecache_postgres.c.
References GNUNET_break, GNUNET_DB_STATUS_HARD_ERROR, GNUNET_PQ_eval_prepared_non_select(), GNUNET_PQ_query_param_absolute_time(), GNUNET_PQ_query_param_auto_from_type, GNUNET_PQ_query_param_end, plugin, and res.
Referenced by namecache_postgres_cache_block().
|
static |
Cache a block in the datastore.
cls | closure (internal context for the plugin) |
block | block to cache |
Definition at line 147 of file plugin_namecache_postgres.c.
References delete_old_block(), GNUNET_break, GNUNET_GNSRECORD_block_get_expiration(), GNUNET_GNSRECORD_block_get_size(), GNUNET_GNSRECORD_query_from_block(), GNUNET_OK, GNUNET_PQ_eval_prepared_non_select(), GNUNET_PQ_query_param_absolute_time(), GNUNET_PQ_query_param_auto_from_type, GNUNET_PQ_query_param_end, GNUNET_PQ_query_param_fixed_size(), GNUNET_SYSERR, namecache_postgres_expire_blocks(), plugin, and res.
Referenced by libgnunet_plugin_namecache_postgres_init().
|
static |
Get the block for a particular zone and label in the datastore.
Will return at most one result to the iterator.
cls | closure (internal context for the plugin) |
query | hash of public key derived from the zone and the label |
iter | function to call with the result |
iter_cls | closure for iter |
Definition at line 194 of file plugin_namecache_postgres.c.
References bsize, GNUNET_break, GNUNET_DB_STATUS_SUCCESS_NO_RESULTS, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_NO, GNUNET_OK, GNUNET_PQ_cleanup_result(), GNUNET_PQ_eval_prepared_singleton_select(), GNUNET_PQ_query_param_auto_from_type, GNUNET_PQ_query_param_end, GNUNET_PQ_result_spec_end, GNUNET_PQ_result_spec_variable_size(), GNUNET_SYSERR, LOG, plugin, and res.
Referenced by libgnunet_plugin_namecache_postgres_init().
|
static |
Shutdown database connection and associate data structures.
plugin | the plugin context (state for this module) |
Definition at line 253 of file plugin_namecache_postgres.c.
References GNUNET_PQ_disconnect(), and plugin.
Referenced by libgnunet_plugin_namecache_postgres_done(), and libgnunet_plugin_namecache_postgres_init().
void * libgnunet_plugin_namecache_postgres_init | ( | void * | cls | ) |
Entry point for the plugin.
cls | the struct GNUNET_NAMECACHE_PluginEnvironment * |
Definition at line 269 of file plugin_namecache_postgres.c.
References GNUNET_NAMECACHE_PluginFunctions::cache_block, cfg, GNUNET_NAMECACHE_PluginFunctions::cls, database_setup(), database_shutdown(), GNUNET_ERROR_TYPE_INFO, GNUNET_new, GNUNET_OK, LOG, GNUNET_NAMECACHE_PluginFunctions::lookup_block, namecache_postgres_cache_block(), namecache_postgres_lookup_block(), and plugin.
void * libgnunet_plugin_namecache_postgres_done | ( | void * | cls | ) |
Exit point from the plugin.
cls | the plugin context (as returned by "init") |
Definition at line 303 of file plugin_namecache_postgres.c.
References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_NAMECACHE_PluginFunctions::cls, database_shutdown(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, LOG, and plugin.