GNUnet  0.10.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 
85 
102 typedef int
104  const struct GNUNET_HashCode *key,
105  uint32_t size,
106  const void *data,
107  enum GNUNET_BLOCK_Type type,
108  uint32_t priority,
109  uint32_t anonymity,
110  uint32_t replication,
112  uint64_t uid);
113 
114 
126 typedef void
128  unsigned long long *estimate);
129 
130 
141 typedef void
142 (*PluginPutCont) (void *cls,
143  const struct GNUNET_HashCode *key,
144  uint32_t size,
145  int status,
146  const char *msg);
147 
148 
167 typedef void
168 (*PluginPut) (void *cls,
169  const struct GNUNET_HashCode *key,
170  bool absent,
171  uint32_t size,
172  const void *data,
173  enum GNUNET_BLOCK_Type type,
174  uint32_t priority,
175  uint32_t anonymity,
176  uint32_t replication,
178  PluginPutCont cont,
179  void *cont_cls);
180 
181 
189 typedef void
191  const struct GNUNET_HashCode *key,
192  unsigned int count);
193 
194 
202 typedef void
203 (*PluginGetKeys) (void *cls,
204  PluginKeyProcessor proc,
205  void *proc_cls);
206 
207 
221 typedef void
222 (*PluginGetKey) (void *cls,
223  uint64_t next_uid,
224  bool random,
225  const struct GNUNET_HashCode *key,
226  enum GNUNET_BLOCK_Type type,
228  void *proc_cls);
229 
230 
241 typedef void
243  const struct GNUNET_HashCode *key,
244  uint32_t size,
245  int status,
246  const char *msg);
247 
248 
259 typedef void
261  const struct GNUNET_HashCode *key,
262  uint32_t size,
263  const void *data,
264  PluginRemoveCont cont,
265  void *cont_cls);
266 
267 
278 typedef void
281  void *proc_cls);
282 
283 
295 typedef void
296 (*PluginGetType) (void *cls,
297  uint64_t next_uid,
298  enum GNUNET_BLOCK_Type type,
300  void *proc_cls);
301 
302 
308 typedef void
309 (*PluginDrop) (void *cls);
310 
311 
317 {
318 
323  void *cls;
324 
330 
335 
340 
345 
354 
361 
367 
372 
377 };
378 
379 #endif
380  /* 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 char * expiration
Credential TTL.
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.
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.