GNUnet 0.22.2
datacache.c File Reference

datacache API implementation More...

Include dependency graph for datacache.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_DATACACHE_Handle
 Internal state of the datacache library. More...
 

Macros

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

Functions

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...
 
enum GNUNET_GenericReturnValue GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, uint32_t xor_distance, const struct GNUNET_DATACACHE_Block *block)
 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_closest (struct GNUNET_DATACACHE_Handle *h, 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...
 

Detailed Description

datacache API implementation

Author
Christian Grothoff

Definition in file datacache.c.

Macro Definition Documentation

◆ LOG

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

Definition at line 32 of file datacache.c.

◆ LOG_STRERROR_FILE

#define LOG_STRERROR_FILE (   kind,
  op,
  fn 
)     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 
)
static

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

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

Definition at line 104 of file datacache.c.

107{
108 struct GNUNET_DATACACHE_Handle *h = cls;
109
111 "Content under key `%s' discarded\n",
112 GNUNET_h2s (key));
113 GNUNET_assert (h->utilization >= size);
114 h->utilization -= size;
117 "# bytes stored",
118 -(long long) size,
119 GNUNET_NO);
121 "# items stored",
122 -1,
123 GNUNET_NO);
124}
#define LOG(kind,...)
Definition: datacache.c:32
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
struct GNUNET_HashCode key
The key used in the DHT.
void GNUNET_CONTAINER_bloomfilter_remove(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Remove an element from the filter.
@ GNUNET_NO
#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).
@ GNUNET_ERROR_TYPE_DEBUG
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:68
Internal state of the datacache library.
Definition: datacache.c:41

References 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: