aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_namestore_service.h
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2023-12-01 22:46:54 +0100
committerMartin Schanzenbach <schanzen@gnunet.org>2023-12-01 22:50:11 +0100
commit663b6fe492691e06fcdcc5ca55b22deefb40ad4b (patch)
tree37659832f67f578fe55e721cdbd0b0f56d596fc6 /src/include/gnunet_namestore_service.h
parent0d77fac87aba598ba53cf4d0606a1a26786e2186 (diff)
downloadgnunet-663b6fe492691e06fcdcc5ca55b22deefb40ad4b.tar.gz
gnunet-663b6fe492691e06fcdcc5ca55b22deefb40ad4b.zip
NAMESTORE: Remove TX API again. Add new edit records API with advisory locking.
Related issues: Issue #7906, Issue #7907
Diffstat (limited to 'src/include/gnunet_namestore_service.h')
-rw-r--r--src/include/gnunet_namestore_service.h146
1 files changed, 84 insertions, 62 deletions
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h
index 61691ff55..5d79ebd13 100644
--- a/src/include/gnunet_namestore_service.h
+++ b/src/include/gnunet_namestore_service.h
@@ -44,9 +44,7 @@
44 44
45#include "gnunet_error_codes.h" 45#include "gnunet_error_codes.h"
46#include "gnunet_util_lib.h" 46#include "gnunet_util_lib.h"
47#include "gnunet_block_lib.h"
48#include "gnunet_gnsrecord_lib.h" 47#include "gnunet_gnsrecord_lib.h"
49#include "gnunet_identity_service.h"
50 48
51#ifdef __cplusplus 49#ifdef __cplusplus
52extern "C" 50extern "C"
@@ -142,6 +140,9 @@ typedef void
142 * 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
143 * monitors do keep up. 141 * monitors do keep up.
144 * 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 *
145 * @param h handle to the namestore 146 * @param h handle to the namestore
146 * @param pkey private key of the zone 147 * @param pkey private key of the zone
147 * @param label name that is being mapped 148 * @param label name that is being mapped
@@ -152,13 +153,13 @@ typedef void
152 * @return handle to abort the request 153 * @return handle to abort the request
153 */ 154 */
154struct GNUNET_NAMESTORE_QueueEntry * 155struct GNUNET_NAMESTORE_QueueEntry *
155GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, 156GNUNET_NAMESTORE_record_set_store (struct GNUNET_NAMESTORE_Handle *h,
156 const struct GNUNET_CRYPTO_PrivateKey *pkey, 157 const struct GNUNET_CRYPTO_PrivateKey *pkey,
157 const char *label, 158 const char *label,
158 unsigned int rd_count, 159 unsigned int rd_count,
159 const struct GNUNET_GNSRECORD_Data *rd, 160 const struct GNUNET_GNSRECORD_Data *rd,
160 GNUNET_NAMESTORE_ContinuationWithStatus cont, 161 GNUNET_NAMESTORE_ContinuationWithStatus cont,
161 void *cont_cls); 162 void *cont_cls);
162 163
163/** 164/**
164 * Store one or more record sets in the namestore. If any item is already present, 165 * Store one or more record sets in the namestore. If any item is already present,
@@ -175,6 +176,9 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h,
175 * cause @a cont to be called immediately before the commit and before 176 * cause @a cont to be called immediately before the commit and before
176 * notification of monitors. 177 * notification of monitors.
177 * 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 *
178 * @param h handle to the namestore 182 * @param h handle to the namestore
179 * @param pkey private key of the zone 183 * @param pkey private key of the zone
180 * @param rd_set_count the number of record sets 184 * @param rd_set_count the number of record sets
@@ -185,7 +189,7 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h,
185 * @return handle to abort the request 189 * @return handle to abort the request
186 */ 190 */
187struct GNUNET_NAMESTORE_QueueEntry * 191struct GNUNET_NAMESTORE_QueueEntry *
188GNUNET_NAMESTORE_records_store2 ( 192GNUNET_NAMESTORE_records_store (
189 struct GNUNET_NAMESTORE_Handle *h, 193 struct GNUNET_NAMESTORE_Handle *h,
190 const struct GNUNET_CRYPTO_PrivateKey *pkey, 194 const struct GNUNET_CRYPTO_PrivateKey *pkey,
191 unsigned int rd_set_count, 195 unsigned int rd_set_count,
@@ -216,16 +220,14 @@ GNUNET_NAMESTORE_records_store2 (
216 * @return handle to abort the request 220 * @return handle to abort the request
217 */ 221 */
218struct GNUNET_NAMESTORE_QueueEntry * 222struct GNUNET_NAMESTORE_QueueEntry *
219GNUNET_NAMESTORE_records_store_ (struct GNUNET_NAMESTORE_Handle *h, 223GNUNET_NAMESTORE_record_set_store_ (struct GNUNET_NAMESTORE_Handle *h,
220 const struct GNUNET_CRYPTO_PrivateKey *pkey, 224 const struct GNUNET_CRYPTO_PrivateKey *pkey,
221 const char *label, 225 const char *label,
222 unsigned int rd_count, 226 unsigned int rd_count,
223 const struct GNUNET_GNSRECORD_Data *rd, 227 const struct GNUNET_GNSRECORD_Data *rd,
224 int is_zonemaster, 228 int is_zonemaster,
225 GNUNET_NAMESTORE_ContinuationWithStatus cont, 229 GNUNET_NAMESTORE_ContinuationWithStatus cont,
226 void *cont_cls); 230 void *cont_cls);
227
228
229 231
230 232
231/** 233/**
@@ -244,6 +246,23 @@ typedef void
244 const char *label, 246 const char *label,
245 unsigned int rd_count, 247 unsigned int rd_count,
246 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 */
259typedef 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);
247 266
248/** 267/**
249 * Process a record set that was stored in the namestore. 268 * Process a record set that was stored in the namestore.
@@ -318,7 +337,6 @@ GNUNET_NAMESTORE_records_lookup2 (struct GNUNET_NAMESTORE_Handle *h,
318 enum GNUNET_GNSRECORD_Filter filter); 337 enum GNUNET_GNSRECORD_Filter filter);
319 338
320 339
321
322/** 340/**
323 * 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.
324 * Returns at most one result to the processor. 342 * Returns at most one result to the processor.
@@ -437,7 +455,6 @@ GNUNET_NAMESTORE_zone_iteration_start2 (struct GNUNET_NAMESTORE_Handle *h,
437 enum GNUNET_GNSRECORD_Filter filter); 455 enum GNUNET_GNSRECORD_Filter filter);
438 456
439 457
440
441/** 458/**
442 * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start 459 * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start
443 * for the next record. 460 * for the next record.
@@ -592,57 +609,62 @@ GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm);
592 */ 609 */
593 610
594/** 611/**
595 * Begin a namestore transaction. 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.
596 * 618 *
597 * @param h handle to the namestore 619 * @param h handle to the namestore
598 * @param cont function to call on result 620 * @param pkey the private key of the zone to edit
599 * @param cont_cls closure for @a cont 621 * @param label the label of the record set to edit
600 * @return handle to abort the request 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
601 */ 628 */
602struct GNUNET_NAMESTORE_QueueEntry * 629struct GNUNET_NAMESTORE_QueueEntry *
603GNUNET_NAMESTORE_transaction_begin (struct GNUNET_NAMESTORE_Handle *h, 630GNUNET_NAMESTORE_record_set_edit_begin (struct GNUNET_NAMESTORE_Handle *h,
604 GNUNET_NAMESTORE_ContinuationWithStatus 631 const struct
605 cont, 632 GNUNET_CRYPTO_PrivateKey *pkey,
606 void *cont_cls); 633 const char *label,
634 const char *editor_hint,
635 GNUNET_NAMESTORE_EditRecordSetBeginCallback
636 edit_cb,
637 void *edit_cb_cls);
607 638
608/** 639/**
609 * Begin rollback all actions in a transaction. 640 * If the current advisory lock is set to the provided editor hint,
610 * Reverts all actions performed since #GNUNET_NAMESTORE_transaction_begin 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.
611 * 645 *
612 * @param h handle to the namestore 646 * If provided editor hint does not match the current advisory lock,
613 * @param cont function to call on result 647 * this function is not doing anything (NOP).
614 * @param cont_cls closure for @a cont
615 * @return handle to abort the request
616 */
617struct GNUNET_NAMESTORE_QueueEntry *
618GNUNET_NAMESTORE_transaction_rollback (struct GNUNET_NAMESTORE_Handle *h,
619 GNUNET_NAMESTORE_ContinuationWithStatus
620 cont,
621 void *cont_cls);
622/**
623 * Commit a namestore transaction.
624 * Saves all actions performed since #GNUNET_NAMESTORE_transaction_begin
625 * 648 *
626 * @param h handle to the namestore 649 * @param h handle to the namestore
627 * @param cont function to call on result 650 * @param pkey the private key of the zone to edit
628 * @param cont_cls closure for @a cont 651 * @param label the label of the record set to edit
629 * @return handle to abort the request 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
630 */ 657 */
631struct GNUNET_NAMESTORE_QueueEntry * 658struct GNUNET_NAMESTORE_QueueEntry *
632GNUNET_NAMESTORE_transaction_commit (struct GNUNET_NAMESTORE_Handle *h, 659GNUNET_NAMESTORE_record_set_edit_cancel (struct GNUNET_NAMESTORE_Handle *h,
633 GNUNET_NAMESTORE_ContinuationWithStatus 660 const struct
634 cont, 661 GNUNET_CRYPTO_PrivateKey *pkey,
635 void *cont_cls); 662 const char *label,
636 663 const char *editor_hint,
637struct GNUNET_NAMESTORE_QueueEntry * 664 const char *editor_hint_replacement,
638GNUNET_NAMESTORE_records_edit ( 665 GNUNET_SCHEDULER_TaskCallback
639 struct GNUNET_NAMESTORE_Handle *h, 666 finished_cb,
640 const struct GNUNET_CRYPTO_PrivateKey *pkey, 667 void *finished_cls);
641 const char *label,
642 GNUNET_SCHEDULER_TaskCallback error_cb,
643 void *error_cb_cls,
644 GNUNET_NAMESTORE_RecordMonitor rm,
645 void *rm_cls);
646 668
647#if 0 /* keep Emacsens' auto-indent happy */ 669#if 0 /* keep Emacsens' auto-indent happy */
648{ 670{