aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim')
-rw-r--r--src/reclaim/gnunet-reclaim.c68
-rw-r--r--src/reclaim/gnunet-service-reclaim.c1
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c237
-rw-r--r--src/reclaim/plugin_gnsrecord_reclaim.c27
4 files changed, 97 insertions, 236 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index 0e5591d69..1c3b4174d 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -157,7 +157,8 @@ static struct GNUNET_SCHEDULER_Task *cleanup_task;
157 */ 157 */
158struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 158struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
159 159
160static void do_cleanup (void *cls) 160static void
161do_cleanup (void *cls)
161{ 162{
162 cleanup_task = NULL; 163 cleanup_task = NULL;
163 if (NULL != timeout) 164 if (NULL != timeout)
@@ -178,8 +179,8 @@ static void do_cleanup (void *cls)
178 GNUNET_free (attr_list); 179 GNUNET_free (attr_list);
179} 180}
180 181
181static void ticket_issue_cb (void *cls, 182static void
182 const struct GNUNET_RECLAIM_Ticket *ticket) 183ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
183{ 184{
184 char *ticket_str; 185 char *ticket_str;
185 reclaim_op = NULL; 186 reclaim_op = NULL;
@@ -192,7 +193,8 @@ static void ticket_issue_cb (void *cls,
192 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 193 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
193} 194}
194 195
195static void store_attr_cont (void *cls, int32_t success, const char *emsg) 196static void
197store_attr_cont (void *cls, int32_t success, const char *emsg)
196{ 198{
197 reclaim_op = NULL; 199 reclaim_op = NULL;
198 if (GNUNET_SYSERR == success) { 200 if (GNUNET_SYSERR == success) {
@@ -201,9 +203,9 @@ static void store_attr_cont (void *cls, int32_t success, const char *emsg)
201 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 203 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
202} 204}
203 205
204static void process_attrs (void *cls, 206static void
205 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 207process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
206 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 208 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
207{ 209{
208 char *value_str; 210 char *value_str;
209 const char *attr_type; 211 const char *attr_type;
@@ -224,33 +226,45 @@ static void process_attrs (void *cls,
224 attr_type, attr->version, attr->id); 226 attr_type, attr->version, attr->id);
225} 227}
226 228
227static void ticket_iter_err (void *cls) 229static void
230ticket_iter_err (void *cls)
228{ 231{
229 ticket_iterator = NULL; 232 ticket_iterator = NULL;
230 fprintf (stderr, "Failed to iterate over tickets\n"); 233 fprintf (stderr, "Failed to iterate over tickets\n");
231 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 234 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
232} 235}
233 236
234static void ticket_iter_fin (void *cls) 237static void
238ticket_iter_fin (void *cls)
235{ 239{
236 ticket_iterator = NULL; 240 ticket_iterator = NULL;
237 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 241 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
238} 242}
239 243
240static void ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) 244static void
245ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
241{ 246{
242 fprintf (stdout, "Found ticket\n"); 247 char *aud;
248 char *ref;
249
250 aud = GNUNET_STRINGS_data_to_string_alloc (
251 &ticket->audience, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
252 ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t));
253
254 fprintf (stdout, "Ticket ID: %s | Audience: %s\n", ref, aud);
243 GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator); 255 GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
244} 256}
245 257
246static void iter_error (void *cls) 258static void
259iter_error (void *cls)
247{ 260{
248 attr_iterator = NULL; 261 attr_iterator = NULL;
249 fprintf (stderr, "Failed to iterate over attributes\n"); 262 fprintf (stderr, "Failed to iterate over attributes\n");
250 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 263 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
251} 264}
252 265
253static void timeout_task (void *cls) 266static void
267timeout_task (void *cls)
254{ 268{
255 timeout = NULL; 269 timeout = NULL;
256 ret = 1; 270 ret = 1;
@@ -259,7 +273,8 @@ static void timeout_task (void *cls)
259 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 273 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
260} 274}
261 275
262static void process_rvk (void *cls, int success, const char *msg) 276static void
277process_rvk (void *cls, int success, const char *msg)
263{ 278{
264 reclaim_op = NULL; 279 reclaim_op = NULL;
265 if (GNUNET_OK != success) { 280 if (GNUNET_OK != success) {
@@ -269,7 +284,8 @@ static void process_rvk (void *cls, int success, const char *msg)
269 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 284 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
270} 285}
271 286
272static void iter_finished (void *cls) 287static void
288iter_finished (void *cls)
273{ 289{
274 char *data; 290 char *data;
275 size_t data_size; 291 size_t data_size;
@@ -325,9 +341,9 @@ static void iter_finished (void *cls)
325 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 341 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
326} 342}
327 343
328static void iter_cb (void *cls, 344static void
329 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 345iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
330 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 346 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
331{ 347{
332 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 348 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
333 char *attrs_tmp; 349 char *attrs_tmp;
@@ -367,7 +383,8 @@ static void iter_cb (void *cls,
367 GNUNET_RECLAIM_get_attributes_next (attr_iterator); 383 GNUNET_RECLAIM_get_attributes_next (attr_iterator);
368} 384}
369 385
370static void start_process () 386static void
387start_process ()
371{ 388{
372 if (NULL == pkey) { 389 if (NULL == pkey) {
373 fprintf (stderr, "Ego %s not found\n", ego_name); 390 fprintf (stderr, "Ego %s not found\n", ego_name);
@@ -402,8 +419,9 @@ static void start_process ()
402 419
403static int init = GNUNET_YES; 420static int init = GNUNET_YES;
404 421
405static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, 422static void
406 const char *name) 423ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
424 const char *name)
407{ 425{
408 if (NULL == name) { 426 if (NULL == name) {
409 if (GNUNET_YES == init) { 427 if (GNUNET_YES == init) {
@@ -418,8 +436,9 @@ static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
418} 436}
419 437
420 438
421static void run (void *cls, char *const *args, const char *cfgfile, 439static void
422 const struct GNUNET_CONFIGURATION_Handle *c) 440run (void *cls, char *const *args, const char *cfgfile,
441 const struct GNUNET_CONFIGURATION_Handle *c)
423{ 442{
424 ret = 0; 443 ret = 0;
425 if (NULL == ego_name) { 444 if (NULL == ego_name) {
@@ -446,7 +465,8 @@ static void run (void *cls, char *const *args, const char *cfgfile,
446} 465}
447 466
448 467
449int main (int argc, char *const argv[]) 468int
469main (int argc, char *const argv[])
450{ 470{
451 exp_interval = GNUNET_TIME_UNIT_HOURS; 471 exp_interval = GNUNET_TIME_UNIT_HOURS;
452 struct GNUNET_GETOPT_CommandLineOption options[] = { 472 struct GNUNET_GETOPT_CommandLineOption options[] = {
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 2c74193d1..2bb4f5a74 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -925,6 +925,7 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
925 } else { 925 } else {
926 env = GNUNET_MQ_msg_extra (trm, sizeof (struct GNUNET_RECLAIM_Ticket), 926 env = GNUNET_MQ_msg_extra (trm, sizeof (struct GNUNET_RECLAIM_Ticket),
927 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); 927 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
928 memcpy (&trm[1], ticket, sizeof (struct GNUNET_RECLAIM_Ticket));
928 } 929 }
929 trm->id = htonl (ti->r_id); 930 trm->id = htonl (ti->r_id);
930 GNUNET_MQ_send (ti->client->mq, env); 931 GNUNET_MQ_send (ti->client->mq, env);
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index 5a3190c7f..4a307e635 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -164,21 +164,6 @@ struct TicketIssueHandle {
164 struct GNUNET_NAMESTORE_QueueEntry *ns_qe; 164 struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
165 165
166 /** 166 /**
167 * Ticket reference list
168 */
169 struct TicketReference *ticket_refs_head;
170
171 /**
172 * Ticket reference list
173 */
174 struct TicketReference *ticket_refs_tail;
175
176 /**
177 * Number of references
178 */
179 uint32_t ticket_ref_num;
180
181 /**
182 * Callback 167 * Callback
183 */ 168 */
184 RECLAIM_TICKETS_TicketResult cb; 169 RECLAIM_TICKETS_TicketResult cb;
@@ -194,19 +179,9 @@ struct TicketIssueHandle {
194 */ 179 */
195struct RECLAIM_TICKETS_Iterator { 180struct RECLAIM_TICKETS_Iterator {
196 /** 181 /**
197 * Issuer Key
198 */
199 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
200
201 /**
202 * Issuer pubkey
203 */
204 struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub;
205
206 /**
207 * Namestore queue entry 182 * Namestore queue entry
208 */ 183 */
209 struct GNUNET_NAMESTORE_QueueEntry *ns_qe; 184 struct GNUNET_NAMESTORE_ZoneIterator *ns_it;
210 185
211 /** 186 /**
212 * Iter callback 187 * Iter callback
@@ -217,16 +192,6 @@ struct RECLAIM_TICKETS_Iterator {
217 * Iter cls 192 * Iter cls
218 */ 193 */
219 void *cb_cls; 194 void *cb_cls;
220
221 /**
222 * Ticket reference list
223 */
224 struct TicketReference *tickets_head;
225
226 /**
227 * Ticket reference list
228 */
229 struct TicketReference *tickets_tail;
230}; 195};
231 196
232 197
@@ -870,113 +835,13 @@ RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth)
870static void 835static void
871cleanup_issue_handle (struct TicketIssueHandle *handle) 836cleanup_issue_handle (struct TicketIssueHandle *handle)
872{ 837{
873 struct TicketReference *tr;
874 struct TicketReference *tr_tmp;
875 if (NULL != handle->attrs)
876 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (handle->attrs);
877 if (NULL != handle->ns_qe) 838 if (NULL != handle->ns_qe)
878 GNUNET_NAMESTORE_cancel (handle->ns_qe); 839 GNUNET_NAMESTORE_cancel (handle->ns_qe);
879 for (tr = handle->ticket_refs_head; NULL != tr;) {
880 if (NULL != tr->attrs)
881 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs);
882 tr_tmp = tr;
883 tr = tr->next;
884 GNUNET_free (tr_tmp);
885 }
886 GNUNET_free (handle); 840 GNUNET_free (handle);
887} 841}
888 842
889 843
890static void 844static void
891store_ticket_refs_cont (void *cls, int32_t success, const char *emsg)
892{
893 struct TicketIssueHandle *handle = cls;
894 handle->ns_qe = NULL;
895 if (GNUNET_OK != success) {
896 handle->cb (handle->cb_cls, NULL, GNUNET_SYSERR,
897 "Error storing updated ticket refs in GNS");
898 cleanup_issue_handle (handle);
899 return;
900 }
901 handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL);
902 cleanup_issue_handle (handle);
903}
904
905
906static void
907update_ticket_refs (void *cls)
908{
909 struct TicketIssueHandle *handle = cls;
910 struct GNUNET_GNSRECORD_Data refs_rd[handle->ticket_ref_num];
911 struct TicketReference *tr;
912
913 tr = handle->ticket_refs_head;
914 for (int i = 0; i < handle->ticket_ref_num; i++) {
915 refs_rd[i].data = &tr->ticket;
916 refs_rd[i].data_size = sizeof (struct GNUNET_RECLAIM_Ticket);
917 refs_rd[i].expiration_time = GNUNET_TIME_UNIT_DAYS.rel_value_us;
918 refs_rd[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF;
919 refs_rd[i].flags =
920 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
921 tr = tr->next;
922 }
923
924 handle->ns_qe = GNUNET_NAMESTORE_records_store (
925 nsh, &handle->identity, GNUNET_GNS_EMPTY_LABEL_AT, handle->ticket_ref_num,
926 refs_rd, &store_ticket_refs_cont, handle);
927}
928
929
930static void
931ticket_lookup_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
932 const char *label, unsigned int rd_count,
933 const struct GNUNET_GNSRECORD_Data *rd)
934{
935 struct TicketIssueHandle *handle = cls;
936 struct TicketReference *tr;
937
938 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
939 "Received tickets from local namestore.\n");
940 handle->ns_qe = NULL;
941 for (int i = 0; i < rd_count; i++) {
942 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF != rd[i].record_type)
943 continue;
944 tr = GNUNET_new (struct TicketReference);
945 memcpy (&tr->ticket, rd[i].data, sizeof (struct GNUNET_RECLAIM_Ticket));
946 if (0 != memcmp (&tr->ticket.identity, &handle->ticket.identity,
947 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) {
948 // Not our ticket
949 GNUNET_free (tr);
950 continue;
951 }
952 GNUNET_CONTAINER_DLL_insert (handle->ticket_refs_head,
953 handle->ticket_refs_tail, tr);
954 handle->ticket_ref_num++;
955 }
956 tr = GNUNET_new (struct TicketReference);
957 tr->ticket = handle->ticket;
958 tr->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (handle->attrs);
959 GNUNET_CONTAINER_DLL_insert (handle->ticket_refs_head,
960 handle->ticket_refs_tail, tr);
961 handle->ticket_ref_num++;
962 GNUNET_SCHEDULER_add_now (&update_ticket_refs, handle);
963}
964
965
966/**
967 * TODO maybe we should cleanup the ATTRREFS here?
968 */
969static void
970ticket_lookup_error_cb (void *cls)
971{
972 struct TicketIssueHandle *handle = cls;
973 handle->ns_qe = NULL;
974 handle->cb (handle->cb_cls, &handle->ticket, GNUNET_SYSERR,
975 "Error checking for ticketsin GNS\n");
976 cleanup_issue_handle (handle);
977}
978
979static void
980store_ticket_issue_cont (void *cls, int32_t success, const char *emsg) 845store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
981{ 846{
982 struct TicketIssueHandle *handle = cls; 847 struct TicketIssueHandle *handle = cls;
@@ -987,10 +852,8 @@ store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
987 "Error storing AuthZ ticket in GNS"); 852 "Error storing AuthZ ticket in GNS");
988 return; 853 return;
989 } 854 }
990 /* First, local references to tickets */ 855 handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL);
991 handle->ns_qe = GNUNET_NAMESTORE_records_lookup ( 856 cleanup_issue_handle (handle);
992 nsh, &handle->identity, GNUNET_GNS_EMPTY_LABEL_AT,
993 &ticket_lookup_error_cb, handle, &ticket_lookup_cb, handle);
994} 857}
995 858
996 859
@@ -1000,7 +863,7 @@ issue_ticket (struct TicketIssueHandle *ih)
1000 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 863 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
1001 struct GNUNET_GNSRECORD_Data *attrs_record; 864 struct GNUNET_GNSRECORD_Data *attrs_record;
1002 char *label; 865 char *label;
1003 size_t list_len = 0; 866 size_t list_len = 1;
1004 int i; 867 int i;
1005 868
1006 for (le = ih->attrs->list_head; NULL != le; le = le->next) 869 for (le = ih->attrs->list_head; NULL != le; le = le->next)
@@ -1017,6 +880,12 @@ issue_ticket (struct TicketIssueHandle *ih)
1017 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 880 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1018 i++; 881 i++;
1019 } 882 }
883 attrs_record[i].data = &ih->ticket;
884 attrs_record[i].data_size = sizeof (struct GNUNET_RECLAIM_Ticket);
885 attrs_record[i].expiration_time = GNUNET_TIME_UNIT_DAYS.rel_value_us;
886 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET;
887 attrs_record[i].flags =
888 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
1020 889
1021 label = 890 label =
1022 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); 891 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t));
@@ -1055,49 +924,11 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1055static void 924static void
1056cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter) 925cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter)
1057{ 926{
1058 struct TicketReference *tr; 927 if (NULL != iter->ns_it)
1059 struct TicketReference *tr_tmp; 928 GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it);
1060 if (NULL != iter->ns_qe)
1061 GNUNET_NAMESTORE_cancel (iter->ns_qe);
1062 for (tr = iter->tickets_head; NULL != tr;) {
1063 if (NULL != tr->attrs)
1064 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs);
1065 tr_tmp = tr;
1066 tr = tr->next;
1067 GNUNET_free (tr_tmp);
1068 }
1069 GNUNET_free (iter); 929 GNUNET_free (iter);
1070} 930}
1071 931
1072static void
1073do_cleanup_iter (void *cls)
1074{
1075 struct RECLAIM_TICKETS_Iterator *iter = cls;
1076 cleanup_iter (iter);
1077}
1078
1079/**
1080 * Perform ticket iteration step
1081 *
1082 * @param ti ticket iterator to process
1083 */
1084static void
1085run_ticket_iteration_round (struct RECLAIM_TICKETS_Iterator *iter)
1086{
1087 struct TicketReference *tr;
1088 if (NULL == iter->tickets_head) {
1089 // No more tickets
1090 iter->cb (iter->cb_cls, NULL);
1091 GNUNET_SCHEDULER_add_now (&do_cleanup_iter, iter);
1092 return;
1093 }
1094 tr = iter->tickets_head;
1095 GNUNET_CONTAINER_DLL_remove (iter->tickets_head, iter->tickets_tail, tr);
1096 iter->cb (iter->cb_cls, &tr->ticket);
1097 if (NULL != tr->attrs)
1098 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs);
1099 GNUNET_free (tr);
1100}
1101 932
1102static void 933static void
1103collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 934collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
@@ -1105,46 +936,52 @@ collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1105 const struct GNUNET_GNSRECORD_Data *rd) 936 const struct GNUNET_GNSRECORD_Data *rd)
1106{ 937{
1107 struct RECLAIM_TICKETS_Iterator *iter = cls; 938 struct RECLAIM_TICKETS_Iterator *iter = cls;
1108 struct TicketReference *tr;
1109 iter->ns_qe = NULL;
1110 939
1111 for (int i = 0; i < rd_count; i++) { 940 for (int i = 0; i < rd_count; i++) {
1112 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF != rd[i].record_type) 941 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
1113 continue; 942 continue;
1114 tr = GNUNET_new (struct TicketReference); 943 iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *)rd[i].data);
1115 memcpy (&tr->ticket, rd[i].data, sizeof (struct GNUNET_RECLAIM_Ticket)); 944 return;
1116 if (0 != memcmp (&tr->ticket.identity, &iter->identity_pub,
1117 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) {
1118 // Not our ticket
1119 GNUNET_free (tr);
1120 continue;
1121 }
1122 GNUNET_CONTAINER_DLL_insert (iter->tickets_head, iter->tickets_tail, tr);
1123 } 945 }
1124 run_ticket_iteration_round (iter); 946 GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1);
1125} 947}
1126 948
949
950static void
951collect_tickets_finished_cb (void *cls)
952{
953 struct RECLAIM_TICKETS_Iterator *iter = cls;
954 iter->ns_it = NULL;
955 iter->cb (iter->cb_cls, NULL);
956 cleanup_iter (iter);
957}
958
959
1127static void 960static void
1128collect_tickets_error_cb (void *cls) 961collect_tickets_error_cb (void *cls)
1129{ 962{
1130 struct RECLAIM_TICKETS_Iterator *iter = cls; 963 struct RECLAIM_TICKETS_Iterator *iter = cls;
1131 iter->ns_qe = NULL; 964 iter->ns_it = NULL;
1132 iter->cb (iter->cb_cls, NULL); 965 iter->cb (iter->cb_cls, NULL);
1133 cleanup_iter (iter); 966 cleanup_iter (iter);
1134} 967}
1135 968
969
1136void 970void
1137RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter) 971RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter)
1138{ 972{
1139 run_ticket_iteration_round (iter); 973 GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1);
1140} 974}
1141 975
976
1142void 977void
1143RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter) 978RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter)
1144{ 979{
980 GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it);
1145 cleanup_iter (iter); 981 cleanup_iter (iter);
1146} 982}
1147 983
984
1148struct RECLAIM_TICKETS_Iterator * 985struct RECLAIM_TICKETS_Iterator *
1149RECLAIM_TICKETS_iteration_start ( 986RECLAIM_TICKETS_iteration_start (
1150 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 987 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
@@ -1153,13 +990,11 @@ RECLAIM_TICKETS_iteration_start (
1153 struct RECLAIM_TICKETS_Iterator *iter; 990 struct RECLAIM_TICKETS_Iterator *iter;
1154 991
1155 iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator); 992 iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
1156 iter->identity = *identity;
1157 GNUNET_CRYPTO_ecdsa_key_get_public (identity, &iter->identity_pub);
1158 iter->cb = cb; 993 iter->cb = cb;
1159 iter->cb_cls = cb_cls; 994 iter->cb_cls = cb_cls;
1160 iter->ns_qe = GNUNET_NAMESTORE_records_lookup ( 995 iter->ns_it = GNUNET_NAMESTORE_zone_iteration_start (
1161 nsh, identity, GNUNET_GNS_EMPTY_LABEL_AT, &collect_tickets_error_cb, iter, 996 nsh, identity, &collect_tickets_error_cb, iter, &collect_tickets_cb, iter,
1162 &collect_tickets_cb, iter); 997 &collect_tickets_finished_cb, iter);
1163 return iter; 998 return iter;
1164} 999}
1165 1000
diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c
index 612fec3bd..48cdd9811 100644
--- a/src/reclaim/plugin_gnsrecord_reclaim.c
+++ b/src/reclaim/plugin_gnsrecord_reclaim.c
@@ -39,8 +39,8 @@
39 * @param data_size number of bytes in @a data 39 * @param data_size number of bytes in @a data
40 * @return NULL on error, otherwise human-readable representation of the value 40 * @return NULL on error, otherwise human-readable representation of the value
41 */ 41 */
42static char *value_to_string (void *cls, uint32_t type, const void *data, 42static char *
43 size_t data_size) 43value_to_string (void *cls, uint32_t type, const void *data, size_t data_size)
44{ 44{
45 switch (type) { 45 switch (type) {
46 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR: 46 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
@@ -49,7 +49,7 @@ static char *value_to_string (void *cls, uint32_t type, const void *data,
49 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: 49 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
50 return GNUNET_strndup (data, data_size); 50 return GNUNET_strndup (data, data_size);
51 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: 51 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF:
52 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF: 52 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
53 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: 53 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
54 return GNUNET_STRINGS_data_to_string_alloc (data, data_size); 54 return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
55 default: 55 default:
@@ -69,8 +69,9 @@ static char *value_to_string (void *cls, uint32_t type, const void *data,
69 * @param data_size set to number of bytes in @a data 69 * @param data_size set to number of bytes in @a data
70 * @return #GNUNET_OK on success 70 * @return #GNUNET_OK on success
71 */ 71 */
72static int string_to_value (void *cls, uint32_t type, const char *s, 72static int
73 void **data, size_t *data_size) 73string_to_value (void *cls, uint32_t type, const char *s, void **data,
74 size_t *data_size)
74{ 75{
75 if (NULL == s) 76 if (NULL == s)
76 return GNUNET_SYSERR; 77 return GNUNET_SYSERR;
@@ -84,7 +85,7 @@ static int string_to_value (void *cls, uint32_t type, const char *s,
84 return GNUNET_OK; 85 return GNUNET_OK;
85 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: 86 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF:
86 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: 87 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
87 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF: 88 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
88 return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size); 89 return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
89 default: 90 default:
90 return GNUNET_SYSERR; 91 return GNUNET_SYSERR;
@@ -105,7 +106,7 @@ static struct {
105 {"RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER}, 106 {"RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER},
106 {"RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT}, 107 {"RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT},
107 {"RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT}, 108 {"RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT},
108 {"RECLAIM_TICKETREF", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF}, 109 {"RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET},
109 {NULL, UINT32_MAX}}; 110 {NULL, UINT32_MAX}};
110 111
111 112
@@ -116,7 +117,8 @@ static struct {
116 * @param dns_typename name to convert 117 * @param dns_typename name to convert
117 * @return corresponding number, UINT32_MAX on error 118 * @return corresponding number, UINT32_MAX on error
118 */ 119 */
119static uint32_t typename_to_number (void *cls, const char *dns_typename) 120static uint32_t
121typename_to_number (void *cls, const char *dns_typename)
120{ 122{
121 unsigned int i; 123 unsigned int i;
122 124
@@ -135,7 +137,8 @@ static uint32_t typename_to_number (void *cls, const char *dns_typename)
135 * @param type number of a type to convert 137 * @param type number of a type to convert
136 * @return corresponding typestring, NULL on error 138 * @return corresponding typestring, NULL on error
137 */ 139 */
138static const char *number_to_typename (void *cls, uint32_t type) 140static const char *
141number_to_typename (void *cls, uint32_t type)
139{ 142{
140 unsigned int i; 143 unsigned int i;
141 144
@@ -152,7 +155,8 @@ static const char *number_to_typename (void *cls, uint32_t type)
152 * @param cls NULL 155 * @param cls NULL
153 * @return the exported block API 156 * @return the exported block API
154 */ 157 */
155void *libgnunet_plugin_gnsrecord_reclaim_init (void *cls) 158void *
159libgnunet_plugin_gnsrecord_reclaim_init (void *cls)
156{ 160{
157 struct GNUNET_GNSRECORD_PluginFunctions *api; 161 struct GNUNET_GNSRECORD_PluginFunctions *api;
158 162
@@ -171,7 +175,8 @@ void *libgnunet_plugin_gnsrecord_reclaim_init (void *cls)
171 * @param cls the return value from #libgnunet_plugin_block_test_init 175 * @param cls the return value from #libgnunet_plugin_block_test_init
172 * @return NULL 176 * @return NULL
173 */ 177 */
174void *libgnunet_plugin_gnsrecord_reclaim_done (void *cls) 178void *
179libgnunet_plugin_gnsrecord_reclaim_done (void *cls)
175{ 180{
176 struct GNUNET_GNSRECORD_PluginFunctions *api = cls; 181 struct GNUNET_GNSRECORD_PluginFunctions *api = cls;
177 182