GNUnet  0.11.x
Data Structures | Macros | Functions
datacache.c File Reference

datacache API implementation More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_datacache_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_datacache_plugin.h"
Include dependency graph for datacache.c:

Go to the source code of this file.

Data Structures

 Internal state of the datacache library. More...


#define LOG(kind, ...)   GNUNET_log_from (kind, "datacache", __VA_ARGS__)
#define LOG_STRERROR_FILE(kind, op, fn)    GNUNET_log_from_strerror_file (kind, "datacache", op, fn)


static void env_delete_notify (void *cls, const struct GNUNET_HashCode *key, size_t size)
 Function called by plugins to notify the datacache about content deletions. More...
struct GNUNET_DATACACHE_HandleGNUNET_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 datastore. 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...

Detailed Description

datacache API implementation

Christian Grothoff

Definition in file datacache.c.

Macro Definition Documentation


#define LOG (   kind,
)    GNUNET_log_from (kind, "datacache", __VA_ARGS__)

Definition at line 32 of file datacache.c.


#define LOG_STRERROR_FILE (   kind,
)     GNUNET_log_from_strerror_file (kind, "datacache", op, fn)

Definition at line 34 of file datacache.c.

Function Documentation

◆ env_delete_notify()

static void env_delete_notify ( void *  cls,
const struct GNUNET_HashCode key,
size_t  size 

Function called by plugins to notify the datacache about content deletions.

keykey of the content that was deleted
sizenumber of bytes that were made available

Definition at line 104 of file datacache.c.

105 {
106  struct GNUNET_DATACACHE_Handle *h = cls;
109  "Content under key `%s' discarded\n",
110  GNUNET_h2s (key));
111  GNUNET_assert (h->utilization >= size);
112  h->utilization -= size;
114  GNUNET_STATISTICS_update (h->stats,
115  gettext_noop ("# bytes stored"),
116  -(long long) size,
117  GNUNET_NO);
118  GNUNET_STATISTICS_update (h->stats,
119  gettext_noop ("# items stored"),
120  -1,
121  GNUNET_NO);
122 }
#define LOG(kind,...)
Definition: datacache.c:32
#define gettext_noop(String)
Definition: gettext.h:69
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_HashCode key
The key used in the DHT.
Definition: gnunet_common.h:94
void GNUNET_CONTAINER_bloomfilter_remove(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Remove an element from the filter.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static unsigned int size
Size of the "table".
Definition: peer.c:67
Internal state of the datacache library.
Definition: datacache.c:41

References gettext_noop, GNUNET_assert, GNUNET_CONTAINER_bloomfilter_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_STATISTICS_update(), h, key, LOG, and size.

Referenced by GNUNET_DATACACHE_create().

Here is the call graph for this function:
Here is the caller graph for this function: