GNUnet  0.17.6
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 #include "gnunet_block_lib.h"
41 #include "gnunet_scheduler_lib.h"
42 
43 
48 #define GNUNET_DATASTORE_ENTRY_OVERHEAD 256
49 
50 
59 typedef void
61  int delta);
62 
63 
70 {
75 
80 
84  void *cls;
85 };
86 
87 
104 typedef int
105 (*PluginDatumProcessor) (void *cls,
106  const struct GNUNET_HashCode *key,
107  uint32_t size,
108  const void *data,
109  enum GNUNET_BLOCK_Type type,
110  uint32_t priority,
111  uint32_t anonymity,
112  uint32_t replication,
114  uint64_t uid);
115 
116 
128 typedef void
129 (*PluginEstimateSize) (void *cls,
130  unsigned long long *estimate);
131 
132 
143 typedef void
144 (*PluginPutCont) (void *cls,
145  const struct GNUNET_HashCode *key,
146  uint32_t size,
147  int status,
148  const char *msg);
149 
150 
169 typedef void
170 (*PluginPut) (void *cls,
171  const struct GNUNET_HashCode *key,
172  bool absent,
173  uint32_t size,
174  const void *data,
175  enum GNUNET_BLOCK_Type type,
176  uint32_t priority,
177  uint32_t anonymity,
178  uint32_t replication,
180  PluginPutCont cont,
181  void *cont_cls);
182 
183 
191 typedef void
192 (*PluginKeyProcessor) (void *cls,
193  const struct GNUNET_HashCode *key,
194  unsigned int count);
195 
196 
204 typedef void
205 (*PluginGetKeys) (void *cls,
206  PluginKeyProcessor proc,
207  void *proc_cls);
208 
209 
223 typedef void
224 (*PluginGetKey) (void *cls,
225  uint64_t next_uid,
226  bool random,
227  const struct GNUNET_HashCode *key,
228  enum GNUNET_BLOCK_Type type,
230  void *proc_cls);
231 
232 
243 typedef void
244 (*PluginRemoveCont) (void *cls,
245  const struct GNUNET_HashCode *key,
246  uint32_t size,
247  int status,
248  const char *msg);
249 
250 
261 typedef void
262 (*PluginRemoveKey) (void *cls,
263  const struct GNUNET_HashCode *key,
264  uint32_t size,
265  const void *data,
266  PluginRemoveCont cont,
267  void *cont_cls);
268 
269 
280 typedef void
281 (*PluginGetRandom) (void *cls,
283  void *proc_cls);
284 
285 
297 typedef void
298 (*PluginGetType) (void *cls,
299  uint64_t next_uid,
300  enum GNUNET_BLOCK_Type type,
302  void *proc_cls);
303 
304 
310 typedef void
311 (*PluginDrop) (void *cls);
312 
313 
319 {
324  void *cls;
325 
331 
336 
341 
346 
355 
362 
368 
373 
378 };
379 
380 #endif
381  /* end of group */
383  /* 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.
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.
int(* 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(* 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.
static unsigned int size
Size of the "table".
Definition: peer.c:67
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
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