GNUnet  0.16.x
gnunet_datacache_plugin.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2006, 2009, 2015, 2022 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
31 #ifndef PLUGIN_DATACACHE_H
32 #define PLUGIN_DATACACHE_H
33 
34 #include "gnunet_datacache_lib.h"
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #if 0 /* keep Emacsens' auto-indent happy */
40 }
41 #endif
42 #endif
43 
44 
53 typedef void
55  const struct GNUNET_HashCode *key,
56  size_t size);
57 
58 
65 {
70 
74  const char *section;
75 
79  void *cls;
80 
86 
90  unsigned long long quota;
91 };
92 
93 
98 {
102  void *cls;
103 
118  ssize_t
119  (*put) (void *cls,
120  const struct GNUNET_HashCode *key,
121  uint32_t xor_distance,
122  size_t size,
123  const char *data,
124  enum GNUNET_BLOCK_Type type,
125  struct GNUNET_TIME_Absolute discard_time,
126  unsigned int path_info_len,
127  const struct GNUNET_DHT_PathElement *path_info);
128 
129 
141  unsigned int
142  (*get) (void *cls,
143  const struct GNUNET_HashCode *key,
144  enum GNUNET_BLOCK_Type type,
146  void *iter_cls);
147 
148 
157  (*del)(void *cls);
158 
159 
175  unsigned int
176  (*get_closest) (void *cls,
177  const struct GNUNET_HashCode *key,
178  enum GNUNET_BLOCK_Type type,
179  unsigned int num_results,
181  void *iter_cls);
182 };
183 
184 
185 #if 0 /* keep Emacsens' auto-indent happy */
186 {
187 #endif
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif
193  /* end of group */
struct GNUNET_HashCode key
The key used in the DHT.
uint32_t data
The data value.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
void(* GNUNET_DATACACHE_DeleteNotifyCallback)(void *cls, const struct GNUNET_HashCode *key, size_t size)
Function called by plugins to notify the datacache about content deletions.
enum GNUNET_GenericReturnValue(* GNUNET_DATACACHE_Iterator)(void *cls, const struct GNUNET_HashCode *key, size_t data_size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute exp, unsigned int path_info_len, const struct GNUNET_DHT_PathElement *path_info)
An iterator over a set of items stored in the datacache.
static unsigned int size
Size of the "table".
Definition: peer.c:67
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
const char * section
Configuration section to use.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
GNUNET_DATACACHE_DeleteNotifyCallback delete_notify
Function to call whenever the plugin needs to discard content that it was asked to store.
void * cls
Closure to use for callbacks.
unsigned long long quota
How much space are we allowed to use?
struct returned by the initialization function of the plugin
void * cls
Closure to pass to all plugin functions.
unsigned int(* get)(void *cls, 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 datastore.
unsigned int(* get_closest)(void *cls, 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.
enum GNUNET_GenericReturnValue(* del)(void *cls)
Delete the entry with the lowest expiration value from the datacache right now.
ssize_t(* put)(void *cls, const struct GNUNET_HashCode *key, uint32_t xor_distance, size_t size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time, unsigned int path_info_len, const struct GNUNET_DHT_PathElement *path_info)
Store an item in the datastore.
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...
A 512-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model