aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_namestore_plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_namestore_plugin.h')
-rw-r--r--src/include/gnunet_namestore_plugin.h138
1 files changed, 73 insertions, 65 deletions
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h
index 3dca5a853..b7bcc4eb6 100644
--- a/src/include/gnunet_namestore_plugin.h
+++ b/src/include/gnunet_namestore_plugin.h
@@ -19,6 +19,9 @@
19 */ 19 */
20 20
21/** 21/**
22 * @addtogroup GNS
23 * @{
24 *
22 * @author Christian Grothoff 25 * @author Christian Grothoff
23 * 26 *
24 * @file 27 * @file
@@ -31,6 +34,7 @@
31#ifndef GNUNET_NAMESTORE_PLUGIN_H 34#ifndef GNUNET_NAMESTORE_PLUGIN_H
32#define GNUNET_NAMESTORE_PLUGIN_H 35#define GNUNET_NAMESTORE_PLUGIN_H
33 36
37
34#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
35#include "gnunet_namestore_service.h" 39#include "gnunet_namestore_service.h"
36 40
@@ -49,6 +53,7 @@ extern "C"
49 * @param cls closure 53 * @param cls closure
50 * @param serial unique serial number of the record, MUST NOT BE ZERO, 54 * @param serial unique serial number of the record, MUST NOT BE ZERO,
51 * and must be monotonically increasing while iterating 55 * and must be monotonically increasing while iterating
56 * @param editor_hint content of the editor field when record was read (may be NULL)
52 * @param zone_key private key of the zone 57 * @param zone_key private key of the zone
53 * @param label name that is being mapped (at most 255 characters long) 58 * @param label name that is being mapped (at most 255 characters long)
54 * @param rd_count number of entries in @a rd array 59 * @param rd_count number of entries in @a rd array
@@ -57,8 +62,9 @@ extern "C"
57typedef void 62typedef void
58(*GNUNET_NAMESTORE_RecordIterator) (void *cls, 63(*GNUNET_NAMESTORE_RecordIterator) (void *cls,
59 uint64_t serial, 64 uint64_t serial,
65 const char *editor_hint,
60 const struct 66 const struct
61 GNUNET_IDENTITY_PrivateKey *private_key, 67 GNUNET_CRYPTO_PrivateKey *private_key,
62 const char *label, 68 const char *label,
63 unsigned int rd_count, 69 unsigned int rd_count,
64 const struct GNUNET_GNSRECORD_Data *rd); 70 const struct GNUNET_GNSRECORD_Data *rd);
@@ -85,12 +91,12 @@ struct GNUNET_NAMESTORE_PluginFunctions
85 * @param rd array of records with data to store 91 * @param rd array of records with data to store
86 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 92 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
87 */ 93 */
88 int 94 enum GNUNET_GenericReturnValue
89 (*store_records) (void *cls, 95 (*store_records)(void *cls,
90 const struct GNUNET_IDENTITY_PrivateKey *zone, 96 const struct GNUNET_CRYPTO_PrivateKey *zone,
91 const char *label, 97 const char *label,
92 unsigned int rd_count, 98 unsigned int rd_count,
93 const struct GNUNET_GNSRECORD_Data *rd); 99 const struct GNUNET_GNSRECORD_Data *rd);
94 100
95 /** 101 /**
96 * Lookup records in the datastore for which we are the authority. 102 * Lookup records in the datastore for which we are the authority.
@@ -102,12 +108,12 @@ struct GNUNET_NAMESTORE_PluginFunctions
102 * @param iter_cls closure for @a iter 108 * @param iter_cls closure for @a iter
103 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR 109 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR
104 */ 110 */
105 int 111 enum GNUNET_GenericReturnValue
106 (*lookup_records) (void *cls, 112 (*lookup_records)(void *cls,
107 const struct GNUNET_IDENTITY_PrivateKey *zone, 113 const struct GNUNET_CRYPTO_PrivateKey *zone,
108 const char *label, 114 const char *label,
109 GNUNET_NAMESTORE_RecordIterator iter, 115 GNUNET_NAMESTORE_RecordIterator iter,
110 void *iter_cls); 116 void *iter_cls);
111 117
112 118
113 /** 119 /**
@@ -124,13 +130,13 @@ struct GNUNET_NAMESTORE_PluginFunctions
124 * @param iter_cls closure for @a iter 130 * @param iter_cls closure for @a iter
125 * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error 131 * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error
126 */ 132 */
127 int 133 enum GNUNET_GenericReturnValue
128 (*iterate_records) (void *cls, 134 (*iterate_records)(void *cls,
129 const struct GNUNET_IDENTITY_PrivateKey *zone, 135 const struct GNUNET_CRYPTO_PrivateKey *zone,
130 uint64_t serial, 136 uint64_t serial,
131 uint64_t limit, 137 uint64_t limit,
132 GNUNET_NAMESTORE_RecordIterator iter, 138 GNUNET_NAMESTORE_RecordIterator iter,
133 void *iter_cls); 139 void *iter_cls);
134 140
135 141
136 /** 142 /**
@@ -144,77 +150,77 @@ struct GNUNET_NAMESTORE_PluginFunctions
144 * @param iter_cls closure for @a iter 150 * @param iter_cls closure for @a iter
145 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 151 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
146 */ 152 */
147 int 153 enum GNUNET_GenericReturnValue
148 (*zone_to_name) (void *cls, 154 (*zone_to_name)(void *cls,
149 const struct GNUNET_IDENTITY_PrivateKey *zone, 155 const struct GNUNET_CRYPTO_PrivateKey *zone,
150 const struct GNUNET_IDENTITY_PublicKey *value_zone, 156 const struct GNUNET_CRYPTO_PublicKey *value_zone,
151 GNUNET_NAMESTORE_RecordIterator iter, 157 GNUNET_NAMESTORE_RecordIterator iter,
152 void *iter_cls); 158 void *iter_cls);
153 159
154 /** Transaction-based API draft **/ 160 /** Transaction-based API draft **/
155 161
156 /** 162 /**
157 * Start a transaction in the database 163 * Edit records in the namestore.
164 * This modifies the editor hint, an advisory lock entry.
165 * The record iterator will be called with the old editor hint (if any).
158 * 166 *
159 * @param cls closure (internal context for the plugin) 167 * @param cls closure (internal context for the plugin)
160 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 168 * @param zone private key of the zone
169 * @param editor_hint the new value for the advisory lock field
170 * @param label name of the record in the zone
171 * @param iter function to call with the result
172 * @param iter_cls closure for @a iter
173 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR
161 */ 174 */
162 enum GNUNET_GenericReturnValue 175 enum GNUNET_GenericReturnValue
163 (*transaction_begin) (void *cls); 176 (*edit_records)(void *cls,
177 const char *editor_hint,
178 const struct GNUNET_CRYPTO_PrivateKey *zone,
179 const char *label,
180 GNUNET_NAMESTORE_RecordIterator iter,
181 void *iter_cls);
164 182
165 /** 183 /**
166 * Abort a transaction in the database 184 * This clears the editor hint, unless it does not match the
185 * given editor hint, in which case this is a NOP.
186 * If a replacement hint is given, it hint is not cleared, but
187 * set to the replacement.
167 * 188 *
168 * @param cls closure (internal context for the plugin) 189 * @param cls closure (internal context for the plugin)
169 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 190 * @param zone private key of the zone
191 * @param editor_hint the new value for the advisory lock field
192 * @param editor_hint_replacement an optional value to use instead of a clear
193 * @param label name of the record in the zone
194 * @param iter function to call with the result
195 * @param iter_cls closure for @a iter
196 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR
170 */ 197 */
171 enum GNUNET_GenericReturnValue 198 enum GNUNET_GenericReturnValue
172 (*transaction_abort) (void *cls); 199 (*clear_editor_hint)(void *cls,
200 const char *editor_hint,
201 const char *editor_hint_replacement,
202 const struct GNUNET_CRYPTO_PrivateKey *zone,
203 const char *label);
173 204
174 /** 205 /**
175 * Commit a transaction in the database 206 * Setup the database.
176 * 207 *
177 * @param cls closure (internal context for the plugin) 208 * @param cls closure (internal context for the plugin)
178 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 209 * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR
179 */ 210 */
180 enum GNUNET_GenericReturnValue 211 enum GNUNET_GenericReturnValue
181 (*transaction_commit) (void *cls); 212 (*create_tables)(void *cls);
182 213
183 /**
184 * Replace a record in the datastore for which we are the authority.
185 * Removes any existing record in the same zone with the same name.
186 *
187 * @param cls closure (internal context for the plugin)
188 * @param zone private key of the zone
189 * @param label name of the record in the zone
190 * @param rd_count number of entries in @a rd array, 0 to delete all records
191 * @param rd array of records with data to store
192 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
193 */
194 int
195 (*replace_records) (void *cls,
196 const struct GNUNET_IDENTITY_PrivateKey *zone,
197 const char *label,
198 unsigned int rd_count,
199 const struct GNUNET_GNSRECORD_Data *rd);
200 214
201 /** 215 /**
202 * Lookup records in the datastore for which we are the authority. 216 * Drop existing tables.
217 * DANGEROUS: All existing data in the dabase will be lost!
203 * 218 *
204 * @param cls closure (internal context for the plugin) 219 * @param cls closure (internal context for the plugin)
205 * @param zone private key of the zone 220 * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR
206 * @param label name of the record in the zone
207 * @param iter function to call with the result
208 * @param iter_cls closure for @a iter
209 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR
210 */ 221 */
211 int 222 enum GNUNET_GenericReturnValue
212 (*select_records) (void *cls, 223 (*drop_tables)(void *cls);
213 const struct GNUNET_IDENTITY_PrivateKey *zone,
214 const char *label,
215 GNUNET_NAMESTORE_RecordIterator iter,
216 void *iter_cls);
217
218}; 224};
219 225
220 226
@@ -228,3 +234,5 @@ struct GNUNET_NAMESTORE_PluginFunctions
228#endif 234#endif
229 235
230/** @} */ /* end of group */ 236/** @} */ /* end of group */
237
238/** @} */ /* end of group addition */