GNUnet  0.10.x
Data Structures | Functions
plugin_datastore_heap.c File Reference

heap-based datastore backend; usually we want the datastore to be persistent, and storing data in the heap is obviously NOT going to be persistent; still, this plugin is useful for testing/benchmarking — but never for production! More...

#include "platform.h"
#include "gnunet_datastore_plugin.h"
Include dependency graph for plugin_datastore_heap.c:

Go to the source code of this file.

Data Structures

struct  Value
 Entry in the hash map. More...
 
struct  ZeroAnonByType
 We organize 0-anonymity values in arrays "by type". More...
 
struct  Plugin
 Handle for a plugin. More...
 
struct  UpdateContext
 Closure for update_rel_sum() and update_abs_sum(). More...
 
struct  GetContext
 Closure for get_cb(). More...
 
struct  GetAllContext
 Closure for the 'return_value' function. More...
 
struct  RemoveContext
 Closure for iterator called during 'remove_key'. More...
 

Functions

static void heap_plugin_estimate_size (void *cls, unsigned long long *estimate)
 Get an estimate of how much space the database is currently using. More...
 
static int update_iterator (void *cls, const struct GNUNET_HashCode *key, void *val)
 Update the matching value. More...
 
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. More...
 
static void delete_value (struct Plugin *plugin, struct Value *value)
 Delete the given value, removing it from the plugin's data structures. More...
 
static int get_iterator (void *cls, const struct GNUNET_HashCode *key, void *val)
 Obtain the matching value with the lowest uid >= next_uid. More...
 
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. More...
 
static void heap_plugin_get_replication (void *cls, PluginDatumProcessor proc, void *proc_cls)
 Get a random item for replication. More...
 
static void heap_plugin_get_expiration (void *cls, PluginDatumProcessor proc, void *proc_cls)
 Get a random item for expiration. More...
 
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. More...
 
static void heap_plugin_drop (void *cls)
 Drop database. More...
 
static int return_value (void *cls, const struct GNUNET_HashCode *key, void *val)
 Callback invoked to call callback on each value. More...
 
static void heap_get_keys (void *cls, PluginKeyProcessor proc, void *proc_cls)
 Get all of the keys in the datastore. More...
 
static int remove_iterator (void *cls, const struct GNUNET_HashCode *key, void *val)
 Obtain the matching value with the lowest uid >= next_uid. More...
 
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. More...
 
void * libgnunet_plugin_datastore_heap_init (void *cls)
 Entry point for the plugin. More...
 
static int free_value (void *cls, const struct GNUNET_HashCode *key, void *val)
 Callback invoked to free all value. More...
 
void * libgnunet_plugin_datastore_heap_done (void *cls)
 Exit point from the plugin. More...
 

Detailed Description

heap-based datastore backend; usually we want the datastore to be persistent, and storing data in the heap is obviously NOT going to be persistent; still, this plugin is useful for testing/benchmarking — but never for production!

Author
Christian Grothoff

Definition in file plugin_datastore_heap.c.

Function Documentation

◆ heap_plugin_estimate_size()

static void heap_plugin_estimate_size ( void *  cls,
unsigned long long *  estimate 
)
static

Get an estimate of how much space the database is currently using.

Parameters
clsour "struct Plugin*"
Returns
number of bytes used on disk

Definition at line 181 of file plugin_datastore_heap.c.

References plugin, and Plugin::size.

Referenced by libgnunet_plugin_datastore_heap_init().

182 {
183  struct Plugin *plugin = cls;
184 
185  if (NULL != estimate)
186  *estimate = plugin->size;
187 }
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
unsigned long long size
Size of all values we're storing.
Handle for a plugin.
Definition: block.c:37
Here is the caller graph for this function:

◆ update_iterator()

static int update_iterator ( void *  cls,
const struct GNUNET_HashCode key,
void *  val 
)
static

Update the matching value.

Parameters
clsthe 'struct UpdateContext'
keyunused
valthe 'struct Value'
Returns
GNUNET_YES (continue iteration), GNUNET_NO if value was found

Definition at line 235 of file plugin_datastore_heap.c.

References GNUNET_TIME_Absolute::abs_value_us, Value::data, UpdateContext::data, Value::expiration, UpdateContext::expiration, Value::expire_heap, GNUNET_CONTAINER_heap_update_cost(), GNUNET_NO, GNUNET_TIME_absolute_max(), GNUNET_YES, Value::priority, UpdateContext::priority, Value::replication, UpdateContext::replication, Value::size, UpdateContext::size, uc, UpdateContext::updated, and value.

Referenced by heap_plugin_put().

