188 if (NULL != estimate)
248 if (0 != memcmp (
value->data,
uc->data,
uc->size))
252 if (
value->expiration.abs_value_us !=
uc->expiration.abs_value_us)
254 value->expiration =
uc->expiration;
256 value->expiration.abs_value_us);
259 if (
value->priority > UINT32_MAX -
uc->priority)
260 value->priority = UINT32_MAX;
262 value->priority +=
uc->priority;
263 if (
value->replication > UINT32_MAX -
uc->replication)
264 value->replication = UINT32_MAX;
266 value->replication +=
uc->replication;
340 for (zabt =
plugin->zero_head; NULL != zabt; zabt = zabt->
next)
361 value->priority = priority;
391 value->expire_heap));
393 value->replication_heap));
394 if (0 ==
value->anonymity)
398 for (zabt =
plugin->zero_head; NULL != zabt; zabt = zabt->
next)
404 value->zero_anon_offset;
472 if ((uint64_t) (intptr_t) value < gc->next_uid)
474 if ((NULL != gc->
value) &&
524 if (NULL == gc.
value)
539 (uint64_t) (intptr_t) gc.
value));
568 if (
value->replication > 0)
570 value->replication--;
595 (uint64_t) (intptr_t)
value));
630 (uint64_t) (intptr_t)
value))
655 for (zabt =
plugin->zero_head; NULL != zabt; zabt = zabt->
next)
660 for (
int i = 0; i < zabt->
array_pos; ++i)
662 if ((uint64_t) (intptr_t) zabt->
array[i] < next_uid)
664 if ((NULL !=
value) &&
685 (uint64_t) (intptr_t)
value));
837 if (NULL == rc.
value)
870 unsigned long long esize;
897 _ (
"Heap database running\n"));
struct GNUNET_MQ_Envelope * env
static struct GNUNET_TESTING_PluginFunctions * plugin
Plugin to dynamically load a test case.
static unsigned int replication
Desired replication level.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
static unsigned int anonymity
static char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_FS_UnindexContext * uc
API for the database backend plugins.
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue(* PluginDatumProcessor)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid)
An processor over a set of items stored in the datastore.
void(* PluginPutCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Put continuation.
void(* PluginKeyProcessor)(void *cls, const struct GNUNET_HashCode *key, unsigned int count)
An processor over a set of keys stored in the datastore.
void(* PluginRemoveCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Remove continuation.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
void GNUNET_CONTAINER_heap_update_cost(struct GNUNET_CONTAINER_HeapNode *node, GNUNET_CONTAINER_HeapCostType new_cost)
Updates the cost of any node in the tree.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
void * GNUNET_CONTAINER_heap_walk_get_next(struct GNUNET_CONTAINER_Heap *heap)
Perform a random walk of the tree.
@ GNUNET_CONTAINER_HEAP_ORDER_MIN
Heap with the minimum cost at the root.
@ GNUNET_CONTAINER_HEAP_ORDER_MAX
Heap with the maximum cost at the root.
#define GNUNET_log_from(kind, comp,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_max(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the maximum of two absolute time values.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
static unsigned int size
Size of the "table".
static int remove_iterator(void *cls, const struct GNUNET_HashCode *key, void *val)
Obtain the matching value with the lowest uid >= next_uid.
void * libgnunet_plugin_datastore_heap_init(void *cls)
Entry point for the plugin.
static void heap_plugin_get_zero_anonymity(void *cls, uint64_t next_uid, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls)
Call the given processor on an item with zero anonymity.
static void heap_plugin_get_key(void *cls, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls)
Get one of the results for a particular key in the datastore.
static void heap_plugin_get_replication(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item for replication.
static int get_iterator(void *cls, const struct GNUNET_HashCode *key, void *val)
Obtain the matching value with the lowest uid >= next_uid.
static void heap_plugin_estimate_size(void *cls, unsigned long long *estimate)
Get an estimate of how much space the database is currently using.
static int free_value(void *cls, const struct GNUNET_HashCode *key, void *val)
Callback invoked to free all value.
static int update_iterator(void *cls, const struct GNUNET_HashCode *key, void *val)
Update the matching value.
static void heap_get_keys(void *cls, PluginKeyProcessor proc, void *proc_cls)
Get all of the keys in the datastore.
static int return_value(void *cls, const struct GNUNET_HashCode *key, void *val)
Callback invoked to call callback on each value.
void * libgnunet_plugin_datastore_heap_done(void *cls)
Exit point from the plugin.
static void heap_plugin_drop(void *cls)
Drop database.
static void heap_plugin_remove_key(void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, PluginRemoveCont cont, void *cont_cls)
Remove a particular key in the datastore.
static void heap_plugin_put(void *cls, const struct GNUNET_HashCode *key, bool absent, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, PluginPutCont cont, void *cont_cls)
Store an item in the datastore.
static void delete_value(struct Plugin *plugin, struct Value *value)
Delete the given value, removing it from the plugin's data structures.
static void heap_plugin_get_expiration(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item for expiration.
GNUNET_BLOCK_GetKeyFunction get_key
Obtain the key for a given block (if possible).
void * cls
Closure for all of the callbacks.
Handle to a node in a heap.
Internal representation of the hash map.
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure to use for all of the following callbacks (except "next_request").
Time for absolute times used by GNUnet, in microseconds.
Closure for the 'return_value' function.
void * proc_cls
Closure for 'proc'.
PluginKeyProcessor proc
Function to call.
enum GNUNET_BLOCK_Type type
Block type requested.
bool random
If true, return a random value.
struct Value * value
Value with lowest uid >= next_uid found so far.
uint64_t next_uid
Lowest uid to consider.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
struct ZeroAnonByType * zero_head
Head of list of arrays containing zero-anonymity values by type.
struct GNUNET_CONTAINER_Heap * by_replication
Heap organized by maximum replication value.
struct ZeroAnonByType * zero_tail
Tail of list of arrays containing zero-anonymity values by type.
struct GNUNET_CONTAINER_MultiHashMap * keyvalue
Mapping from keys to 'struct Value's.
struct GNUNET_DATASTORE_PluginEnvironment * env
Our execution environment.
unsigned long long size
Size of all values we're storing.
struct GNUNET_CONTAINER_Heap * by_expiration
Heap organized by minimum expiration time.
Closure for iterator called during 'remove_key'.
uint32_t size
Size of data.
const void * data
Data to remove.
struct Value * value
Value found.
Closure for iterator for updating.
uint32_t priority
Priority of the value.
bool updated
True if the value was found and updated.
struct GNUNET_TIME_Absolute expiration
Expiration time for this value.
const void * data
Pointer to the data.
uint32_t size
Number of bytes in 'data'.
uint32_t replication
Replication level for the value.
struct GNUNET_HashCode key
Key for the value.
struct GNUNET_CONTAINER_HeapNode * replication_heap
Entry for this value in the 'replication' heap.
const void * data
Pointer to the value's data (allocated at the end of this struct).
enum GNUNET_BLOCK_Type type
Type of 'data'.
unsigned int zero_anon_offset
Offset of this value in the array of the 'struct ZeroAnonByType'; only used if anonymity is zero.
uint32_t anonymity
Anonymity level for the value.
uint32_t size
Number of bytes in 'data'.
struct GNUNET_TIME_Absolute expiration
Expiration time for this value.
uint32_t priority
Priority of the value.
struct GNUNET_CONTAINER_HeapNode * expire_heap
Entry for this value in the 'expire' heap.
uint32_t replication
Replication level for the value.
We organize 0-anonymity values in arrays "by type".
struct ZeroAnonByType * prev
We keep these in a DLL.
unsigned int array_pos
First unused offset in 'array'.
unsigned int array_size
Allocated size of the array.
struct ZeroAnonByType * next
We keep these in a DLL.
enum GNUNET_BLOCK_Type type
Type of all of the values in 'array'.
struct Value ** array
Array of 0-anonymity items of the given type.