![]() |
GNUnet
0.11.x
|
Simple, transient hash table of bounded size with content expiration. More...
Typedefs | |
typedef int(* | GNUNET_DATACACHE_Iterator) (void *cls, const struct GNUNET_HashCode *key, size_t data_size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute exp, unsigned int path_info_len, const struct GNUNET_PeerIdentity *path_info) |
An iterator over a set of items stored in the datacache. More... | |
Functions | |
struct GNUNET_DATACACHE_Handle * | GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section) |
Create a data cache. More... | |
void | GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) |
Destroy a data cache (and free associated resources). More... | |
int | GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, const struct GNUNET_HashCode *key, uint32_t xor_distance, size_t data_size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time, unsigned int path_info_len, const struct GNUNET_PeerIdentity *path_info) |
Store an item in the datacache. More... | |
unsigned int | GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, void *iter_cls) |
Iterate over the results for a particular key in the datacache. More... | |
unsigned int | GNUNET_DATACACHE_get_random (struct GNUNET_DATACACHE_Handle *h, GNUNET_DATACACHE_Iterator iter, void *iter_cls) |
Obtain a random element from the datacache. More... | |
unsigned int | GNUNET_DATACACHE_get_closest (struct GNUNET_DATACACHE_Handle *h, const struct GNUNET_HashCode *key, unsigned int num_results, GNUNET_DATACACHE_Iterator iter, void *iter_cls) |
Iterate over the results that are "close" to a particular key in the datacache. More... | |
Simple, transient hash table of bounded size with content expiration.
In contrast to the sqstore there is no prioritization, deletion or iteration. All of the data is discarded when the peer shuts down!
typedef int(* GNUNET_DATACACHE_Iterator) (void *cls, const struct GNUNET_HashCode *key, size_t data_size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute exp, unsigned int path_info_len, const struct GNUNET_PeerIdentity *path_info) |
An iterator over a set of items stored in the datacache.
cls | closure |
key | key for the content |
data_size | number of bytes in data |
data | content stored |
type | type of the content |
exp | when will the content expire? |
path_info_len | number of entries in path_info |
path_info | a path through the network |
Definition at line 93 of file gnunet_datacache_lib.h.
struct GNUNET_DATACACHE_Handle* GNUNET_DATACACHE_create | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
const char * | section | ||
) |
Create a data cache.
cfg | configuration to use |
section | section in the configuration that contains our options |
Definition at line 133 of file datacache.c.
References _, GNUNET_DATACACHE_Handle::api, GNUNET_DATACACHE_Handle::bloom_name, GNUNET_DATACACHE_Handle::cfg, GNUNET_DATACACHE_PluginEnvironment::cfg, GNUNET_DATACACHE_PluginEnvironment::cls, GNUNET_DATACACHE_PluginEnvironment::delete_notify, GNUNET_DATACACHE_Handle::env, env_delete_notify(), GNUNET_DATACACHE_Handle::filter, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_size(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_bloomfilter_init(), GNUNET_CONTAINER_bloomfilter_load(), GNUNET_DATACACHE_destroy(), GNUNET_DISK_mktemp(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log_config_missing(), GNUNET_new, GNUNET_OK, GNUNET_PLUGIN_load(), GNUNET_STATISTICS_create(), GNUNET_strdup, GNUNET_YES, GNUNET_DATACACHE_Handle::lib_name, LOG, name, GNUNET_DATACACHE_PluginEnvironment::quota, quota, ret, GNUNET_DATACACHE_Handle::section, GNUNET_DATACACHE_PluginEnvironment::section, GNUNET_DATACACHE_Handle::short_name, and GNUNET_DATACACHE_Handle::stats.
Referenced by GDS_DATACACHE_init().
void GNUNET_DATACACHE_destroy | ( | struct GNUNET_DATACACHE_Handle * | h | ) |
Destroy a data cache (and free associated resources).
h | handle to the datastore |
Definition at line 212 of file datacache.c.
References GNUNET_DATACACHE_Handle::api, GNUNET_DATACACHE_Handle::bloom_name, GNUNET_DATACACHE_Handle::filter, GNUNET_break, GNUNET_CONTAINER_bloomfilter_free(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_from_strerror_file, GNUNET_NO, GNUNET_PLUGIN_unload(), GNUNET_STATISTICS_destroy(), GNUNET_DATACACHE_Handle::lib_name, GNUNET_DATACACHE_Handle::section, GNUNET_DATACACHE_Handle::short_name, and GNUNET_DATACACHE_Handle::stats.
Referenced by GDS_DATACACHE_done(), and GNUNET_DATACACHE_create().
int GNUNET_DATACACHE_put | ( | struct GNUNET_DATACACHE_Handle * | h, |
const struct GNUNET_HashCode * | key, | ||
uint32_t | xor_distance, | ||
size_t | data_size, | ||
const char * | data, | ||
enum GNUNET_BLOCK_Type | type, | ||
struct GNUNET_TIME_Absolute | discard_time, | ||
unsigned int | path_info_len, | ||
const struct GNUNET_PeerIdentity * | path_info | ||
) |
Store an item in the datacache.
h | handle to the datacache |
key | key to store data under |
how | close is key to our pid? |
data_size | number of bytes in data |
data | data to store |
type | type of the value |
discard_time | when to discard the value in any case |
path_info_len | number of entries in path_info |
path_info | a path through the network |
Store an item in the datacache.
h | handle to the datacache |
key | key to store data under |
xor_distance | distance of key to our PID |
data_size | number of bytes in data |
data | data to store |
type | type of the value |
discard_time | when to discard the value in any case |
path_info_len | number of entries in path_info |
path_info | a path through the network |
Definition at line 250 of file datacache.c.
References GNUNET_DATACACHE_Handle::api, GNUNET_DATACACHE_PluginFunctions::cls, GNUNET_DATACACHE_PluginFunctions::del, GNUNET_DATACACHE_Handle::env, GNUNET_DATACACHE_Handle::filter, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_bloomfilter_add(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, LOG, GNUNET_DATACACHE_PluginFunctions::put, GNUNET_DATACACHE_PluginEnvironment::quota, GNUNET_DATACACHE_Handle::stats, and GNUNET_DATACACHE_Handle::utilization.
Referenced by GDS_DATACACHE_handle_put().
unsigned int GNUNET_DATACACHE_get | ( | struct GNUNET_DATACACHE_Handle * | h, |
const struct GNUNET_HashCode * | key, | ||
enum GNUNET_BLOCK_Type | type, | ||
GNUNET_DATACACHE_Iterator | iter, | ||
void * | iter_cls | ||
) |
Iterate over the results for a particular key in the datacache.
h | handle to the datacache |
key | what to look up |
type | entries of which type are relevant? |
iter | maybe NULL (to just count) |
iter_cls | closure for iter |
Definition at line 313 of file datacache.c.
References GNUNET_DATACACHE_Handle::api, GNUNET_DATACACHE_PluginFunctions::cls, GNUNET_DATACACHE_Handle::filter, GNUNET_DATACACHE_PluginFunctions::get, gettext_noop, GNUNET_CONTAINER_bloomfilter_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), LOG, and GNUNET_DATACACHE_Handle::stats.
Referenced by GDS_DATACACHE_handle_get().
unsigned int GNUNET_DATACACHE_get_random | ( | struct GNUNET_DATACACHE_Handle * | h, |
GNUNET_DATACACHE_Iterator | iter, | ||
void * | iter_cls | ||
) |
Obtain a random element from the datacache.
h | handle to the datacache |
iter | maybe NULL (to just count) |
iter_cls | closure for iter |
Definition at line 352 of file datacache.c.
References GNUNET_DATACACHE_Handle::api, GNUNET_DATACACHE_PluginFunctions::cls, GNUNET_DATACACHE_PluginFunctions::get_random, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, and GNUNET_DATACACHE_Handle::stats.
Referenced by GDS_DATACACHE_get_random_key().
unsigned int GNUNET_DATACACHE_get_closest | ( | struct GNUNET_DATACACHE_Handle * | h, |
const struct GNUNET_HashCode * | key, | ||
unsigned int | num_results, | ||
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 key (when interpreted as a circular address space), with small distance.
h | handle to the datacache |
key | area of the keyspace to look into |
num_results | number of results that should be returned to iter |
iter | maybe NULL (to just count) |
iter_cls | closure for iter |
Definition at line 380 of file datacache.c.
References GNUNET_DATACACHE_Handle::api, GNUNET_DATACACHE_PluginFunctions::cls, GNUNET_DATACACHE_PluginFunctions::get_closest, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_STATISTICS_update(), LOG, and GNUNET_DATACACHE_Handle::stats.
Referenced by GDS_DATACACHE_get_successors().