238 {
239  struct UpdateContext *uc = cls;
240  struct Value *value = val;
241 
242  if (value->size != uc->size)
243  return GNUNET_YES;
244  if (0 != memcmp(value->data, uc->data, uc->size))
245  return GNUNET_YES;
247  uc->expiration);
249  {
250  value->expiration = uc->expiration;
252  value->expiration.abs_value_us);
253  }
254  /* Saturating adds, don't overflow */
255  if (value->priority > UINT32_MAX - uc->priority)
256  value->priority = UINT32_MAX;
257  else
258  value->priority += uc->priority;
259  if (value->replication > UINT32_MAX - uc->replication)
260  value->replication = UINT32_MAX;
261  else
262  value->replication += uc->replication;
263  uc->updated = true;
264  return GNUNET_NO;
265 }
size_t size
Payload (actual payload follows this struct)
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.
Closure for update_rel_sum() and update_abs_sum().
static struct GNUNET_FS_UnindexContext * uc
#define GNUNET_NO
Definition: gnunet_common.h:78
uint64_t abs_value_us
The actual value.
uint32_t replication
Replication level for the value.
uint32_t priority
Priority of the value.
static char * value
Value of the record to add/remove.
struct GNUNET_CONTAINER_HeapNode * expire_heap
Entry for this value in the 'expire' heap.
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.
Definition: time.c:317
uint32_t replication
Replication level for the value.
const void * data
Pointer to the data.
Entry in the hash map.
uint32_t priority
Priority of the value.
struct GNUNET_TIME_Absolute expiration
Expiration time for this value.
struct GNUNET_TIME_Absolute expiration
Expiration time for this value.
#define GNUNET_YES
Definition: gnunet_common.h:77
const void * data
Pointer to the value's data (allocated at the end of this struct).
uint32_t size
Number of bytes in 'data'.
bool updated
True if the value was found and updated.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ heap_plugin_put()

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 
)
static

Store an item in the datastore.

Parameters
clsclosure
keykey for the item
absenttrue if the key was not found in the bloom filter
sizenumber of bytes in data
datacontent stored
typetype of the content
prioritypriority of the content
anonymityanonymity-level for the content
replicationreplication-level for the content
expirationexpiration time for the content
contcontinuation called with success or failure status
cont_clscontinuation closure

Definition at line 284 of file plugin_datastore_heap.c.

References GNUNET_TIME_Absolute::abs_value_us, Value::anonymity, ZeroAnonByType::array, ZeroAnonByType::array_pos, ZeroAnonByType::array_size, Plugin::by_expiration, Plugin::by_replication, Value::data, UpdateContext::data, Value::expiration, UpdateContext::expiration, Value::expire_heap, GNUNET_array_grow, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, Value::key, Plugin::keyvalue, ZeroAnonByType::next, plugin, Value::priority, UpdateContext::priority, Value::replication, UpdateContext::replication, Value::replication_heap, Value::size, Plugin::size, UpdateContext::size, Value::type, ZeroAnonByType::type, update_iterator(), UpdateContext::updated, value, Value::zero_anon_offset, Plugin::zero_head, and Plugin::zero_tail.

Referenced by libgnunet_plugin_datastore_heap_init().

