Exponential backoff for find finger trail task
[oweals/gnunet.git] / src / include / gnunet_peerstore_plugin.h
1 /*
2      This file is part of GNUnet
3      (C) 2012, 2013 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file include/gnunet_peerstore_plugin.h
23  * @brief plugin API for the peerstore database backend
24  * @author Omar Tarabai
25  */
26 #ifndef GNUNET_PEERSTORE_PLUGIN_H
27 #define GNUNET_PEERSTORE_PLUGIN_H
28
29 #include "gnunet_util_lib.h"
30 #include "gnunet_peerstore_service.h"
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #if 0                           /* keep Emacsens' auto-indent happy */
36 }
37 #endif
38 #endif
39
40
41 /**
42  * @brief struct returned by the initialization function of the plugin
43  */
44 struct GNUNET_PEERSTORE_PluginFunctions
45 {
46
47   /**
48    * Closure to pass to all plugin functions.
49    */
50   void *cls;
51
52   /**
53    * Store a record in the peerstore.
54    * Key is the combination of sub system and peer identity.
55    * One key can store multiple values.
56    *
57    * @param cls closure (internal context for the plugin)
58    * @param sub_system name of the GNUnet sub system responsible
59    * @param peer peer identity
60    * @param value value to be stored
61    * @param size size of value to be stored
62    * @return #GNUNET_OK on success, else #GNUNET_SYSERR
63    */
64   int
65   (*store_record) (void *cls,
66       const char *sub_system,
67       const struct GNUNET_PeerIdentity *peer,
68       const char *key,
69       const void *value,
70       size_t size,
71       struct GNUNET_TIME_Absolute expiry,
72       enum GNUNET_PEERSTORE_StoreOption options);
73
74   /**
75    * Iterate over the records given an optional peer id
76    * and/or key.
77    *
78    * @param cls closure (internal context for the plugin)
79    * @param sub_system name of sub system
80    * @param peer Peer identity (can be NULL)
81    * @param key entry key string (can be NULL)
82    * @param iter function to call with the result
83    * @param iter_cls closure for @a iter
84    * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
85    */
86   int
87   (*iterate_records) (void *cls,
88       const char *sub_system,
89       const struct GNUNET_PeerIdentity *peer,
90       const char *key,
91       GNUNET_PEERSTORE_Processor iter, void *iter_cls);
92
93   /**
94    * Delete expired records (expiry < now)
95    *
96    * @param cls closure (internal context for the plugin)
97    * @param now time to use as reference
98    * @return number of records deleted
99    */
100   int
101   (*expire_records) (void *cls,
102       struct GNUNET_TIME_Absolute now);
103
104 };
105
106
107 #if 0                           /* keep Emacsens' auto-indent happy */
108 {
109 #endif
110 #ifdef __cplusplus
111 }
112 #endif
113
114 /* end of gnunet_peerstore_plugin.h */
115 #endif