GNUnet  0.19.3
gnunet_datastore_plugin.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2009, 2011 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_DATASTORE_H
35 #define PLUGIN_DATASTORE_H
36 
37 
38 #include "gnunet_block_lib.h"
42 #include "gnunet_scheduler_lib.h"
43 
44 
49 #define GNUNET_DATASTORE_ENTRY_OVERHEAD 256
50 
51 
60 typedef void
62  int delta);
63 
64 
71 {
76 
81 
85  void *cls;
86 };
87 
88 
105 typedef enum GNUNET_GenericReturnValue
106 (*PluginDatumProcessor)(void *cls,
107  const struct GNUNET_HashCode *key,
108  uint32_t size,
109  const void *data,
110  enum GNUNET_BLOCK_Type type,
111  uint32_t priority,
112  uint32_t anonymity,
113  uint32_t replication,
115  uint64_t uid);
116 
117 
129 typedef void
130 (*PluginEstimateSize) (void *cls,
131  unsigned long long *estimate);
132 
133 
144 typedef void
145 (*PluginPutCont) (void *cls,
146  const struct GNUNET_HashCode *key,
147  uint32_t size,
148  int status,
149  const char *msg);
150 
151 
170 typedef void
171 (*PluginPut) (void *cls,
172  const struct GNUNET_HashCode *key,
173  bool absent,
174  uint32_t size,
175  const void *data,
176  enum GNUNET_BLOCK_Type type,
177  uint32_t priority,
178  uint32_t anonymity,
179  uint32_t replication,
181  PluginPutCont cont,
182  void *cont_cls);
183 
184 
192 typedef void
193 (*PluginKeyProcessor) (void *cls,
194  const struct GNUNET_HashCode *key,
195  unsigned int count);
196 
197 
205 typedef void
206 (*PluginGetKeys) (void *cls,
207  PluginKeyProcessor proc,
208  void *proc_cls);
209 
210 
224 typedef void
225 (*PluginGetKey) (void *cls,
226  uint64_t next_uid,
227  bool random,
228  const struct GNUNET_HashCode *key,
229  enum GNUNET_BLOCK_Type type,
231  void *proc_cls);
232 
233 
244 typedef void
245 (*PluginRemoveCont) (void *cls,
246  const struct GNUNET_HashCode *key,
247  uint32_t size,
248  int status,
249  const char *msg);
250 
251 
262 typedef void
263 (*PluginRemoveKey) (void *cls,
264  const struct GNUNET_HashCode *key,
265  uint32_t size,
266  const void *data,
267  PluginRemoveCont cont,
268  void *cont_cls);
269 
270 
281 typedef void
282 (*PluginGetRandom) (void *cls,
284  void *proc_cls);
285 
286 
298 typedef void
299 (*PluginGetType) (void *cls,
300  uint64_t next_uid,
301  enum GNUNET_BLOCK_Type type,
303  void *proc_cls);
304 
305 
311 typedef void
312 (*PluginDrop) (void *cls);
313 
314 
320 {
325  void *cls;
326 
332 
337 
342 
347 
356 
363 
369 
374 
379 };
380 
381 #endif
382  /* end of group */
384  /* end of group addition */
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
static unsigned int replication
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int anonymity
uint32_t data
The data value.
uint16_t status
See PRISM_STATUS_*-constants.
Library for data block manipulation.
Configuration API.
API to schedule computations using continuation passing style.
API to create, modify and access statistics.
void(* PluginGetKeys)(void *cls, PluginKeyProcessor proc, void *proc_cls)
Get all of the keys in the datastore.
enum GNUNET_GenericReturnValue(* PluginDatumProcessor)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid)
An processor over a set of items stored in the datastore.
void(* PluginGetKey)(void *cls, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls)
Get one of the results for a particular key in the datastore.
void(* PluginDrop)(void *cls)
Drop database.
void(* PluginGetRandom)(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item (additional constraints may apply depending on the specific implementation).
void(* PluginEstimateSize)(void *cls, unsigned long long *estimate)
Get an estimate of how much space the database is currently using.
void(* PluginRemoveKey)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, PluginRemoveCont cont, void *cont_cls)
Remove a particular key in the datastore.
void(* PluginGetType)(void *cls, uint64_t next_uid, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls)
Select a single item from the datastore (among those applicable).
void(* PluginPutCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Put continuation.
void(* PluginKeyProcessor)(void *cls, const struct GNUNET_HashCode *key, unsigned int count)
An processor over a set of keys stored in the datastore.
void(* GNUNET_DATASTORE_DiskUtilizationChange)(void *cls, int delta)
Function invoked to notify service of disk utilization changes.
void(* PluginRemoveCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Remove continuation.
void(* PluginPut)(void *cls, const struct GNUNET_HashCode *key, bool absent, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, PluginPutCont cont, void *cont_cls)
Store an item in the datastore.
GNUNET_GenericReturnValue
Named constants for return values.
static unsigned int size
Size of the "table".
Definition: peer.c:68
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:36
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
GNUNET_DATASTORE_DiskUtilizationChange duc
Function to call on disk utilization change.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
PluginGetKey get_key
Get a particular datum matching a given hash from the datastore.
PluginGetRandom get_expiration
Function to get a random expired item or, if none are expired, either the oldest entry or one with a ...
PluginEstimateSize estimate_size
Calculate the current on-disk size of the SQ store.
PluginGetKeys get_keys
Iterate over all keys in the database.
PluginGetRandom get_replication
Function to get a random item with high replication score from the database, lowering the item's repl...
PluginPut put
Function to store an item in the datastore.
void * cls
Closure to use for all of the following callbacks (except "next_request").
PluginGetType get_zero_anonymity
Get datum (of the specified type) with anonymity level zero.
PluginDrop drop
Delete the database.
PluginRemoveKey remove_key
Function to remove an item from the database.
A 512-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model