296 {
297  struct Plugin *plugin = cls;
298  struct Value *value;
299 
300  if (!absent)
301  {
302  struct UpdateContext uc;
303 
304  uc.size = size;
305  uc.data = data;
306  uc.priority = priority;
307  uc.replication = replication;
308  uc.expiration = expiration;
309  uc.updated = false;
311  key,
313  &uc);
314  if (uc.updated)
315  {
316  cont(cont_cls, key, size, GNUNET_NO, NULL);
317  return;
318  }
319  }
320  value = GNUNET_malloc(sizeof(struct Value) + size);
321  value->key = *key;
322  value->data = &value[1];
324  value,
325  expiration.abs_value_us);
327  value,
328  replication);
329  value->expiration = expiration;
330  if (0 == anonymity)
331  {
332  struct ZeroAnonByType *zabt;
333 
334  for (zabt = plugin->zero_head; NULL != zabt; zabt = zabt->next)
335  if (zabt->type == type)
336  break;
337  if (NULL == zabt)
338  {
339  zabt = GNUNET_new(struct ZeroAnonByType);
340  zabt->type = type;
342  plugin->zero_tail,
343  zabt);
344  }
345  if (zabt->array_size == zabt->array_pos)
346  {
347  GNUNET_array_grow(zabt->array,
348  zabt->array_size,
349  zabt->array_size * 2 + 4);
350  }
351  value->zero_anon_offset = zabt->array_pos;
352  zabt->array[zabt->array_pos++] = value;
353  }
354  value->size = size;
355  value->priority = priority;
356  value->anonymity = anonymity;
357  value->replication = replication;
358  value->type = type;
359  GNUNET_memcpy(&value[1], data, size);
361  &value->key,
362  value,
364  plugin->size += size;
365  cont(cont_cls, key, size, GNUNET_OK, NULL);
366 }
size_t size
Payload (actual payload follows this struct)
static char * expiration
Credential TTL.
Closure for update_rel_sum() and update_abs_sum().
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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_MultiHashMap * keyvalue
Mapping from keys to 'struct Value's.
static struct GNUNET_FS_UnindexContext * uc
static unsigned int replication
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
unsigned int array_size
Allocated size of the array.
unsigned int array_pos
First unused offset in 'array'.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint64_t abs_value_us
The actual value.
struct GNUNET_CONTAINER_Heap * by_expiration
Heap organized by minimum expiration time.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
uint32_t priority
Priority of the value.
static char * value
Value of the record to add/remove.
enum GNUNET_BLOCK_Type type
Type of all of the values in 'array'.
unsigned int zero_anon_offset
Offset of this value in the array of the 'struct ZeroAnonByType'; only used if anonymity is zero...
enum GNUNET_BLOCK_Type type
Type of the block.
struct GNUNET_CONTAINER_HeapNode * expire_heap
Entry for this value in the 'expire' heap.
struct Value ** array
Array of 0-anonymity items of the given type.
struct ZeroAnonByType * zero_tail
Tail of list of arrays containing zero-anonymity values by type.
We organize 0-anonymity values in arrays "by type".
struct GNUNET_HashCode key
Key for the entry.
struct GNUNET_CONTAINER_HeapNode * replication_heap
Entry for this value in the 'replication' heap.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:66
uint32_t replication
Replication level for the value.
int 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.
Allow multiple values with the same key.
Entry in the hash map.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
unsigned long long size
Size of all values we're storing.
uint32_t priority
Priority of the value.
Handle for a plugin.
Definition: block.c:37
struct GNUNET_CONTAINER_Heap * by_replication
Heap organized by maximum replication value.
uint32_t anonymity
Anonymity level for the value.
struct GNUNET_TIME_Absolute expiration
Expiration time for this value.
struct ZeroAnonByType * zero_head
Head of list of arrays containing zero-anonymity values by type.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
static unsigned int anonymity
const void * data
Pointer to the value's data (allocated at the end of this struct).
uint32_t data
The data value.
struct ZeroAnonByType * next
We keep these in a DLL.
#define GNUNET_malloc(size)
Wrapper around malloc.
static int update_iterator(void *cls, const struct GNUNET_HashCode *key, void *val)
Update the matching value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_value()

static void delete_value ( struct Plugin plugin,
struct Value value 
)
static

Delete the given value, removing it from the plugin's data structures.

Parameters
pluginthe plugin
valuevalue to delete

Definition at line 377 of file plugin_datastore_heap.c.

References Value::anonymity, ZeroAnonByType::array, ZeroAnonByType::array_pos, ZeroAnonByType::array_size, Value::expire_heap, GNUNET_array_grow, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, Value::key, Plugin::keyvalue, ZeroAnonByType::next, Value::replication_heap, Value::size, Plugin::size, Value::type, ZeroAnonByType::type, Value::zero_anon_offset, Plugin::zero_head, and Plugin::zero_tail.

Referenced by free_value(), heap_plugin_get_expiration(), and heap_plugin_remove_key().

379 {
382  &value->key,
383  value));
386  if (0 == value->anonymity)
387  {
388  struct ZeroAnonByType *zabt;
389 
390  for (zabt = plugin->zero_head; NULL != zabt; zabt = zabt->next)
391  if (zabt->type == value->type)
392  break;
393  GNUNET_assert(NULL != zabt);
394  zabt->array[value->zero_anon_offset] = zabt->array[--zabt->array_pos];
396  if (0 == zabt->array_pos)
397  {
398  GNUNET_array_grow(zabt->array,
399  zabt->array_size,
400  0);
402  plugin->zero_tail,
403  zabt);
404  GNUNET_free(zabt);
405  }
406  }
407  plugin->size -= value->size;
408  GNUNET_free(value);
409 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
size_t size
Payload (actual payload follows this struct)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CONTAINER_MultiHashMap * keyvalue
Mapping from keys to 'struct Value's.
unsigned int array_size
Allocated size of the array.
unsigned int array_pos
First unused offset in 'array'.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
enum GNUNET_BLOCK_Type type
Type of all of the values in 'array'.
unsigned int zero_anon_offset
Offset of this value in the array of the 'struct ZeroAnonByType'; only used if anonymity is zero...
enum GNUNET_BLOCK_Type type
Type of the block.
struct GNUNET_CONTAINER_HeapNode * expire_heap
Entry for this value in the 'expire' heap.
int 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.
struct Value ** array
Array of 0-anonymity items of the given type.
struct ZeroAnonByType * zero_tail
Tail of list of arrays containing zero-anonymity values by type.
We organize 0-anonymity values in arrays "by type".
struct GNUNET_HashCode key
Key for the entry.
struct GNUNET_CONTAINER_HeapNode * replication_heap
Entry for this value in the 'replication' heap.
unsigned long long size
Size of all values we're storing.
uint32_t anonymity
Anonymity level for the value.
struct ZeroAnonByType * zero_head
Head of list of arrays containing zero-anonymity values by type.
#define GNUNET_YES
Definition: gnunet_common.h:77
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
struct ZeroAnonByType * next
We keep these in a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_iterator()

