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

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...
 
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

Author
Christian Grothoff

Definition in file datacache.c.

Macro Definition Documentation

◆ LOG

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

◆ 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.

Referenced by pid_file_delete(), and write_pid_file().

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.

References GNUNET_DATACACHE_Handle::filter, gettext_noop, GNUNET_assert, GNUNET_CONTAINER_bloomfilter_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_STATISTICS_update(), h, LOG, size, GNUNET_DATACACHE_Handle::stats, and GNUNET_DATACACHE_Handle::utilization.

Referenced by GNUNET_DATACACHE_create().

105 {
106  struct GNUNET_DATACACHE_Handle *h = cls;
107 
109  "Content under key `%s' discarded\n",
110  GNUNET_h2s (key));
112  h->utilization -= size;
115  gettext_noop ("# bytes stored"),
116  -(long long) size,
117  GNUNET_NO);
119  gettext_noop ("# items stored"),
120  -1,
121  GNUNET_NO);
122 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
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 struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_STATISTICS_Handle * stats
Opaque handle for the statistics service.
Definition: datacache.c:55
unsigned long long utilization
How much space is in use right now?
Definition: datacache.c:91
void GNUNET_CONTAINER_bloomfilter_remove(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Remove an element from the filter.
struct GNUNET_CONTAINER_BloomFilter * filter
Bloomfilter to quickly tell if we don't have the content.
Definition: datacache.c:45
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define LOG(kind,...)
Definition: datacache.c:32
Internal state of the datacache library.
Definition: datacache.c:40
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function: