diff options
Diffstat (limited to 'src/include/gnunet_namestore_service.h')
-rw-r--r-- | src/include/gnunet_namestore_service.h | 344 |
1 files changed, 326 insertions, 18 deletions
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index 2482b97a5..0f9be8b10 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.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 |
@@ -38,10 +41,10 @@ | |||
38 | #ifndef GNUNET_NAMESTORE_SERVICE_H | 41 | #ifndef GNUNET_NAMESTORE_SERVICE_H |
39 | #define GNUNET_NAMESTORE_SERVICE_H | 42 | #define GNUNET_NAMESTORE_SERVICE_H |
40 | 43 | ||
44 | |||
45 | #include "gnunet_error_codes.h" | ||
41 | #include "gnunet_util_lib.h" | 46 | #include "gnunet_util_lib.h" |
42 | #include "gnunet_block_lib.h" | ||
43 | #include "gnunet_gnsrecord_lib.h" | 47 | #include "gnunet_gnsrecord_lib.h" |
44 | #include "gnunet_identity_service.h" | ||
45 | 48 | ||
46 | #ifdef __cplusplus | 49 | #ifdef __cplusplus |
47 | extern "C" | 50 | extern "C" |
@@ -67,6 +70,28 @@ struct GNUNET_NAMESTORE_Handle; | |||
67 | */ | 70 | */ |
68 | struct GNUNET_NAMESTORE_ZoneIterator; | 71 | struct GNUNET_NAMESTORE_ZoneIterator; |
69 | 72 | ||
73 | /** | ||
74 | * Transaction control types. | ||
75 | * They roughly correspond to DB transaction controls | ||
76 | */ | ||
77 | enum GNUNET_NAMESTORE_TxControl | ||
78 | { | ||
79 | GNUNET_NAMESTORE_TX_BEGIN = 0, | ||
80 | GNUNET_NAMESTORE_TX_COMMIT = 1, | ||
81 | GNUNET_NAMESTORE_TX_ROLLBACK = 2, | ||
82 | }; | ||
83 | |||
84 | /** | ||
85 | * A struct for record bulk import. | ||
86 | * The fields are arrays pointing to individual GNS records and names. | ||
87 | */ | ||
88 | struct GNUNET_NAMESTORE_RecordInfo | ||
89 | { | ||
90 | const char *a_label; | ||
91 | unsigned int a_rd_count; | ||
92 | struct GNUNET_GNSRECORD_Data *a_rd; | ||
93 | }; | ||
94 | |||
70 | 95 | ||
71 | /** | 96 | /** |
72 | * Connect to the namestore service. | 97 | * Connect to the namestore service. |
@@ -97,12 +122,11 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h); | |||
97 | * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) | 122 | * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) |
98 | * #GNUNET_NO if content was already there or not found | 123 | * #GNUNET_NO if content was already there or not found |
99 | * #GNUNET_YES (or other positive value) on success | 124 | * #GNUNET_YES (or other positive value) on success |
100 | * @param emsg NULL on success, otherwise an error message | 125 | * @param ec the #GNUNET_ErrorCode, #GNUNET_EC_NONE on success. |
101 | */ | 126 | */ |
102 | typedef void | 127 | typedef void |
103 | (*GNUNET_NAMESTORE_ContinuationWithStatus) (void *cls, | 128 | (*GNUNET_NAMESTORE_ContinuationWithStatus) (void *cls, |
104 | int32_t success, | 129 | enum GNUNET_ErrorCode ec); |
105 | const char *emsg); | ||
106 | 130 | ||
107 | 131 | ||
108 | /** | 132 | /** |
@@ -116,6 +140,9 @@ typedef void | |||
116 | * keep up with the changes, calling @a cont will be delayed until the | 140 | * keep up with the changes, calling @a cont will be delayed until the |
117 | * monitors do keep up. | 141 | * monitors do keep up. |
118 | * | 142 | * |
143 | * This always overwrites the record set and unsets any advisory | ||
144 | * lock inrrespective of the currently set editor hint/advisory lock value. | ||
145 | * | ||
119 | * @param h handle to the namestore | 146 | * @param h handle to the namestore |
120 | * @param pkey private key of the zone | 147 | * @param pkey private key of the zone |
121 | * @param label name that is being mapped | 148 | * @param label name that is being mapped |
@@ -126,13 +153,81 @@ typedef void | |||
126 | * @return handle to abort the request | 153 | * @return handle to abort the request |
127 | */ | 154 | */ |
128 | struct GNUNET_NAMESTORE_QueueEntry * | 155 | struct GNUNET_NAMESTORE_QueueEntry * |
129 | GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | 156 | GNUNET_NAMESTORE_record_set_store (struct GNUNET_NAMESTORE_Handle *h, |
130 | const struct GNUNET_IDENTITY_PrivateKey *pkey, | 157 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
131 | const char *label, | 158 | const char *label, |
132 | unsigned int rd_count, | 159 | unsigned int rd_count, |
133 | const struct GNUNET_GNSRECORD_Data *rd, | 160 | const struct GNUNET_GNSRECORD_Data *rd, |
134 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 161 | GNUNET_NAMESTORE_ContinuationWithStatus cont, |
135 | void *cont_cls); | 162 | void *cont_cls); |
163 | |||
164 | /** | ||
165 | * Store one or more record sets in the namestore. If any item is already present, | ||
166 | * it is replaced with the new record. Use an empty array to | ||
167 | * remove all records under the given name. | ||
168 | * | ||
169 | * The continuation is called after the records have been stored in the | ||
170 | * database. They may not yet have been commited. Monitors may be notified | ||
171 | * asynchronously (basically with a buffer when commited). | ||
172 | * However, if any monitor is consistently too slow to | ||
173 | * keep up with the changes, calling @a cont will be delayed until the | ||
174 | * monitors do keep up. | ||
175 | * Uncommited store requests within a transaction (GNUNET_NAMESTORE_transaction_begin) | ||
176 | * cause @a cont to be called immediately before the commit and before | ||
177 | * notification of monitors. | ||
178 | * | ||
179 | * This always overwrites the record set and unsets any advisory | ||
180 | * lock inrrespective of the currently set editor hint/advisory lock value. | ||
181 | * | ||
182 | * @param h handle to the namestore | ||
183 | * @param pkey private key of the zone | ||
184 | * @param rd_set_count the number of record sets | ||
185 | * @param record_info the records to add containing @a rd_set_count records | ||
186 | * @param cont continuation to call when done | ||
187 | * @param rds_sent set to how many record sets could actually be sent | ||
188 | * @param cont_cls closure for @a cont | ||
189 | * @return handle to abort the request | ||
190 | */ | ||
191 | struct GNUNET_NAMESTORE_QueueEntry * | ||
192 | GNUNET_NAMESTORE_records_store ( | ||
193 | struct GNUNET_NAMESTORE_Handle *h, | ||
194 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | ||
195 | unsigned int rd_set_count, | ||
196 | const struct GNUNET_NAMESTORE_RecordInfo *record_info, | ||
197 | unsigned int *rds_sent, | ||
198 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | ||
199 | void *cont_cls); | ||
200 | |||
201 | /** | ||
202 | * Store an item in the namestore. If the item is already present, | ||
203 | * it is replaced with the new record. Use an empty array to | ||
204 | * remove all records under the given name. | ||
205 | * | ||
206 | * The continuation is called after the value has been stored in the | ||
207 | * database. Monitors may be notified asynchronously (basically with | ||
208 | * a buffer). However, if any monitor is consistently too slow to | ||
209 | * keep up with the changes, calling @a cont will be delayed until the | ||
210 | * monitors do keep up. | ||
211 | * | ||
212 | * @param h handle to the namestore | ||
213 | * @param pkey private key of the zone | ||
214 | * @param label name that is being mapped | ||
215 | * @param rd_count number of records in the 'rd' array | ||
216 | * @param rd array of records with data to store | ||
217 | * @param is_zonemaster update tombstones, do not process monitors | ||
218 | * @param cont continuation to call when done | ||
219 | * @param cont_cls closure for @a cont | ||
220 | * @return handle to abort the request | ||
221 | */ | ||
222 | struct GNUNET_NAMESTORE_QueueEntry * | ||
223 | GNUNET_NAMESTORE_record_set_store_ (struct GNUNET_NAMESTORE_Handle *h, | ||
224 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | ||
225 | const char *label, | ||
226 | unsigned int rd_count, | ||
227 | const struct GNUNET_GNSRECORD_Data *rd, | ||
228 | int is_zonemaster, | ||
229 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | ||
230 | void *cont_cls); | ||
136 | 231 | ||
137 | 232 | ||
138 | /** | 233 | /** |
@@ -147,10 +242,48 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | |||
147 | typedef void | 242 | typedef void |
148 | (*GNUNET_NAMESTORE_RecordMonitor) (void *cls, | 243 | (*GNUNET_NAMESTORE_RecordMonitor) (void *cls, |
149 | const struct | 244 | const struct |
150 | GNUNET_IDENTITY_PrivateKey *zone, | 245 | GNUNET_CRYPTO_PrivateKey *zone, |
151 | const char *label, | 246 | const char *label, |
152 | unsigned int rd_count, | 247 | unsigned int rd_count, |
153 | const struct GNUNET_GNSRECORD_Data *rd); | 248 | const struct GNUNET_GNSRECORD_Data *rd); |
249 | /** | ||
250 | * Process a record that was stored in the namestore. | ||
251 | * | ||
252 | * @param cls closure | ||
253 | * @param ec the error code. #GNUNET_EC_NONE on success. | ||
254 | * @param rd_count number of entries in @a rd array, 0 if label was deleted | ||
255 | * @param rd array of records with data to store | ||
256 | * @param editor_hint the advisory lock value that was replaced. NULL of not advisory lock | ||
257 | was set or if lock was equal to provided editor hint. | ||
258 | */ | ||
259 | typedef void | ||
260 | (*GNUNET_NAMESTORE_EditRecordSetBeginCallback) (void *cls, | ||
261 | enum GNUNET_ErrorCode ec, | ||
262 | unsigned int rd_count, | ||
263 | const struct | ||
264 | GNUNET_GNSRECORD_Data *rd, | ||
265 | const char *editor_hint); | ||
266 | |||
267 | /** | ||
268 | * Process a record set that was stored in the namestore. | ||
269 | * The record set expiration value takes existing TOMBSTONE records | ||
270 | * into account even if those are not returned. | ||
271 | * | ||
272 | * @param cls closure | ||
273 | * @param zone private key of the zone | ||
274 | * @param label label of the records | ||
275 | * @param rd_count number of entries in @a rd array, 0 if label was deleted | ||
276 | * @param rd array of records with data to store | ||
277 | * @param expiry the expiration of this record set. | ||
278 | */ | ||
279 | typedef void | ||
280 | (*GNUNET_NAMESTORE_RecordSetMonitor) (void *cls, | ||
281 | const struct | ||
282 | GNUNET_CRYPTO_PrivateKey *zone, | ||
283 | const char *label, | ||
284 | unsigned int rd_count, | ||
285 | const struct GNUNET_GNSRECORD_Data *rd, | ||
286 | struct GNUNET_TIME_Absolute expiry); | ||
154 | 287 | ||
155 | 288 | ||
156 | /** | 289 | /** |
@@ -170,13 +303,39 @@ typedef void | |||
170 | struct GNUNET_NAMESTORE_QueueEntry * | 303 | struct GNUNET_NAMESTORE_QueueEntry * |
171 | GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, | 304 | GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, |
172 | const struct | 305 | const struct |
173 | GNUNET_IDENTITY_PrivateKey *pkey, | 306 | GNUNET_CRYPTO_PrivateKey *pkey, |
174 | const char *label, | 307 | const char *label, |
175 | GNUNET_SCHEDULER_TaskCallback error_cb, | 308 | GNUNET_SCHEDULER_TaskCallback error_cb, |
176 | void *error_cb_cls, | 309 | void *error_cb_cls, |
177 | GNUNET_NAMESTORE_RecordMonitor rm, | 310 | GNUNET_NAMESTORE_RecordMonitor rm, |
178 | void *rm_cls); | 311 | void *rm_cls); |
179 | 312 | ||
313 | /** | ||
314 | * Lookup an item in the namestore with GNSRECORD filter. | ||
315 | * | ||
316 | * @param h handle to the namestore | ||
317 | * @param pkey private key of the zone | ||
318 | * @param label name that is being mapped | ||
319 | * @param error_cb function to call on error (i.e. disconnect) | ||
320 | * the handle is afterwards invalid | ||
321 | * @param error_cb_cls closure for @a error_cb | ||
322 | * @param rm function to call with the result (with 0 records if we don't have that label); | ||
323 | * the handle is afterwards invalid | ||
324 | * @param rm_cls closure for @a rm | ||
325 | * @param filter the record set filter to use | ||
326 | * @return handle to abort the request | ||
327 | */ | ||
328 | struct GNUNET_NAMESTORE_QueueEntry * | ||
329 | GNUNET_NAMESTORE_records_lookup2 (struct GNUNET_NAMESTORE_Handle *h, | ||
330 | const struct | ||
331 | GNUNET_CRYPTO_PrivateKey *pkey, | ||
332 | const char *label, | ||
333 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
334 | void *error_cb_cls, | ||
335 | GNUNET_NAMESTORE_RecordMonitor rm, | ||
336 | void *rm_cls, | ||
337 | enum GNUNET_GNSRECORD_Filter filter); | ||
338 | |||
180 | 339 | ||
181 | /** | 340 | /** |
182 | * Look for an existing PKEY delegation record for a given public key. | 341 | * Look for an existing PKEY delegation record for a given public key. |
@@ -197,9 +356,9 @@ GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, | |||
197 | */ | 356 | */ |
198 | struct GNUNET_NAMESTORE_QueueEntry * | 357 | struct GNUNET_NAMESTORE_QueueEntry * |
199 | GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, | 358 | GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, |
200 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 359 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
201 | const struct | 360 | const struct |
202 | GNUNET_IDENTITY_PublicKey *value_zone, | 361 | GNUNET_CRYPTO_PublicKey *value_zone, |
203 | GNUNET_SCHEDULER_TaskCallback error_cb, | 362 | GNUNET_SCHEDULER_TaskCallback error_cb, |
204 | void *error_cb_cls, | 363 | void *error_cb_cls, |
205 | GNUNET_NAMESTORE_RecordMonitor proc, | 364 | GNUNET_NAMESTORE_RecordMonitor proc, |
@@ -219,6 +378,9 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe); | |||
219 | 378 | ||
220 | 379 | ||
221 | /** | 380 | /** |
381 | * @deprecated since 0.16.7 will be replaced in 0.18 | ||
382 | * @see GNUNET_NAMESTORE_zone_iteration_start2() | ||
383 | * | ||
222 | * Starts a new zone iteration (used to periodically PUT all of our | 384 | * Starts a new zone iteration (used to periodically PUT all of our |
223 | * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle` | 385 | * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle` |
224 | * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and | 386 | * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and |
@@ -246,7 +408,7 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe); | |||
246 | struct GNUNET_NAMESTORE_ZoneIterator * | 408 | struct GNUNET_NAMESTORE_ZoneIterator * |
247 | GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, | 409 | GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, |
248 | const struct | 410 | const struct |
249 | GNUNET_IDENTITY_PrivateKey *zone, | 411 | GNUNET_CRYPTO_PrivateKey *zone, |
250 | GNUNET_SCHEDULER_TaskCallback error_cb, | 412 | GNUNET_SCHEDULER_TaskCallback error_cb, |
251 | void *error_cb_cls, | 413 | void *error_cb_cls, |
252 | GNUNET_NAMESTORE_RecordMonitor proc, | 414 | GNUNET_NAMESTORE_RecordMonitor proc, |
@@ -254,6 +416,44 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, | |||
254 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 416 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
255 | void *finish_cb_cls); | 417 | void *finish_cb_cls); |
256 | 418 | ||
419 | /** | ||
420 | * Starts a new zone iteration (used to periodically PUT all of our | ||
421 | * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle` | ||
422 | * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and | ||
423 | * #GNUNET_NAMESTORE_zone_iteration_stop. @a proc will be called once | ||
424 | * immediately, and then again after | ||
425 | * #GNUNET_NAMESTORE_zone_iterator_next() is invoked. | ||
426 | * | ||
427 | * On error (disconnect), @a error_cb will be invoked. | ||
428 | * On normal completion, @a finish_cb proc will be | ||
429 | * invoked. | ||
430 | * | ||
431 | * @param h handle to the namestore | ||
432 | * @param zone zone to access, NULL for all zones | ||
433 | * @param error_cb function to call on error (i.e. disconnect), | ||
434 | * the handle is afterwards invalid | ||
435 | * @param error_cb_cls closure for @a error_cb | ||
436 | * @param proc function to call on each name from the zone; it | ||
437 | * will be called repeatedly with a value (if available) | ||
438 | * @param proc_cls closure for @a proc | ||
439 | * @param finish_cb function to call on completion | ||
440 | * the handle is afterwards invalid | ||
441 | * @param finish_cb_cls closure for @a finish_cb | ||
442 | * @param filter the record set filter to use | ||
443 | * @return an iterator handle to use for iteration | ||
444 | */ | ||
445 | struct GNUNET_NAMESTORE_ZoneIterator * | ||
446 | GNUNET_NAMESTORE_zone_iteration_start2 (struct GNUNET_NAMESTORE_Handle *h, | ||
447 | const struct | ||
448 | GNUNET_CRYPTO_PrivateKey *zone, | ||
449 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
450 | void *error_cb_cls, | ||
451 | GNUNET_NAMESTORE_RecordSetMonitor proc, | ||
452 | void *proc_cls, | ||
453 | GNUNET_SCHEDULER_TaskCallback finish_cb, | ||
454 | void *finish_cb_cls, | ||
455 | enum GNUNET_GNSRECORD_Filter filter); | ||
456 | |||
257 | 457 | ||
258 | /** | 458 | /** |
259 | * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start | 459 | * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start |
@@ -286,6 +486,9 @@ struct GNUNET_NAMESTORE_ZoneMonitor; | |||
286 | 486 | ||
287 | 487 | ||
288 | /** | 488 | /** |
489 | * @deprecated since 0.16.7 will be replaced in 0.18 | ||
490 | * @see GNUNET_NAMESTORE_zone_monitor_start2() | ||
491 | * | ||
289 | * Begin monitoring a zone for changes. Will first call the @a | 492 | * Begin monitoring a zone for changes. Will first call the @a |
290 | * monitor function on all existing records in the selected zone(s) if | 493 | * monitor function on all existing records in the selected zone(s) if |
291 | * @a iterate_first is #GNUNET_YES. In any case, we will then call @a | 494 | * @a iterate_first is #GNUNET_YES. In any case, we will then call @a |
@@ -315,7 +518,7 @@ struct GNUNET_NAMESTORE_ZoneMonitor; | |||
315 | struct GNUNET_NAMESTORE_ZoneMonitor * | 518 | struct GNUNET_NAMESTORE_ZoneMonitor * |
316 | GNUNET_NAMESTORE_zone_monitor_start ( | 519 | GNUNET_NAMESTORE_zone_monitor_start ( |
317 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 520 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
318 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 521 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
319 | int iterate_first, | 522 | int iterate_first, |
320 | GNUNET_SCHEDULER_TaskCallback error_cb, | 523 | GNUNET_SCHEDULER_TaskCallback error_cb, |
321 | void *error_cb_cls, | 524 | void *error_cb_cls, |
@@ -324,6 +527,47 @@ GNUNET_NAMESTORE_zone_monitor_start ( | |||
324 | GNUNET_SCHEDULER_TaskCallback sync_cb, | 527 | GNUNET_SCHEDULER_TaskCallback sync_cb, |
325 | void *sync_cb_cls); | 528 | void *sync_cb_cls); |
326 | 529 | ||
530 | /** | ||
531 | * Begin monitoring a zone for changes. Will first call the @a | ||
532 | * monitor function on all existing records in the selected zone(s) if | ||
533 | * @a iterate_first is #GNUNET_YES. In any case, we will then call @a | ||
534 | * sync_cb, and then afterwards call the @a monitor whenever a record | ||
535 | * changes. If the namestore disconnects, the @a error_cb function is | ||
536 | * called with a disconnect event. Once the connection is | ||
537 | * re-established, the process begins from the start (depending on @a | ||
538 | * iterate_first, we will again first do all existing records, then @a | ||
539 | * sync, then updates). | ||
540 | * | ||
541 | * @param cfg configuration to use to connect to namestore | ||
542 | * @param zone zone to monitor, NULL for all zones | ||
543 | * @param iterate_first #GNUNET_YES to first iterate over all existing records, | ||
544 | * #GNUNET_NO to only return changes that happen from now on | ||
545 | * @param error_cb function to call on error (i.e. disconnect); note that | ||
546 | * unlike the other error callbacks in this API, a call to this | ||
547 | * function does NOT destroy the monitor handle, it merely signals | ||
548 | * that monitoring is down. You need to still explicitly call | ||
549 | * #GNUNET_NAMESTORE_zone_monitor_stop(). | ||
550 | * @param error_cb_cls closure for @a error_cb | ||
551 | * @param monitor function to call on zone changes, with an initial limit of 1 | ||
552 | * @param monitor_cls closure for @a monitor | ||
553 | * @param sync_cb function called when we're in sync with the namestore | ||
554 | * @param sync_cb_cls closure for @a sync_cb | ||
555 | * @param filter the record set filter to use | ||
556 | * @return handle to stop monitoring | ||
557 | */ | ||
558 | struct GNUNET_NAMESTORE_ZoneMonitor * | ||
559 | GNUNET_NAMESTORE_zone_monitor_start2 ( | ||
560 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
561 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
562 | int iterate_first, | ||
563 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
564 | void *error_cb_cls, | ||
565 | GNUNET_NAMESTORE_RecordSetMonitor monitor, | ||
566 | void *monitor_cls, | ||
567 | GNUNET_SCHEDULER_TaskCallback sync_cb, | ||
568 | void *sync_cb_cls, | ||
569 | enum GNUNET_GNSRECORD_Filter filter); | ||
570 | |||
327 | 571 | ||
328 | /** | 572 | /** |
329 | * Calls the monitor processor specified in #GNUNET_NAMESTORE_zone_monitor_start | 573 | * Calls the monitor processor specified in #GNUNET_NAMESTORE_zone_monitor_start |
@@ -360,6 +604,68 @@ void | |||
360 | GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm); | 604 | GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm); |
361 | 605 | ||
362 | 606 | ||
607 | /** | ||
608 | * New API draft. Experimental | ||
609 | */ | ||
610 | |||
611 | /** | ||
612 | * This function is used to initiate the editing | ||
613 | * of a record set under #label. | ||
614 | * It will set the editor hint of the record set to #editor_hint. | ||
615 | * The editor hint serves as an advisory lock that is used in | ||
616 | * #GNUNET_NAMESTORE_EdtirRecordSetBeginCallback if #editor_hint | ||
617 | * differs from the currently set advisory lock in the database. | ||
618 | * | ||
619 | * @param h handle to the namestore | ||
620 | * @param pkey the private key of the zone to edit | ||
621 | * @param label the label of the record set to edit | ||
622 | * @param editor_hint the editor hint to set as advisory lock | ||
623 | * @param error_cb the error callback | ||
624 | * @param error_cb_cls closure to #error_cb | ||
625 | * @param edit_cb the #GNUNET_NAMESTORE_EditRecordSetBeginCallback | ||
626 | * @param edit_cb_cls closure to #edit_cb | ||
627 | * @return handle to the operation | ||
628 | */ | ||
629 | struct GNUNET_NAMESTORE_QueueEntry * | ||
630 | GNUNET_NAMESTORE_record_set_edit_begin (struct GNUNET_NAMESTORE_Handle *h, | ||
631 | const struct | ||
632 | GNUNET_CRYPTO_PrivateKey *pkey, | ||
633 | const char *label, | ||
634 | const char *editor_hint, | ||
635 | GNUNET_NAMESTORE_EditRecordSetBeginCallback | ||
636 | edit_cb, | ||
637 | void *edit_cb_cls); | ||
638 | |||
639 | /** | ||
640 | * If the current advisory lock is set to the provided editor hint, | ||
641 | * this API cancels the editing of a record set and unsets the advisory lock in database. | ||
642 | * Optionally, a new editor hint can be provided: For example, | ||
643 | * the value that was returned in in the callback to | ||
644 | * #GNUNET_NAMESTORE_record_set_edit_begin. | ||
645 | * | ||
646 | * If provided editor hint does not match the current advisory lock, | ||
647 | * this function is not doing anything (NOP). | ||
648 | * | ||
649 | * @param h handle to the namestore | ||
650 | * @param pkey the private key of the zone to edit | ||
651 | * @param label the label of the record set to edit | ||
652 | * @param editor_hint the editor hint to set as advisory lock | ||
653 | * @param editor_hint_replacement the editor hint to set as advisory lock instead of clearing it | ||
654 | * @param finished_cb the callback called when cancelled | ||
655 | * @param finished_cb_cls closure to #finished_cb | ||
656 | * @return handle to the operation | ||
657 | */ | ||
658 | struct GNUNET_NAMESTORE_QueueEntry * | ||
659 | GNUNET_NAMESTORE_record_set_edit_cancel (struct GNUNET_NAMESTORE_Handle *h, | ||
660 | const struct | ||
661 | GNUNET_CRYPTO_PrivateKey *pkey, | ||
662 | const char *label, | ||
663 | const char *editor_hint, | ||
664 | const char *editor_hint_replacement, | ||
665 | GNUNET_NAMESTORE_ContinuationWithStatus | ||
666 | finished_cb, | ||
667 | void *finished_cls); | ||
668 | |||
363 | #if 0 /* keep Emacsens' auto-indent happy */ | 669 | #if 0 /* keep Emacsens' auto-indent happy */ |
364 | { | 670 | { |
365 | #endif | 671 | #endif |
@@ -370,3 +676,5 @@ GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm); | |||
370 | #endif | 676 | #endif |
371 | 677 | ||
372 | /** @} */ /* end of group */ | 678 | /** @} */ /* end of group */ |
679 | |||
680 | /** @} */ /* end of group addition */ | ||