static int get_iterator ( void *  cls,
const struct GNUNET_HashCode key,
void *  val 
)
static

Obtain the matching value with the lowest uid >= next_uid.

Parameters
clsthe 'struct GetContext'
keyunused
valthe 'struct Value'
Returns
GNUNET_YES (continue iteration), GNUNET_NO if result was found

Definition at line 447 of file plugin_datastore_heap.c.

References GNUNET_BLOCK_TYPE_ANY, GNUNET_NO, GNUNET_OK, GetContext::random, Value::type, GetContext::type, value, and GetContext::value.

Referenced by heap_plugin_get_key().

450 {
451  struct GetContext *gc = cls;
452  struct Value *value = val;
453 
454  if ((gc->type != GNUNET_BLOCK_TYPE_ANY) &&
455  (gc->type != value->type))
456  return GNUNET_OK;
457  if (gc->random)
458  {
459  gc->value = value;
460  return GNUNET_NO;
461  }
462  if ((uint64_t)(intptr_t)value < gc->next_uid)
463  return GNUNET_OK;
464  if ((NULL != gc->value) &&
465  (value > gc->value))
466  return GNUNET_OK;
467  gc->value = value;
468  return GNUNET_OK;
469 }
Any type of block, used as a wildcard when searching.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
struct Value * value
Value with lowest uid >= next_uid found so far.
enum GNUNET_BLOCK_Type type
Type of the block.
enum GNUNET_BLOCK_Type type
Block type requested.
bool random
If true, return a random value.
Closure for get_cb().
Entry in the hash map.
Here is the caller graph for this function:

◆ heap_plugin_get_key()

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 
)
static

Get one of the results for a particular key in the datastore.

Parameters
clsclosure
next_uidreturn the result with lowest uid >= next_uid
randomif true, return a random result instead of using next_uid
keymaybe NULL (to match all entries)
typeentries of which type are relevant? Use 0 for any type.
procfunction to call on the matching value; will be called with NULL if nothing matches
proc_clsclosure for proc

Definition at line 486 of file plugin_datastore_heap.c.

References Value::anonymity, Value::expiration, get_iterator(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, Value::key, Plugin::keyvalue, GetContext::next_uid, plugin, Value::priority, GetContext::random, Value::replication, Value::size, Value::type, GetContext::type, and GetContext::value.

Referenced by libgnunet_plugin_datastore_heap_init().

493 {
494  struct Plugin *plugin = cls;
495  struct GetContext gc;
496 
497  gc.value = NULL;
498  gc.next_uid = next_uid;
499  gc.random = random;
500  gc.type = type;
501  if (NULL == key)
502  {
504  &get_iterator,
505  &gc);
506  }
507  else
508  {
510  key,
511  &get_iterator,
512  &gc);
513  }
514  if (NULL == gc.value)
515  {
516  proc(proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
517  return;
518  }
520  proc(proc_cls,
521  &gc.value->key,
522  gc.value->size,
523  &gc.value[1],
524  gc.value->type,
525  gc.value->priority,
526  gc.value->anonymity,
527  gc.value->replication,
528  gc.value->expiration,
529  (uint64_t)(intptr_t)gc.value));
530 }
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
static int get_iterator(void *cls, const struct GNUNET_HashCode *key, void *val)
Obtain the matching value with the lowest uid >= next_uid.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CONTAINER_MultiHashMap * keyvalue
Mapping from keys to &#39;struct Value&#39;s.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint64_t next_uid
Lowest uid to consider.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct Value * value
Value with lowest uid >= next_uid found so far.
bool random
If true, return a random value.
Closure for get_cb().
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ heap_plugin_get_replication()

static void heap_plugin_get_replication ( void *  cls,
PluginDatumProcessor  proc,
void *  proc_cls 
)
static

Get a random item for replication.

Returns a single, not expired, random item from those with the highest replication counters. The item's replication counter is decremented by one IF it was positive before. Call 'proc' with all values ZERO or NULL if the datastore is empty.

Parameters
clsclosure
procfunction to call the value (once only).
proc_clsclosure for proc

