![]() |
GNUnet
0.11.x
|
heap-only implementation of a database backend for the datacache More...
Go to the source code of this file.
Data Structures | |
struct | Plugin |
Handle for a plugin. More... | |
struct | Value |
Entry in the hash map. More... | |
struct | PutContext |
Closure for put_cb(). More... | |
struct | GetContext |
Closure for get_cb(). More... | |
struct | GetClosestContext |
Closure for find_closest(). More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "datacache-heap", __VA_ARGS__) |
#define | LOG_STRERROR_FILE(kind, op, fn) |
#define | NUM_HEAPS 24 |
#define | OVERHEAD (sizeof(struct Value) + 64) |
Functions | |
static enum GNUNET_GenericReturnValue | put_cb (void *cls, const struct GNUNET_HashCode *key, void *value) |
Function called during PUT to detect if an equivalent block already exists. More... | |
static ssize_t | heap_plugin_put (void *cls, const struct GNUNET_HashCode *key, uint32_t xor_distance, size_t size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time, unsigned int path_info_len, const struct GNUNET_DHT_PathElement *path_info) |
Store an item in the datastore. More... | |
static int | get_cb (void *cls, const struct GNUNET_HashCode *key, void *value) |
Function called during GET to find matching blocks. More... | |
static unsigned int | heap_plugin_get (void *cls, 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 datastore. More... | |
static int | heap_plugin_del (void *cls) |
Delete the entry with the lowest expiration value from the datacache right now. More... | |
static enum GNUNET_GenericReturnValue | find_closest (void *cls, const struct GNUNET_HashCode *key, void *value) |
static unsigned int | heap_plugin_get_closest (void *cls, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, 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... | |
void * | libgnunet_plugin_datacache_heap_init (void *cls) |
Entry point for the plugin. More... | |
void * | libgnunet_plugin_datacache_heap_done (void *cls) |
Exit point from the plugin. More... | |
heap-only implementation of a database backend for the datacache
Definition in file plugin_datacache_heap.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "datacache-heap", __VA_ARGS__) |
Definition at line 30 of file plugin_datacache_heap.c.
#define LOG_STRERROR_FILE | ( | kind, | |
op, | |||
fn | |||
) |
Definition at line 32 of file plugin_datacache_heap.c.
#define NUM_HEAPS 24 |
Definition at line 36 of file plugin_datacache_heap.c.
#define OVERHEAD (sizeof(struct Value) + 64) |
Definition at line 107 of file plugin_datacache_heap.c.
|
static |
Function called during PUT to detect if an equivalent block already exists.
cls | the struct PutContext |
key | the key for the value(s) |
value | an existing value |
Definition at line 1 of file plugin_datacache_heap.c.
Referenced by GNUNET_DHT_monitor_start(), and heap_plugin_put().
|
static |
Store an item in the datastore.
cls | closure (our struct Plugin ) |
key | key to store data under |
xor_distance | how close is key to our PID? |
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 215 of file plugin_datacache_heap.c.
References GNUNET_TIME_Absolute::abs_value_us, PutContext::data, data, Value::discard_time, PutContext::discard_time, Value::distance, PutContext::found, GNUNET_array_grow, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_YES, Plugin::heaps, Value::hn, Value::key, key, Plugin::map, NUM_HEAPS, OVERHEAD, Value::path_info, PutContext::path_info, Value::path_info_len, PutContext::path_info_len, plugin, put_cb(), Value::size, size, Value::type, and type.
Referenced by libgnunet_plugin_datacache_heap_init().
|
static |
Function called during GET to find matching blocks.
Only matches by type.
cls | the struct GetContext |
key | the key for the value(s) |
value | an existing value |
Definition at line 313 of file plugin_datacache_heap.c.
References GetContext::cnt, Value::discard_time, GNUNET_BLOCK_TYPE_ANY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_OK, GNUNET_TIME_absolute_is_past(), GNUNET_YES, GetContext::iter, GetContext::iter_cls, key, Value::path_info, Value::path_info_len, ret, Value::size, Value::type, GetContext::type, and value.
Referenced by GNUNET_DHT_monitor_start(), and heap_plugin_get().
|
static |
Iterate over the results for a particular key in the datastore.
cls | closure (our struct Plugin ) |
key | |
type | entries of which type are relevant? |
iter | maybe NULL (to just count) |
iter_cls | closure for iter |
Definition at line 368 of file plugin_datacache_heap.c.
References GetContext::cnt, get_cb(), GNUNET_CONTAINER_multihashmap_get_multiple(), GetContext::iter, GetContext::iter_cls, key, Plugin::map, plugin, GetContext::type, and type.
Referenced by libgnunet_plugin_datacache_heap_init().
|
static |
Delete the entry with the lowest expiration value from the datacache right now.
cls | closure (our struct Plugin ) |
Definition at line 397 of file plugin_datacache_heap.c.
Referenced by libgnunet_plugin_datacache_heap_init().
|
static |
Definition at line 397 of file plugin_datacache_heap.c.
References GNUNET_DATACACHE_PluginEnvironment::cls, GNUNET_DATACACHE_PluginEnvironment::delete_notify, Plugin::env, GNUNET_assert, GNUNET_CONTAINER_heap_remove_root(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, Plugin::heaps, Value::key, Plugin::map, NUM_HEAPS, OVERHEAD, Value::path_info, plugin, and Value::size.
Referenced by heap_plugin_get_closest().
|
static |
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.
cls | closure (internal context for the plugin) |
key | area of the keyspace to look into |
type | desired block type for the replies |
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 492 of file plugin_datacache_heap.c.
References find_closest(), GNUNET_CONTAINER_multihashmap_iterate(), key, Plugin::map, GetClosestContext::num_results, plugin, size, type, GetClosestContext::values, and values.
Referenced by libgnunet_plugin_datacache_heap_init().
void* libgnunet_plugin_datacache_heap_init | ( | void * | cls | ) |
Entry point for the plugin.
cls | closure (the struct GNUNET_DATACACHE_PluginEnvironmnet ) |
struct Plugin
) Definition at line 535 of file plugin_datacache_heap.c.
References _, Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_DATACACHE_PluginEnvironment::cls, env, Plugin::env, GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_INFO, GNUNET_new, GNUNET_YES, heap_plugin_del(), heap_plugin_get(), heap_plugin_get_closest(), heap_plugin_put(), Plugin::heaps, LOG, Plugin::map, NUM_HEAPS, and plugin.
void* libgnunet_plugin_datacache_heap_done | ( | void * | cls | ) |
Exit point from the plugin.
cls | closure (our "struct Plugin") |
Definition at line 567 of file plugin_datacache_heap.c.
References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_DATACACHE_PluginFunctions::cls, GNUNET_assert, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, Plugin::heaps, Value::key, Plugin::map, NUM_HEAPS, Value::path_info, and plugin.