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 
71 
76 
80  void *cls;
81 };
82 
83 
100 typedef int
102  const struct GNUNET_HashCode *key,
103  uint32_t size,
104  const void *data,
105  enum GNUNET_BLOCK_Type type,
106  uint32_t priority,
107  uint32_t anonymity,
108  uint32_t replication,
110  uint64_t uid);
111 
112 
124 typedef void
126  unsigned long long *estimate);
127 
128 
139 typedef void
140 (*PluginPutCont) (void *cls,
141  const struct GNUNET_HashCode *key,
142  uint32_t size,
143  int status,
144  const char *msg);
145 
146 
165 typedef void
166 (*PluginPut) (void *cls,
167  const struct GNUNET_HashCode *key,
168  bool absent,
169  uint32_t size,
170  const void *data,
171  enum GNUNET_BLOCK_Type type,
172  uint32_t priority,
173  uint32_t anonymity,
174  uint32_t replication,
176  PluginPutCont cont,
177  void *cont_cls);
178 
179 
187 typedef void
189  const struct GNUNET_HashCode *key,
190  unsigned int count);
191 
192 
200 typedef void
201 (*PluginGetKeys) (void *cls,
202  PluginKeyProcessor proc,
203  void *proc_cls);
204 
205 
219 typedef void
220 (*PluginGetKey) (void *cls,
221  uint64_t next_uid,
222  bool random,
223  const struct GNUNET_HashCode *key,
224  enum GNUNET_BLOCK_Type type,
226  void *proc_cls);
227 
228 
239 typedef void
241  const struct GNUNET_HashCode *key,
242  uint32_t size,
243  int status,
244  const char *msg);
245 
246 
257 typedef void
259  const struct GNUNET_HashCode *key,
260  uint32_t size,
261  const void *data,
262  PluginRemoveCont cont,
263  void *cont_cls);
264 
265 
276 typedef void
279  void *proc_cls);
280 
281 
293 typedef void
294 (*PluginGetType) (void *cls,
295  uint64_t next_uid,
296  enum GNUNET_BLOCK_Type type,
298  void *proc_cls);
299 
300 
306 typedef void
307 (*PluginDrop) (void *cls);
308 
309 
319  void *cls;
320 
326 
331 
336 
341 
350 
357 
363 
368 
373 };
374 
375 #endif
376  /* 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:66
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:83
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.