Definition at line 545 of file plugin_datastore_heap.c.

References Value::anonymity, Plugin::by_replication, Value::expiration, GNUNET_assert, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_CONTAINER_heap_walk_get_next(), GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, Value::key, plugin, Value::priority, Value::replication, Value::replication_heap, Value::size, Value::type, and value.

Referenced by libgnunet_plugin_datastore_heap_init().

548 {
549  struct Plugin *plugin = cls;
550  struct Value *value;
551 
553  if (NULL == value)
554  {
555  proc(proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
556  return;
557  }
558  if (value->replication > 0)
559  {
560  value->replication--;
562  value,
563  value->replication);
564  }
565  else
566  {
567  /* need a better way to pick a random item, replication level is always 0 */
569  value,
570  value->replication);
572  }
574  proc(proc_cls,
575  &value->key,
576  value->size,
577  &value[1],
578  value->type,
579  value->priority,
580  value->anonymity,
581  value->replication,
582  value->expiration,
583  (uint64_t)(intptr_t)value));
584 }
size_t size
Payload (actual payload follows this struct)
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
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.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
static char * value
Value of the record to add/remove.
enum GNUNET_BLOCK_Type type
Type of the block.
void * GNUNET_CONTAINER_heap_walk_get_next(struct GNUNET_CONTAINER_Heap *heap)
Perform a random walk of the tree.
struct GNUNET_HashCode key
Key for the entry.
struct GNUNET_CONTAINER_HeapNode * replication_heap
Entry for this value in the &#39;replication&#39; heap.
uint32_t replication
Replication level for the value.
Entry in the hash map.
uint32_t priority
Priority of the value.
Handle for a plugin.
Definition: block.c:37
struct GNUNET_CONTAINER_Heap * by_replication
Heap organized by maximum replication value.
uint32_t anonymity
Anonymity level for the value.
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
struct GNUNET_TIME_Absolute expiration
Expiration time for this value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ heap_plugin_get_expiration()

static void heap_plugin_get_expiration ( void *  cls,
PluginDatumProcessor  proc,
void *  proc_cls 
)
static

Get a random item for expiration.

Call 'proc' with all values ZERO or NULL if the datastore is empty.

Parameters
clsclosure
procfunction to call the value (once only).
proc_clsclosure for proc

Definition at line 596 of file plugin_datastore_heap.c.

References Value::anonymity, Plugin::by_expiration, delete_value(), Value::expiration, GNUNET_CONTAINER_heap_peek(), GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, Value::key, plugin, Value::priority, Value::replication, Value::size, Value::type, and value.

Referenced by libgnunet_plugin_datastore_heap_init().

