GNUnet  0.11.x
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 
31 #ifndef PLUGIN_DATASTORE_H
32 #define PLUGIN_DATASTORE_H
33 
34 #include "gnunet_block_lib.h"
38 #include "gnunet_scheduler_lib.h"
39 
40 
45 #define GNUNET_DATASTORE_ENTRY_OVERHEAD 256
46 
47 
56 typedef void
58  int delta);
59 
60 
67 {
72 
77 
81  void *cls;
82 };
83 
84 
101 typedef int
103  const struct GNUNET_HashCode *key,
104  uint32_t size,
105  const void *data,
106  enum GNUNET_BLOCK_Type type,
107  uint32_t priority,
108  uint32_t anonymity,
109  uint32_t replication,
111  uint64_t uid);
112 
113 
125 typedef void
127  unsigned long long *estimate);
128 
129 
140 typedef void
141 (*PluginPutCont) (void *cls,
142  const struct GNUNET_HashCode *key,
143  uint32_t size,
144  int status,
145  const char *msg);
146 
147 
166 typedef void
167 (*PluginPut) (void *cls,
168  const struct GNUNET_HashCode *key,
169  bool absent,
170  uint32_t size,
171  const void *data,
172  enum GNUNET_BLOCK_Type type,
173  uint32_t priority,
174  uint32_t anonymity,
175  uint32_t replication,
177  PluginPutCont cont,
178  void *cont_cls);
179 
180 
188 typedef void
190  const struct GNUNET_HashCode *key,
191  unsigned int count);
192 
193 
201 typedef void
202 (*PluginGetKeys) (void *cls,
203  PluginKeyProcessor proc,
204  void *proc_cls);
205 
206 
220 typedef void
221 (*PluginGetKey) (void *cls,
222  uint64_t next_uid,
223  bool random,
224  const struct GNUNET_HashCode *key,
225  enum GNUNET_BLOCK_Type type,
227  void *proc_cls);
228 
229 
240 typedef void
242  const struct GNUNET_HashCode *key,
243  uint32_t size,
244  int status,
245  const char *msg);
246 
247 
258 typedef void
260  const struct GNUNET_HashCode *key,
261  uint32_t size,
262  const void *data,
263  PluginRemoveCont cont,
264  void *cont_cls);
265 
266 
277 typedef void
280  void *proc_cls);
281 
282 
294 typedef void
295 (*PluginGetType) (void *cls,
296  uint64_t next_uid,
297  enum GNUNET_BLOCK_Type type,
299  void *proc_cls);
300 
301 
307 typedef void
308 (*PluginDrop) (void *cls);
309 
310 
316 {
321  void *cls;
322 
328 
333 
338 
343 
352 
359 
365 
370 
375 };
376 
377 #endif
378  /* end of group */
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_DATASTORE_DiskUtilizationChange duc
Function to call on disk utilization change.
PluginGetKeys get_keys
Iterate over all keys in the database.
PluginPut put
Function to store an item in the datastore.
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.
PluginGetType get_zero_anonymity
Get datum (of the specified type) with anonymity level zero.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
void(* GNUNET_DATASTORE_DiskUtilizationChange)(void *cls, int delta)
Function invoked to notify service of disk utilization changes.
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
void(* PluginEstimateSize)(void *cls, unsigned long long *estimate)
Get an estimate of how much space the database is currently using.
PluginRemoveKey remove_key
Function to remove an item from the database.
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(* 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).
static unsigned int replication
PluginEstimateSize estimate_size
Calculate the current on-disk size of the SQ store.
void(* PluginPutCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Put continuation.
PluginGetRandom get_replication
Function to get a random item with high replication score from the database, lowering the item&#39;s repl...
PluginDrop drop
Delete the database.
void(* PluginKeyProcessor)(void *cls, const struct GNUNET_HashCode *key, unsigned int count)
An processor over a set of keys stored in 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 ...
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
uint16_t status
See PRISM_STATUS_*-constants.
void(* PluginDrop)(void *cls)
Drop database.
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
A 512-bit hashcode.
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:67
void(* PluginRemoveCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Remove continuation.
void * cls
Closure to use for all of the following callbacks (except "next_request").
configuration data
Definition: configuration.c:85
void(* PluginGetKeys)(void *cls, PluginKeyProcessor proc, void *proc_cls)
Get all of the keys in the datastore.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
static unsigned int anonymity
void(* PluginGetRandom)(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item (additional constraints may apply depending on the specific implementation).
PluginGetKey get_key
Get a particular datum matching a given hash from the datastore.
uint32_t data
The data value.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
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.