GNUnet  0.17.6
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 
34 #ifndef PLUGIN_DATACACHE_H
35 #define PLUGIN_DATACACHE_H
36 
37 #include "gnunet_datacache_lib.h"
38 
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #if 0 /* keep Emacsens' auto-indent happy */
43 }
44 #endif
45 #endif
46 
47 
56 typedef void
58  const struct GNUNET_HashCode *key,
59  size_t size);
60 
61 
68 {
73 
77  const char *section;
78 
82  void *cls;
83 
89 
93  unsigned long long quota;
94 };
95 
96 
101 {
105  void *cls;
106 
115  ssize_t
116  (*put) (void *cls,
117  uint32_t xor_distance,
118  const struct GNUNET_DATACACHE_Block *block);
119 
120 
132  unsigned int
133  (*get) (void *cls,
134  const struct GNUNET_HashCode *key,
135  enum GNUNET_BLOCK_Type type,
137  void *iter_cls);
138 
139 
148  (*del)(void *cls);
149 
150 
166  unsigned int
167  (*get_closest) (void *cls,
168  const struct GNUNET_HashCode *key,
169  enum GNUNET_BLOCK_Type type,
170  unsigned int num_results,
172  void *iter_cls);
173 };
174 
175 
176 #if 0 /* keep Emacsens' auto-indent happy */
177 {
178 #endif
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif
184  /* end of group */
186  /* end of group addition */
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
struct GNUNET_HashCode key
The key used in the DHT.
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_DATACACHE_Block *block)
An iterator over a set of items stored in the datacache.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
static unsigned int size
Size of the "table".
Definition: peer.c:67
Information about a block stored in the datacache.
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, uint32_t xor_distance, const struct GNUNET_DATACACHE_Block *block)
Store an item in the datastore.
A 512-bit hashcode.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model