598 {
599  struct Plugin *plugin = cls;
600  struct Value *value;
601 
602  value = GNUNET_CONTAINER_heap_peek(plugin->by_expiration);
603  if (NULL == value)
604  {
605  proc(proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
606  return;
607  }
608  if (GNUNET_NO ==
609  proc(proc_cls,
610  &value->key,
611  value->size,
612  &value[1],
613  value->type,
614  value->priority,
615  value->anonymity,
616  value->replication,
617  value->expiration,
618  (uint64_t)(intptr_t)value))
619  delete_value(plugin, value);
620 }
size_t size
Payload (actual payload follows this struct)
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
static void delete_value(struct Plugin *plugin, struct Value *value)
Delete the given value, removing it from the plugin&#39;s data structures.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CONTAINER_Heap * by_expiration
Heap organized by minimum expiration time.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
static char * value
Value of the record to add/remove.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
enum GNUNET_BLOCK_Type type
Type of the block.
struct GNUNET_HashCode key
Key for the entry.
uint32_t replication
Replication level for the value.
Entry in the hash map.
uint32_t priority
Priority of the value.
Handle for a plugin.
Definition: block.c:37
uint32_t anonymity
Anonymity level for the value.
struct GNUNET_TIME_Absolute expiration
Expiration time for this value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ heap_plugin_get_zero_anonymity()

static void heap_plugin_get_zero_anonymity ( void *  cls,
uint64_t  next_uid,
enum GNUNET_BLOCK_Type  type,
PluginDatumProcessor  proc,
void *  proc_cls 
)
static

Call the given processor on an item with zero anonymity.

Parameters
clsour "struct Plugin*"
next_uidreturn the result with lowest uid >= next_uid
typeentries of which type should be considered? Must not be zero (ANY).
procfunction to call on each matching value; will be called with NULL if no value matches
proc_clsclosure for proc

Definition at line 635 of file plugin_datastore_heap.c.

References Value::anonymity, ZeroAnonByType::array, ZeroAnonByType::array_pos, Value::expiration, GNUNET_assert, GNUNET_BLOCK_TYPE_ANY, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, Value::key, ZeroAnonByType::next, plugin, Value::priority, Value::replication, Value::size, Value::type, ZeroAnonByType::type, value, and Plugin::zero_head.

Referenced by libgnunet_plugin_datastore_heap_init().

638 {
639  struct Plugin *plugin = cls;
640  struct ZeroAnonByType *zabt;
641  struct Value *value = NULL;
642 
643  for (zabt = plugin->zero_head; NULL != zabt; zabt = zabt->next)
644  {
645  if ((type != GNUNET_BLOCK_TYPE_ANY) &&
646  (type != zabt->type))
647  continue;
648  for (int i = 0; i < zabt->array_pos; ++i)
649  {
650  if ((uint64_t)(intptr_t)zabt->array[i] < next_uid)
651  continue;
652  if ((NULL != value) &&
653  (zabt->array[i] > value))
654  continue;
655  value = zabt->array[i];
656  }
657  }
658  if (NULL == value)
659  {
660  proc(proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
661  return;
662  }
664  proc(proc_cls,
665  &value->key,
666  value->size,
667  &value[1],
668  value->type,
669  value->priority,
670  value->anonymity,
671  value->replication,
672  value->expiration,
673  (uint64_t)(intptr_t)value));
674 }
size_t size
Payload (actual payload follows this struct)
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
Any type of block, used as a wildcard when searching.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
unsigned int array_pos
First unused offset in &#39;array&#39;.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
static char * value
Value of the record to add/remove.
enum GNUNET_BLOCK_Type type
Type of all of the values in &#39;array&#39;.
enum GNUNET_BLOCK_Type type
Type of the block.
struct Value ** array
Array of 0-anonymity items of the given type.
We organize 0-anonymity values in arrays "by type".
struct GNUNET_HashCode key
Key for the entry.
uint32_t replication
Replication level for the value.
Entry in the hash map.
uint32_t priority
Priority of the value.
Handle for a plugin.
Definition: block.c:37
uint32_t anonymity
Anonymity level for the value.
struct GNUNET_TIME_Absolute expiration
Expiration time for this value.
struct ZeroAnonByType * zero_head
Head of list of arrays containing zero-anonymity values by type.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct ZeroAnonByType * next
We keep these in a DLL.
Here is the caller graph for this function:

◆ heap_plugin_drop()

static void heap_plugin_drop ( void *  cls)
static

Drop database.

Definition at line 681 of file plugin_datastore_heap.c.

Referenced by libgnunet_plugin_datastore_heap_init().

682 {
683  /* nothing needs to be done */
684 }
Here is the caller graph for this function:

◆ return_value()

static int return_value ( void *  cls,
const struct GNUNET_HashCode key,
void *  val 
)
static

Callback invoked to call callback on each value.

Parameters
clsthe plugin
keyunused
valthe value
Returns
GNUNET_OK (continue to iterate)

Definition at line 712 of file plugin_datastore_heap.c.

References GNUNET_OK, GetAllContext::proc, and GetAllContext::proc_cls.

Referenced by heap_get_keys().

715 {
716  struct GetAllContext *gac = cls;
717 
718  gac->proc(gac->proc_cls,
719  key,
720  1);
721  return GNUNET_OK;
722 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
PluginKeyProcessor proc
Function to call.
void * proc_cls
Closure for &#39;proc&#39;.
Closure for the &#39;return_value&#39; function.
Here is the caller graph for this function:

◆ heap_get_keys()

static void heap_get_keys ( void *  cls,
PluginKeyProcessor  proc,
void *  proc_cls 
)
static

Get all of the keys in the datastore.

Parameters
clsclosure
procfunction to call on each key
proc_clsclosure for proc

Definition at line 733 of file plugin_datastore_heap.c.

References GNUNET_CONTAINER_multihashmap_iterate(), Plugin::keyvalue, plugin, GetAllContext::proc, GetAllContext::proc_cls, and return_value().

Referenced by libgnunet_plugin_datastore_heap_init().

736 {
737  struct Plugin *plugin = cls;
738  struct GetAllContext gac;
739 
740  gac.proc = proc;
741  gac.proc_cls = proc_cls;
743  &return_value,
744  &gac);
745  proc(proc_cls, NULL, 0);
746 }
struct GNUNET_CONTAINER_MultiHashMap * keyvalue
Mapping from keys to &#39;struct Value&#39;s.
PluginKeyProcessor proc
Function to call.
void * proc_cls
Closure for &#39;proc&#39;.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
Closure for the &#39;return_value&#39; function.
static int return_value(void *cls, const struct GNUNET_HashCode *key, void *val)
Callback invoked to call callback on each value.
Handle for a plugin.
Definition: block.c:37
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_iterator()

static int remove_iterator ( void *  cls,
const struct GNUNET_HashCode key,
void *  val 
)
static

Obtain the matching value with the lowest uid >= next_uid.

Parameters
clsthe 'struct GetContext'
keyunused
valthe 'struct Value'
Returns
GNUNET_YES (continue iteration), GNUNET_NO if result was found

Definition at line 779 of file plugin_datastore_heap.c.

References Value::data, RemoveContext::data, GNUNET_NO, GNUNET_YES, Value::size, RemoveContext::size, value, and RemoveContext::value.

Referenced by heap_plugin_remove_key().

782 {
783  struct RemoveContext *rc = cls;
784  struct Value *value = val;
785 
786  if (value->size != rc->size)
787  return GNUNET_YES;
788  if (0 != memcmp(value->data, rc->data, rc->size))
789  return GNUNET_YES;
790  rc->value = value;
791  return GNUNET_NO;
792 }
size_t size
Payload (actual payload follows this struct)
uint32_t size
Size of data.
const void * data
Data to remove.
#define GNUNET_NO
Definition: gnunet_common.h:78
static char * value
Value of the record to add/remove.
struct Value * value
Value found.
Entry in the hash map.
#define GNUNET_YES
Definition: gnunet_common.h:77
const void * data
Pointer to the value&#39;s data (allocated at the end of this struct).
Closure for iterator called during &#39;remove_key&#39;.
Here is the caller graph for this function:

◆ heap_plugin_remove_key()

static void heap_plugin_remove_key ( void *  cls,
const struct GNUNET_HashCode key,
uint32_t  size,
const void *  data,
PluginRemoveCont  cont,
void *  cont_cls 
)
static

Remove a particular key in the datastore.

Parameters
clsclosure
keykey for the content
sizenumber of bytes in data
datacontent stored
contcontinuation called with success or failure status
cont_clscontinuation closure for cont

Definition at line 806 of file plugin_datastore_heap.c.

References Value::data, RemoveContext::data, delete_value(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_NO, GNUNET_OK, Plugin::keyvalue, plugin, remove_iterator(), Value::size, RemoveContext::size, and RemoveContext::value.

Referenced by libgnunet_plugin_datastore_heap_init().

812 {
813  struct Plugin *plugin = cls;
814  struct RemoveContext rc;
815 
816  rc.value = NULL;
817  rc.size = size;
818  rc.data = data;
820  key,
822  &rc);
823  if (NULL == rc.value)
824  {
825  cont(cont_cls,
826  key,
827  size,
828  GNUNET_NO,
829  NULL);
830  return;
831  }
832  delete_value(plugin,
833  rc.value);
834  cont(cont_cls,
835  key,
836  size,
837  GNUNET_OK,
838  NULL);
839 }
size_t size
Payload (actual payload follows this struct)
struct GNUNET_CONTAINER_MultiHashMap * keyvalue
Mapping from keys to &#39;struct Value&#39;s.
static void delete_value(struct Plugin *plugin, struct Value *value)
Delete the given value, removing it from the plugin&#39;s data structures.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct Value * value
Value found.
static int remove_iterator(void *cls, const struct GNUNET_HashCode *key, void *val)
Obtain the matching value with the lowest uid >= next_uid.
static unsigned int size
Size of the "table".
Definition: peer.c:66
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
Handle for a plugin.
Definition: block.c:37
Closure for iterator called during &#39;remove_key&#39;.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libgnunet_plugin_datastore_heap_init()

void* libgnunet_plugin_datastore_heap_init ( void *  cls)

Entry point for the plugin.

Parameters
clsthe "struct GNUNET_DATASTORE_PluginEnvironment*"
Returns
our "struct Plugin*"

Definition at line 849 of file plugin_datastore_heap.c.

References _, Plugin::api, Plugin::by_expiration, Plugin::by_replication, GNUNET_DATASTORE_PluginEnvironment::cfg, GNUNET_DATASTORE_PluginEnvironment::cls, GNUNET_DATASTORE_PluginFunctions::cls, GNUNET_DATASTORE_PluginFunctions::drop, env, Plugin::env, GNUNET_DATASTORE_PluginFunctions::estimate_size, GNUNET_DATASTORE_PluginFunctions::get_expiration, GNUNET_DATASTORE_PluginFunctions::get_key, GNUNET_DATASTORE_PluginFunctions::get_keys, GNUNET_DATASTORE_PluginFunctions::get_replication, GNUNET_DATASTORE_PluginFunctions::get_zero_anonymity, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MAX, GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_INFO, GNUNET_log_from, GNUNET_new, GNUNET_OK, GNUNET_YES, heap_get_keys(), heap_plugin_drop(), heap_plugin_estimate_size(), heap_plugin_get_expiration(), heap_plugin_get_key(), heap_plugin_get_replication(), heap_plugin_get_zero_anonymity(), heap_plugin_put(), heap_plugin_remove_key(), Plugin::keyvalue, plugin, GNUNET_DATASTORE_PluginFunctions::put, and GNUNET_DATASTORE_PluginFunctions::remove_key.

850 {
853  struct Plugin *plugin;
854  unsigned long long esize;
855 
856  if (GNUNET_OK !=
858  "datastore-heap",
859  "HASHMAPSIZE",
860  &esize))
861  esize = 128 * 1024;
862  plugin = GNUNET_new(struct Plugin);
863  plugin->env = env;
868  api->cls = plugin;
870  api->put = &heap_plugin_put;
875  api->drop = &heap_plugin_drop;
876  api->get_keys = &heap_get_keys;
879  _("Heap database running\n"));
880  return api;
881 }
PluginGetKeys get_keys
Iterate over all keys in the database.
PluginPut put
Function to store an item in the datastore.
PluginGetType get_zero_anonymity
Get datum (of the specified type) with anonymity level zero.
int 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.
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.
struct GNUNET_CONTAINER_MultiHashMap * keyvalue
Mapping from keys to &#39;struct Value&#39;s.
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.
PluginRemoveKey remove_key
Function to remove an item from the database.
PluginEstimateSize estimate_size
Calculate the current on-disk size of the SQ store.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONTAINER_Heap * by_expiration
Heap organized by minimum expiration time.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:46
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
PluginGetRandom get_replication
Function to get a random item with high replication score from the database, lowering the item&#39;s repl...
static void heap_plugin_get_replication(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item for replication.
PluginDrop drop
Delete the database.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
PluginGetRandom get_expiration
Function to get a random expired item or, if none are expired, either the oldest entry or one with a ...
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
static void heap_plugin_drop(void *cls)
Drop database.
Heap with the minimum cost at the root.
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void heap_plugin_estimate_size(void *cls, unsigned long long *estimate)
Get an estimate of how much space the database is currently using.
void * cls
Closure to use for all of the following callbacks (except "next_request").
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
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.
Handle for a plugin.
Definition: block.c:37
struct GNUNET_CONTAINER_Heap * by_replication
Heap organized by maximum replication value.
Heap with the maximum cost at the root.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static void heap_get_keys(void *cls, PluginKeyProcessor proc, void *proc_cls)
Get all of the keys in the datastore.
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.
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_log_from(kind, comp,...)
PluginGetKey get_key
Get a particular datum matching a given hash from the datastore.
static void heap_plugin_get_expiration(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item for expiration.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Here is the call graph for this function:

◆ free_value()

static int free_value ( void *  cls,
const struct GNUNET_HashCode key,
void *  val 
)
static

Callback invoked to free all value.

Parameters
clsthe plugin
keyunused
valthe value
Returns
GNUNET_OK (continue to iterate)

Definition at line 893 of file plugin_datastore_heap.c.

References delete_value(), GNUNET_OK, plugin, and value.

Referenced by libgnunet_plugin_datastore_heap_done().

896 {
897  struct Plugin *plugin = cls;
898  struct Value *value = val;
899 
900  delete_value(plugin, value);
901  return GNUNET_OK;
902 }
static void delete_value(struct Plugin *plugin, struct Value *value)
Delete the given value, removing it from the plugin&#39;s data structures.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
static char * value
Value of the record to add/remove.
Entry in the hash map.
Handle for a plugin.
Definition: block.c:37
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libgnunet_plugin_datastore_heap_done()

void* libgnunet_plugin_datastore_heap_done ( void *  cls)

Exit point from the plugin.

Parameters
clsour "struct Plugin*"
Returns
always NULL

Definition at line 911 of file plugin_datastore_heap.c.

References Plugin::by_expiration, Plugin::by_replication, GNUNET_DATASTORE_PluginFunctions::cls, free_value(), GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, Plugin::keyvalue, and plugin.

912 {
914  struct Plugin *plugin = api->cls;
915 
917  &free_value,
918  plugin);
922  GNUNET_free(plugin);
923  GNUNET_free(api);
924  return NULL;
925 }
struct GNUNET_CONTAINER_MultiHashMap * keyvalue
Mapping from keys to &#39;struct Value&#39;s.
struct GNUNET_CONTAINER_Heap * by_expiration
Heap organized by minimum expiration time.
static int free_value(void *cls, const struct GNUNET_HashCode *key, void *val)
Callback invoked to free all value.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
void * cls
Closure to use for all of the following callbacks (except "next_request").
Handle for a plugin.
Definition: block.c:37
struct GNUNET_CONTAINER_Heap * by_replication
Heap organized by maximum replication value.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function: