flat file-based peerstore backend More...
#include "platform.h"
#include "gnunet_peerstore_plugin.h"
#include "gnunet_peerstore_service.h"
#include "peerstore.h"
Go to the source code of this file.
Data Structures | |
struct | Plugin |
Handle for a plugin. More... | |
Functions | |
static int | delete_entries (void *cls, const struct GNUNET_HashCode *key, void *value) |
static int | peerstore_flat_delete_records (void *cls, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key) |
Delete records with the given key. More... | |
static int | expire_entries (void *cls, const struct GNUNET_HashCode *key, void *value) |
static int | peerstore_flat_expire_records (void *cls, struct GNUNET_TIME_Absolute now, GNUNET_PEERSTORE_Continuation cont, void *cont_cls) |
Delete expired records (expiry < now) More... | |
static int | iterate_entries (void *cls, const struct GNUNET_HashCode *key, void *value) |
static int | peerstore_flat_iterate_records (void *cls, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_PEERSTORE_Processor iter, void *iter_cls) |
Iterate over the records given an optional peer id and/or key. More... | |
static int | peerstore_flat_store_record (void *cls, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, const void *value, size_t size, struct GNUNET_TIME_Absolute expiry, enum GNUNET_PEERSTORE_StoreOption options, GNUNET_PEERSTORE_Continuation cont, void *cont_cls) |
Store a record in the peerstore. More... | |
static int | database_setup (struct Plugin *plugin) |
Initialize the database connections and associated data structures (create tables and indices as needed as well). More... | |
static int | store_and_free_entries (void *cls, const struct GNUNET_HashCode *key, void *value) |
static void | database_shutdown (struct Plugin *plugin) |
Shutdown database connection and associate data structures. More... | |
void * | libgnunet_plugin_peerstore_flat_init (void *cls) |
Entry point for the plugin. More... | |
void * | libgnunet_plugin_peerstore_flat_done (void *cls) |
Exit point from the plugin. More... | |
flat file-based peerstore backend
Definition in file plugin_peerstore_flat.c.
|
static |
Definition at line 100 of file plugin_peerstore_flat.c.
References GNUNET_CONTAINER_multihashmap_remove(), GNUNET_YES, key, GNUNET_PEERSTORE_Record::key, GNUNET_PEERSTORE_Record::peer, plugin, GNUNET_PEERSTORE_Record::sub_system, and value.
Referenced by peerstore_flat_delete_records().
|
static |
Delete records with the given key.
cls | closure (internal context for the plugin) |
sub_system | name of sub system |
peer | Peer identity (can be NULL) |
key | entry key string (can be NULL) |
Definition at line 132 of file plugin_peerstore_flat.c.
References delete_entries(), GNUNET_CONTAINER_multihashmap_iterate(), key, peer, and plugin.
Referenced by peerstore_flat_store_record().
|
static |
Definition at line 151 of file plugin_peerstore_flat.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_PEERSTORE_Record::expiry, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_YES, key, plugin, and value.
Referenced by peerstore_flat_expire_records().
|
static |
Delete expired records (expiry < now)
cls | closure (internal context for the plugin) |
now | time to use as reference |
cont | continuation called with the number of records expired |
cont_cls | continuation closure |
Definition at line 178 of file plugin_peerstore_flat.c.
References expire_entries(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_OK, and plugin.
Referenced by libgnunet_plugin_peerstore_flat_init().
|
static |
Definition at line 199 of file plugin_peerstore_flat.c.
References GNUNET_YES, GNUNET_PEERSTORE_Record::key, GNUNET_PEERSTORE_Record::peer, plugin, and value.
Referenced by peerstore_flat_iterate_records().
|
static |
Iterate over the records given an optional peer id and/or key.
cls | closure (internal context for the plugin) |
sub_system | name of sub system |
peer | Peer identity (can be NULL) |
key | entry key string (can be NULL) |
iter | function to call asynchronously with the results, terminated by a NULL result |
iter_cls | closure for iter |
Definition at line 241 of file plugin_peerstore_flat.c.
References GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_OK, Plugin::iter, Plugin::iter_cls, iterate_entries(), key, peer, and plugin.
Referenced by libgnunet_plugin_peerstore_flat_init().
|
static |
Store a record in the peerstore.
Key is the combination of sub system and peer identity. One key can store multiple values.
cls | closure (internal context for the plugin) |
sub_system | name of the GNUnet sub system responsible |
peer | peer identity |
key | record key string |
value | value to be stored |
size | size of value to be stored |
expiry | absolute time after which the record is (possibly) deleted |
options | options related to the store operation |
cont | continuation called when record is stored |
cont_cls | continuation closure |
Definition at line 282 of file plugin_peerstore_flat.c.
References GNUNET_PEERSTORE_Record::expiry, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_hash(), GNUNET_i2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_PEERSTORE_STOREOPTION_REPLACE, GNUNET_strdup, key, GNUNET_PEERSTORE_Record::key, options, GNUNET_PEERSTORE_Record::peer, peer, peer_id, peerstore_flat_delete_records(), plugin, size, GNUNET_PEERSTORE_Record::sub_system, GNUNET_PEERSTORE_Record::value, value, and GNUNET_PEERSTORE_Record::value_size.
Referenced by libgnunet_plugin_peerstore_flat_init().
|
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 336 of file plugin_peerstore_flat.c.
References _, GNUNET_PEERSTORE_Record::expiry, fh, GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_hash(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_size(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_log_config_missing(), GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_base64_decode(), GNUNET_STRINGS_fancy_time_to_absolute(), GNUNET_SYSERR, GNUNET_YES, key, GNUNET_PEERSTORE_Record::key, line, GNUNET_PEERSTORE_Record::peer, peer, peer_id, plugin, size, GNUNET_PEERSTORE_Record::sub_system, GNUNET_PEERSTORE_Record::value, value, and GNUNET_PEERSTORE_Record::value_size.
Referenced by libgnunet_plugin_peerstore_flat_init().
|
static |
Definition at line 484 of file plugin_peerstore_flat.c.
References GNUNET_PEERSTORE_Record::expiry, fh, GNUNET_asprintf(), GNUNET_DISK_file_write(), GNUNET_free, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_base64_encode(), GNUNET_YES, GNUNET_PEERSTORE_Record::key, line, GNUNET_PEERSTORE_Record::peer, peer, GNUNET_PEERSTORE_Record::sub_system, GNUNET_PEERSTORE_Record::value, value, and GNUNET_PEERSTORE_Record::value_size.
Referenced by database_shutdown().
|
static |
Shutdown database connection and associate data structures.
plugin | the plugin context (state for this module) |
Definition at line 529 of file plugin_peerstore_flat.c.
References _, fh, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, plugin, and store_and_free_entries().
Referenced by libgnunet_plugin_peerstore_flat_done(), and libgnunet_plugin_peerstore_flat_init().
void* libgnunet_plugin_peerstore_flat_init | ( | void * | cls | ) |
Entry point for the plugin.
cls | The struct GNUNET_CONFIGURATION_Handle. |
Definition at line 561 of file plugin_peerstore_flat.c.
References cfg, GNUNET_PEERSTORE_PluginFunctions::cls, database_setup(), database_shutdown(), GNUNET_PEERSTORE_PluginFunctions::expire_records, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_PEERSTORE_PluginFunctions::iterate_records, peerstore_flat_expire_records(), peerstore_flat_iterate_records(), peerstore_flat_store_record(), plugin, and GNUNET_PEERSTORE_PluginFunctions::store_record.
void* libgnunet_plugin_peerstore_flat_done | ( | void * | cls | ) |
Exit point from the plugin.
cls | The plugin context (as returned by "init") |
Definition at line 593 of file plugin_peerstore_flat.c.
References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_PEERSTORE_PluginFunctions::cls, database_shutdown(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and plugin.