summaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-service-reclaim_tickets.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c1115
1 files changed, 561 insertions, 554 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index b38a5eb25..57c9e2167 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -44,7 +44,8 @@ struct ParallelLookup;
44/** 44/**
45 * A reference to a ticket stored in GNS 45 * A reference to a ticket stored in GNS
46 */ 46 */
47struct TicketReference { 47struct TicketReference
48{
48 /** 49 /**
49 * DLL 50 * DLL
50 */ 51 */
@@ -70,7 +71,8 @@ struct TicketReference {
70/** 71/**
71 * Handle to a consume operation 72 * Handle to a consume operation
72 */ 73 */
73struct RECLAIM_TICKETS_ConsumeHandle { 74struct RECLAIM_TICKETS_ConsumeHandle
75{
74 /** 76 /**
75 * Ticket 77 * Ticket
76 */ 78 */
@@ -131,7 +133,8 @@ struct RECLAIM_TICKETS_ConsumeHandle {
131/** 133/**
132 * Handle for a parallel GNS lookup job 134 * Handle for a parallel GNS lookup job
133 */ 135 */
134struct ParallelLookup { 136struct ParallelLookup
137{
135 /* DLL */ 138 /* DLL */
136 struct ParallelLookup *next; 139 struct ParallelLookup *next;
137 140
@@ -157,7 +160,8 @@ struct ParallelLookup {
157/** 160/**
158 * Ticket issue request handle 161 * Ticket issue request handle
159 */ 162 */
160struct TicketIssueHandle { 163struct TicketIssueHandle
164{
161 /** 165 /**
162 * Attributes to issue 166 * Attributes to issue
163 */ 167 */
@@ -198,7 +202,8 @@ struct TicketIssueHandle {
198/** 202/**
199 * Ticket iterator 203 * Ticket iterator
200 */ 204 */
201struct RECLAIM_TICKETS_Iterator { 205struct RECLAIM_TICKETS_Iterator
206{
202 /** 207 /**
203 * Namestore queue entry 208 * Namestore queue entry
204 */ 209 */
@@ -216,7 +221,8 @@ struct RECLAIM_TICKETS_Iterator {
216}; 221};
217 222
218 223
219struct RevokedAttributeEntry { 224struct RevokedAttributeEntry
225{
220 /** 226 /**
221 * DLL 227 * DLL
222 */ 228 */
@@ -242,7 +248,8 @@ struct RevokedAttributeEntry {
242/** 248/**
243 * Ticket revocation request handle 249 * Ticket revocation request handle
244 */ 250 */
245struct RECLAIM_TICKETS_RevokeHandle { 251struct RECLAIM_TICKETS_RevokeHandle
252{
246 /** 253 /**
247 * Issuer Key 254 * Issuer Key
248 */ 255 */
@@ -330,32 +337,32 @@ static struct GNUNET_STATISTICS_Handle *stats;
330 * @param rh the ticket revocation handle 337 * @param rh the ticket revocation handle
331 */ 338 */
332static void 339static void
333cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh) 340cleanup_rvk (struct RECLAIM_TICKETS_RevokeHandle *rh)
334{ 341{
335 struct RevokedAttributeEntry *ae; 342 struct RevokedAttributeEntry *ae;
336 struct TicketRecordsEntry *le; 343 struct TicketRecordsEntry *le;
337 344
338 if (NULL != rh->ns_qe) 345 if (NULL != rh->ns_qe)
339 GNUNET_NAMESTORE_cancel(rh->ns_qe); 346 GNUNET_NAMESTORE_cancel (rh->ns_qe);
340 if (NULL != rh->ns_it) 347 if (NULL != rh->ns_it)
341 GNUNET_NAMESTORE_zone_iteration_stop(rh->ns_it); 348 GNUNET_NAMESTORE_zone_iteration_stop (rh->ns_it);
342 while (NULL != (ae = rh->attrs_head)) 349 while (NULL != (ae = rh->attrs_head))
343 { 350 {
344 GNUNET_CONTAINER_DLL_remove(rh->attrs_head, rh->attrs_tail, ae); 351 GNUNET_CONTAINER_DLL_remove (rh->attrs_head, rh->attrs_tail, ae);
345 GNUNET_free(ae); 352 GNUNET_free (ae);
346 } 353 }
347 while (NULL != (le = rh->tickets_to_update_head)) 354 while (NULL != (le = rh->tickets_to_update_head))
348 { 355 {
349 GNUNET_CONTAINER_DLL_remove(rh->tickets_to_update_head, 356 GNUNET_CONTAINER_DLL_remove (rh->tickets_to_update_head,
350 rh->tickets_to_update_head, 357 rh->tickets_to_update_head,
351 le); 358 le);
352 if (NULL != le->data) 359 if (NULL != le->data)
353 GNUNET_free(le->data); 360 GNUNET_free (le->data);
354 if (NULL != le->label) 361 if (NULL != le->label)
355 GNUNET_free(le->label); 362 GNUNET_free (le->label);
356 GNUNET_free(le); 363 GNUNET_free (le);
357 } 364 }
358 GNUNET_free(rh); 365 GNUNET_free (rh);
359} 366}
360 367
361 368
@@ -366,7 +373,7 @@ cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
366 * @param cls handle to the operation 373 * @param cls handle to the operation
367 */ 374 */
368static void 375static void
369process_tickets(void *cls); 376process_tickets (void *cls);
370 377
371 378
372/** 379/**
@@ -378,12 +385,12 @@ process_tickets(void *cls);
378 * @param emsg (NULL on success) 385 * @param emsg (NULL on success)
379 */ 386 */
380static void 387static void
381ticket_processed(void *cls, int32_t success, const char *emsg) 388ticket_processed (void *cls, int32_t success, const char *emsg)
382{ 389{
383 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 390 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
384 391
385 rvk->ns_qe = NULL; 392 rvk->ns_qe = NULL;
386 GNUNET_SCHEDULER_add_now(&process_tickets, rvk); 393 GNUNET_SCHEDULER_add_now (&process_tickets, rvk);
387} 394}
388 395
389 396
@@ -393,57 +400,57 @@ ticket_processed(void *cls, int32_t success, const char *emsg)
393 * @param cls handle to the operation 400 * @param cls handle to the operation
394 */ 401 */
395static void 402static void
396process_tickets(void *cls) 403process_tickets (void *cls)
397{ 404{
398 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 405 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
399 struct TicketRecordsEntry *le; 406 struct TicketRecordsEntry *le;
400 struct RevokedAttributeEntry *ae; 407 struct RevokedAttributeEntry *ae;
401 408
402 if (NULL == rvk->tickets_to_update_head) 409 if (NULL == rvk->tickets_to_update_head)
403 { 410 {
404 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
405 "Finished updatding tickets, success\n"); 412 "Finished updatding tickets, success\n");
406 rvk->cb(rvk->cb_cls, GNUNET_OK); 413 rvk->cb (rvk->cb_cls, GNUNET_OK);
407 cleanup_rvk(rvk); 414 cleanup_rvk (rvk);
408 return; 415 return;
409 } 416 }
410 le = rvk->tickets_to_update_head; 417 le = rvk->tickets_to_update_head;
411 GNUNET_CONTAINER_DLL_remove(rvk->tickets_to_update_head, 418 GNUNET_CONTAINER_DLL_remove (rvk->tickets_to_update_head,
412 rvk->tickets_to_update_tail, 419 rvk->tickets_to_update_tail,
413 le); 420 le);
414 struct GNUNET_GNSRECORD_Data rd[le->rd_count]; 421 struct GNUNET_GNSRECORD_Data rd[le->rd_count];
415 if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize(le->data_size, 422 if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize (le->data_size,
416 le->data, 423 le->data,
417 le->rd_count, 424 le->rd_count,
418 rd)) 425 rd))
419 { 426 {
420 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 427 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
421 "Unable to deserialize ticket record(s)\n"); 428 "Unable to deserialize ticket record(s)\n");
422 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 429 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
423 cleanup_rvk(rvk); 430 cleanup_rvk (rvk);
424 return; 431 return;
425 } 432 }
426 for (int i = 0; i < le->rd_count; i++) 433 for (int i = 0; i < le->rd_count; i++)
434 {
435 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
436 continue;
437 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
427 { 438 {
428 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 439 if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t)))
429 continue; 440 continue;
430 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 441 rd[i].data = &ae->new_id;
431 {
432 if (0 != memcmp(rd[i].data, &ae->old_id, sizeof(uint64_t)))
433 continue;
434 rd[i].data = &ae->new_id;
435 }
436 } 442 }
437 rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 443 }
438 &rvk->identity, 444 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
439 le->label, 445 &rvk->identity,
440 le->rd_count, 446 le->label,
441 rd, 447 le->rd_count,
442 &ticket_processed, 448 rd,
443 rvk); 449 &ticket_processed,
444 GNUNET_free(le->label); 450 rvk);
445 GNUNET_free(le->data); 451 GNUNET_free (le->label);
446 GNUNET_free(le); 452 GNUNET_free (le->data);
453 GNUNET_free (le);
447} 454}
448 455
449 456
@@ -453,12 +460,12 @@ process_tickets(void *cls)
453 * @param cls handle to the operation 460 * @param cls handle to the operation
454 */ 461 */
455static void 462static void
456rvk_ticket_update_finished(void *cls) 463rvk_ticket_update_finished (void *cls)
457{ 464{
458 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 465 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
459 466
460 rvk->ns_it = NULL; 467 rvk->ns_it = NULL;
461 GNUNET_SCHEDULER_add_now(&process_tickets, rvk); 468 GNUNET_SCHEDULER_add_now (&process_tickets, rvk);
462} 469}
463 470
464 471
@@ -473,11 +480,11 @@ rvk_ticket_update_finished(void *cls)
473 * @param rd record set 480 * @param rd record set
474 */ 481 */
475static void 482static void
476rvk_ticket_update(void *cls, 483rvk_ticket_update (void *cls,
477 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 484 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
478 const char *label, 485 const char *label,
479 unsigned int rd_count, 486 unsigned int rd_count,
480 const struct GNUNET_GNSRECORD_Data *rd) 487 const struct GNUNET_GNSRECORD_Data *rd)
481{ 488{
482 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 489 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
483 struct TicketRecordsEntry *le; 490 struct TicketRecordsEntry *le;
@@ -486,32 +493,32 @@ rvk_ticket_update(void *cls,
486 493
487 /** Let everything point to the old record **/ 494 /** Let everything point to the old record **/
488 for (int i = 0; i < rd_count; i++) 495 for (int i = 0; i < rd_count; i++)
496 {
497 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
498 continue;
499 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
489 { 500 {
490 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 501 if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t)))
491 continue; 502 continue;
492 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 503 has_changed = GNUNET_YES;
493 { 504 break;
494 if (0 != memcmp(rd[i].data, &ae->old_id, sizeof(uint64_t)))
495 continue;
496 has_changed = GNUNET_YES;
497 break;
498 }
499 if (GNUNET_YES == has_changed)
500 break;
501 } 505 }
506 if (GNUNET_YES == has_changed)
507 break;
508 }
502 if (GNUNET_YES == has_changed) 509 if (GNUNET_YES == has_changed)
503 { 510 {
504 le = GNUNET_new(struct TicketRecordsEntry); 511 le = GNUNET_new (struct TicketRecordsEntry);
505 le->data_size = GNUNET_GNSRECORD_records_get_size(rd_count, rd); 512 le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
506 le->data = GNUNET_malloc(le->data_size); 513 le->data = GNUNET_malloc (le->data_size);
507 le->rd_count = rd_count; 514 le->rd_count = rd_count;
508 le->label = GNUNET_strdup(label); 515 le->label = GNUNET_strdup (label);
509 GNUNET_GNSRECORD_records_serialize(rd_count, rd, le->data_size, le->data); 516 GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
510 GNUNET_CONTAINER_DLL_insert(rvk->tickets_to_update_head, 517 GNUNET_CONTAINER_DLL_insert (rvk->tickets_to_update_head,
511 rvk->tickets_to_update_tail, 518 rvk->tickets_to_update_tail,
512 le); 519 le);
513 } 520 }
514 GNUNET_NAMESTORE_zone_iterator_next(rvk->ns_it, 1); 521 GNUNET_NAMESTORE_zone_iterator_next (rvk->ns_it, 1);
515} 522}
516 523
517 524
@@ -521,16 +528,16 @@ rvk_ticket_update(void *cls,
521 * @param cls handle to the operation 528 * @param cls handle to the operation
522 */ 529 */
523static void 530static void
524rvk_ns_iter_err(void *cls) 531rvk_ns_iter_err (void *cls)
525{ 532{
526 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 533 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
527 534
528 rvk->ns_it = NULL; 535 rvk->ns_it = NULL;
529 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 536 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
530 "Namestore error on revocation (id=%" PRIu64 "\n", 537 "Namestore error on revocation (id=%" PRIu64 "\n",
531 rvk->move_attr->old_id); 538 rvk->move_attr->old_id);
532 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 539 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
533 cleanup_rvk(rvk); 540 cleanup_rvk (rvk);
534} 541}
535 542
536 543
@@ -540,16 +547,16 @@ rvk_ns_iter_err(void *cls)
540 * @param cls handle to the operation 547 * @param cls handle to the operation
541 */ 548 */
542static void 549static void
543rvk_ns_err(void *cls) 550rvk_ns_err (void *cls)
544{ 551{
545 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 552 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
546 553
547 rvk->ns_qe = NULL; 554 rvk->ns_qe = NULL;
548 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 555 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
549 "Namestore error on revocation (id=%" PRIu64 "\n", 556 "Namestore error on revocation (id=%" PRIu64 "\n",
550 rvk->move_attr->old_id); 557 rvk->move_attr->old_id);
551 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 558 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
552 cleanup_rvk(rvk); 559 cleanup_rvk (rvk);
553} 560}
554 561
555 562
@@ -563,7 +570,7 @@ rvk_ns_err(void *cls)
563 * @param rvk handle to the operation 570 * @param rvk handle to the operation
564 */ 571 */
565static void 572static void
566move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh); 573move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rh);
567 574
568 575
569/** 576/**
@@ -572,9 +579,9 @@ move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh);
572 * @param cls handle to the operation. 579 * @param cls handle to the operation.
573 */ 580 */
574static void 581static void
575move_attrs_cont(void *cls) 582move_attrs_cont (void *cls)
576{ 583{
577 move_attrs((struct RECLAIM_TICKETS_RevokeHandle *)cls); 584 move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *) cls);
578} 585}
579 586
580 587
@@ -587,22 +594,22 @@ move_attrs_cont(void *cls)
587 * @param emsg error message (NULL on success) 594 * @param emsg error message (NULL on success)
588 */ 595 */
589static void 596static void
590del_attr_finished(void *cls, int32_t success, const char *emsg) 597del_attr_finished (void *cls, int32_t success, const char *emsg)
591{ 598{
592 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 599 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
593 600
594 rvk->ns_qe = NULL; 601 rvk->ns_qe = NULL;
595 if (GNUNET_SYSERR == success) 602 if (GNUNET_SYSERR == success)
596 { 603 {
597 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 604 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
598 "Error removing attribute: %s\n", 605 "Error removing attribute: %s\n",
599 emsg); 606 emsg);
600 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 607 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
601 cleanup_rvk(rvk); 608 cleanup_rvk (rvk);
602 return; 609 return;
603 } 610 }
604 rvk->move_attr = rvk->move_attr->next; 611 rvk->move_attr = rvk->move_attr->next;
605 GNUNET_SCHEDULER_add_now(&move_attrs_cont, rvk); 612 GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk);
606} 613}
607 614
608 615
@@ -616,31 +623,31 @@ del_attr_finished(void *cls, int32_t success, const char *emsg)
616 * @param emsg error message (NULL on success) 623 * @param emsg error message (NULL on success)
617 */ 624 */
618static void 625static void
619move_attr_finished(void *cls, int32_t success, const char *emsg) 626move_attr_finished (void *cls, int32_t success, const char *emsg)
620{ 627{
621 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 628 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
622 char *label; 629 char *label;
623 630
624 rvk->ns_qe = NULL; 631 rvk->ns_qe = NULL;
625 if (GNUNET_SYSERR == success) 632 if (GNUNET_SYSERR == success)
626 { 633 {
627 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg); 634 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg);
628 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 635 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
629 cleanup_rvk(rvk); 636 cleanup_rvk (rvk);
630 return; 637 return;
631 } 638 }
632 label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->old_id, 639 label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id,
633 sizeof(uint64_t)); 640 sizeof(uint64_t));
634 GNUNET_assert(NULL != label); 641 GNUNET_assert (NULL != label);
635 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); 642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
636 rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 643 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
637 &rvk->identity, 644 &rvk->identity,
638 label, 645 label,
639 0, 646 0,
640 NULL, 647 NULL,
641 &del_attr_finished, 648 &del_attr_finished,
642 rvk); 649 rvk);
643 GNUNET_free(label); 650 GNUNET_free (label);
644} 651}
645 652
646 653
@@ -654,11 +661,11 @@ move_attr_finished(void *cls, int32_t success, const char *emsg)
654 * @param rd record set (the attribute) 661 * @param rd record set (the attribute)
655 */ 662 */
656static void 663static void
657rvk_move_attr_cb(void *cls, 664rvk_move_attr_cb (void *cls,
658 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 665 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
659 const char *label, 666 const char *label,
660 unsigned int rd_count, 667 unsigned int rd_count,
661 const struct GNUNET_GNSRECORD_Data *rd) 668 const struct GNUNET_GNSRECORD_Data *rd)
662{ 669{
663 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 670 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
664 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 671 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
@@ -669,44 +676,44 @@ rvk_move_attr_cb(void *cls,
669 676
670 rvk->ns_qe = NULL; 677 rvk->ns_qe = NULL;
671 if (0 == rd_count) 678 if (0 == rd_count)
672 { 679 {
673 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 680 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
674 "The attribute %s no longer exists!\n", 681 "The attribute %s no longer exists!\n",
675 label); 682 label);
676 le = rvk->move_attr; 683 le = rvk->move_attr;
677 rvk->move_attr = le->next; 684 rvk->move_attr = le->next;
678 GNUNET_CONTAINER_DLL_remove(rvk->attrs_head, rvk->attrs_tail, le); 685 GNUNET_CONTAINER_DLL_remove (rvk->attrs_head, rvk->attrs_tail, le);
679 GNUNET_free(le); 686 GNUNET_free (le);
680 GNUNET_SCHEDULER_add_now(&move_attrs_cont, rvk); 687 GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk);
681 return; 688 return;
682 } 689 }
683 /** find a new place for this attribute **/ 690 /** find a new place for this attribute **/
684 rvk->move_attr->new_id = 691 rvk->move_attr->new_id =
685 GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); 692 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
686 new_rd = *rd; 693 new_rd = *rd;
687 claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize(rd->data, rd->data_size); 694 claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size);
688 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
689 "Attribute to update: Name=%s, ID=%" PRIu64 "\n", 696 "Attribute to update: Name=%s, ID=%" PRIu64 "\n",
690 claim->name, 697 claim->name,
691 claim->id); 698 claim->id);
692 claim->id = rvk->move_attr->new_id; 699 claim->id = rvk->move_attr->new_id;
693 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(claim); 700 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim);
694 attr_data = GNUNET_malloc(rd->data_size); 701 attr_data = GNUNET_malloc (rd->data_size);
695 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize(claim, attr_data); 702 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data);
696 new_rd.data = attr_data; 703 new_rd.data = attr_data;
697 new_label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->new_id, 704 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
698 sizeof(uint64_t)); 705 sizeof(uint64_t));
699 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); 706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
700 rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 707 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
701 &rvk->identity, 708 &rvk->identity,
702 new_label, 709 new_label,
703 1, 710 1,
704 &new_rd, 711 &new_rd,
705 &move_attr_finished, 712 &move_attr_finished,
706 rvk); 713 rvk);
707 GNUNET_free(new_label); 714 GNUNET_free (new_label);
708 GNUNET_free(claim); 715 GNUNET_free (claim);
709 GNUNET_free(attr_data); 716 GNUNET_free (attr_data);
710} 717}
711 718
712 719
@@ -719,36 +726,36 @@ rvk_move_attr_cb(void *cls,
719 * @param rvk handle to the operation 726 * @param rvk handle to the operation
720 */ 727 */
721static void 728static void
722move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rvk) 729move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk)
723{ 730{
724 char *label; 731 char *label;
725 732
726 if (NULL == rvk->move_attr) 733 if (NULL == rvk->move_attr)
727 { 734 {
728 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n"); 735 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n");
729 rvk->ns_it = 736 rvk->ns_it =
730 GNUNET_NAMESTORE_zone_iteration_start(nsh, 737 GNUNET_NAMESTORE_zone_iteration_start (nsh,
731 &rvk->identity, 738 &rvk->identity,
732 &rvk_ns_iter_err, 739 &rvk_ns_iter_err,
733 rvk, 740 rvk,
734 &rvk_ticket_update, 741 &rvk_ticket_update,
735 rvk, 742 rvk,
736 &rvk_ticket_update_finished, 743 &rvk_ticket_update_finished,
737 rvk); 744 rvk);
738 return; 745 return;
739 } 746 }
740 label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->old_id, 747 label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id,
741 sizeof(uint64_t)); 748 sizeof(uint64_t));
742 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label); 749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label);
743 750
744 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup(nsh, 751 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
745 &rvk->identity, 752 &rvk->identity,
746 label, 753 label,
747 &rvk_ns_err, 754 &rvk_ns_err,
748 rvk, 755 rvk,
749 &rvk_move_attr_cb, 756 &rvk_move_attr_cb,
750 rvk); 757 rvk);
751 GNUNET_free(label); 758 GNUNET_free (label);
752} 759}
753 760
754 761
@@ -764,29 +771,29 @@ move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rvk)
764 * @param emsg error message (NULL on success) 771 * @param emsg error message (NULL on success)
765 */ 772 */
766static void 773static void
767remove_ticket_cont(void *cls, int32_t success, const char *emsg) 774remove_ticket_cont (void *cls, int32_t success, const char *emsg)
768{ 775{
769 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 776 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
770 777
771 rvk->ns_qe = NULL; 778 rvk->ns_qe = NULL;
772 if (GNUNET_SYSERR == success) 779 if (GNUNET_SYSERR == success)
773 { 780 {
774 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); 781 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
775 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 782 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
776 cleanup_rvk(rvk); 783 cleanup_rvk (rvk);
777 return; 784 return;
778 } 785 }
779 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n"); 786 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n");
780 if (0 == rvk->ticket_attrs) 787 if (0 == rvk->ticket_attrs)
781 { 788 {
782 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 789 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
783 "No attributes to move... strange\n"); 790 "No attributes to move... strange\n");
784 rvk->cb(rvk->cb_cls, GNUNET_OK); 791 rvk->cb (rvk->cb_cls, GNUNET_OK);
785 cleanup_rvk(rvk); 792 cleanup_rvk (rvk);
786 return; 793 return;
787 } 794 }
788 rvk->move_attr = rvk->attrs_head; 795 rvk->move_attr = rvk->attrs_head;
789 move_attrs(rvk); 796 move_attrs (rvk);
790} 797}
791 798
792 799
@@ -801,11 +808,11 @@ remove_ticket_cont(void *cls, int32_t success, const char *emsg)
801 * @param rd record set 808 * @param rd record set
802 */ 809 */
803static void 810static void
804revoke_attrs_cb(void *cls, 811revoke_attrs_cb (void *cls,
805 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 812 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
806 const char *label, 813 const char *label,
807 unsigned int rd_count, 814 unsigned int rd_count,
808 const struct GNUNET_GNSRECORD_Data *rd) 815 const struct GNUNET_GNSRECORD_Data *rd)
809 816
810{ 817{
811 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 818 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
@@ -817,23 +824,23 @@ revoke_attrs_cb(void *cls,
817 * We need it later. 824 * We need it later.
818 */ 825 */
819 for (int i = 0; i < rd_count; i++) 826 for (int i = 0; i < rd_count; i++)
820 { 827 {
821 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 828 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
822 continue; 829 continue;
823 le = GNUNET_new(struct RevokedAttributeEntry); 830 le = GNUNET_new (struct RevokedAttributeEntry);
824 le->old_id = *((uint64_t *)rd[i].data); 831 le->old_id = *((uint64_t *) rd[i].data);
825 GNUNET_CONTAINER_DLL_insert(rvk->attrs_head, rvk->attrs_tail, le); 832 GNUNET_CONTAINER_DLL_insert (rvk->attrs_head, rvk->attrs_tail, le);
826 rvk->ticket_attrs++; 833 rvk->ticket_attrs++;
827 } 834 }
828 835
829 /** Remove attribute references **/ 836 /** Remove attribute references **/
830 rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 837 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
831 &rvk->identity, 838 &rvk->identity,
832 label, 839 label,
833 0, 840 0,
834 NULL, 841 NULL,
835 &remove_ticket_cont, 842 &remove_ticket_cont,
836 rvk); 843 rvk);
837} 844}
838 845
839 846
@@ -843,12 +850,12 @@ revoke_attrs_cb(void *cls,
843 * @param cls handle to the operation 850 * @param cls handle to the operation
844 */ 851 */
845static void 852static void
846rvk_attrs_err_cb(void *cls) 853rvk_attrs_err_cb (void *cls)
847{ 854{
848 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 855 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
849 856
850 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 857 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
851 cleanup_rvk(rvk); 858 cleanup_rvk (rvk);
852} 859}
853 860
854 861
@@ -864,31 +871,31 @@ rvk_attrs_err_cb(void *cls)
864 * @return handle to the operation 871 * @return handle to the operation
865 */ 872 */
866struct RECLAIM_TICKETS_RevokeHandle * 873struct RECLAIM_TICKETS_RevokeHandle *
867RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, 874RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
868 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 875 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
869 RECLAIM_TICKETS_RevokeCallback cb, 876 RECLAIM_TICKETS_RevokeCallback cb,
870 void *cb_cls) 877 void *cb_cls)
871{ 878{
872 struct RECLAIM_TICKETS_RevokeHandle *rvk; 879 struct RECLAIM_TICKETS_RevokeHandle *rvk;
873 char *label; 880 char *label;
874 881
875 rvk = GNUNET_new(struct RECLAIM_TICKETS_RevokeHandle); 882 rvk = GNUNET_new (struct RECLAIM_TICKETS_RevokeHandle);
876 rvk->cb = cb; 883 rvk->cb = cb;
877 rvk->cb_cls = cb_cls; 884 rvk->cb_cls = cb_cls;
878 rvk->identity = *identity; 885 rvk->identity = *identity;
879 rvk->ticket = *ticket; 886 rvk->ticket = *ticket;
880 GNUNET_CRYPTO_ecdsa_key_get_public(&rvk->identity, &rvk->ticket.identity); 887 GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity);
881 /** Get shared attributes **/ 888 /** Get shared attributes **/
882 label = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); 889 label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
883 GNUNET_assert(NULL != label); 890 GNUNET_assert (NULL != label);
884 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup(nsh, 891 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
885 identity, 892 identity,
886 label, 893 label,
887 &rvk_attrs_err_cb, 894 &rvk_attrs_err_cb,
888 rvk, 895 rvk,
889 &revoke_attrs_cb, 896 &revoke_attrs_cb,
890 rvk); 897 rvk);
891 GNUNET_free(label); 898 GNUNET_free (label);
892 return rvk; 899 return rvk;
893} 900}
894 901
@@ -899,10 +906,10 @@ RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket,
899 * @param rh handle to the operation 906 * @param rh handle to the operation
900 */ 907 */
901void 908void
902RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh) 909RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh)
903{ 910{
904 GNUNET_assert(NULL != rh); 911 GNUNET_assert (NULL != rh);
905 cleanup_rvk(rh); 912 cleanup_rvk (rh);
906} 913}
907 914
908 915
@@ -916,28 +923,28 @@ RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
916 * @param cth the handle to clean up 923 * @param cth the handle to clean up
917 */ 924 */
918static void 925static void
919cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth) 926cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth)
920{ 927{
921 struct ParallelLookup *lu; 928 struct ParallelLookup *lu;
922 929
923 if (NULL != cth->lookup_request) 930 if (NULL != cth->lookup_request)
924 GNUNET_GNS_lookup_cancel(cth->lookup_request); 931 GNUNET_GNS_lookup_cancel (cth->lookup_request);
925 if (NULL != cth->kill_task) 932 if (NULL != cth->kill_task)
926 GNUNET_SCHEDULER_cancel(cth->kill_task); 933 GNUNET_SCHEDULER_cancel (cth->kill_task);
927 while (NULL != (lu = cth->parallel_lookups_head)) 934 while (NULL != (lu = cth->parallel_lookups_head))
928 { 935 {
929 if (NULL != lu->lookup_request) 936 if (NULL != lu->lookup_request)
930 GNUNET_GNS_lookup_cancel(lu->lookup_request); 937 GNUNET_GNS_lookup_cancel (lu->lookup_request);
931 GNUNET_free_non_null(lu->label); 938 GNUNET_free_non_null (lu->label);
932 GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, 939 GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head,
933 cth->parallel_lookups_tail, 940 cth->parallel_lookups_tail,
934 lu); 941 lu);
935 GNUNET_free(lu); 942 GNUNET_free (lu);
936 } 943 }
937 944
938 if (NULL != cth->attrs) 945 if (NULL != cth->attrs)
939 GNUNET_RECLAIM_ATTRIBUTE_list_destroy(cth->attrs); 946 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (cth->attrs);
940 GNUNET_free(cth); 947 GNUNET_free (cth);
941} 948}
942 949
943 950
@@ -949,51 +956,51 @@ cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth)
949 * @param rd record set 956 * @param rd record set
950 */ 957 */
951static void 958static void
952process_parallel_lookup_result(void *cls, 959process_parallel_lookup_result (void *cls,
953 uint32_t rd_count, 960 uint32_t rd_count,
954 const struct GNUNET_GNSRECORD_Data *rd) 961 const struct GNUNET_GNSRECORD_Data *rd)
955{ 962{
956 struct ParallelLookup *parallel_lookup = cls; 963 struct ParallelLookup *parallel_lookup = cls;
957 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; 964 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
958 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; 965 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le;
959 966
960 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 967 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
961 "Parallel lookup finished (count=%u)\n", 968 "Parallel lookup finished (count=%u)\n",
962 rd_count); 969 rd_count);
963 970
964 GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, 971 GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head,
965 cth->parallel_lookups_tail, 972 cth->parallel_lookups_tail,
966 parallel_lookup); 973 parallel_lookup);
967 GNUNET_free(parallel_lookup->label); 974 GNUNET_free (parallel_lookup->label);
968 975
969 GNUNET_STATISTICS_update(stats, 976 GNUNET_STATISTICS_update (stats,
970 "attribute_lookup_time_total", 977 "attribute_lookup_time_total",
971 GNUNET_TIME_absolute_get_duration( 978 GNUNET_TIME_absolute_get_duration (
972 parallel_lookup->lookup_start_time) 979 parallel_lookup->lookup_start_time)
973 .rel_value_us, 980 .rel_value_us,
974 GNUNET_YES); 981 GNUNET_YES);
975 GNUNET_STATISTICS_update(stats, "attribute_lookups_count", 1, GNUNET_YES); 982 GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES);
976 983
977 984
978 GNUNET_free(parallel_lookup); 985 GNUNET_free (parallel_lookup);
979 if (1 != rd_count) 986 if (1 != rd_count)
980 GNUNET_break(0); // FIXME: We should never find this. 987 GNUNET_break (0); // FIXME: We should never find this.
981 if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR) 988 if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR)
982 { 989 {
983 attr_le = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 990 attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
984 attr_le->claim = 991 attr_le->claim =
985 GNUNET_RECLAIM_ATTRIBUTE_deserialize(rd->data, rd->data_size); 992 GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size);
986 GNUNET_CONTAINER_DLL_insert(cth->attrs->list_head, 993 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
987 cth->attrs->list_tail, 994 cth->attrs->list_tail,
988 attr_le); 995 attr_le);
989 } 996 }
990 997
991 if (NULL != cth->parallel_lookups_head) 998 if (NULL != cth->parallel_lookups_head)
992 return; // Wait for more 999 return; // Wait for more
993 1000
994 /* Else we are done */ 1001 /* Else we are done */
995 cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); 1002 cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
996 cleanup_cth(cth); 1003 cleanup_cth (cth);
997} 1004}
998 1005
999 1006
@@ -1003,7 +1010,7 @@ process_parallel_lookup_result(void *cls,
1003 * @param cls handle to the operation 1010 * @param cls handle to the operation
1004 */ 1011 */
1005static void 1012static void
1006abort_parallel_lookups(void *cls) 1013abort_parallel_lookups (void *cls)
1007{ 1014{
1008 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; 1015 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1009 struct ParallelLookup *lu; 1016 struct ParallelLookup *lu;
@@ -1011,17 +1018,17 @@ abort_parallel_lookups(void *cls)
1011 1018
1012 cth->kill_task = NULL; 1019 cth->kill_task = NULL;
1013 for (lu = cth->parallel_lookups_head; NULL != lu;) 1020 for (lu = cth->parallel_lookups_head; NULL != lu;)
1014 { 1021 {
1015 GNUNET_GNS_lookup_cancel(lu->lookup_request); 1022 GNUNET_GNS_lookup_cancel (lu->lookup_request);
1016 GNUNET_free(lu->label); 1023 GNUNET_free (lu->label);
1017 tmp = lu->next; 1024 tmp = lu->next;
1018 GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, 1025 GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head,
1019 cth->parallel_lookups_tail, 1026 cth->parallel_lookups_tail,
1020 lu); 1027 lu);
1021 GNUNET_free(lu); 1028 GNUNET_free (lu);
1022 lu = tmp; 1029 lu = tmp;
1023 } 1030 }
1024 cth->cb(cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted"); 1031 cth->cb (cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted");
1025} 1032}
1026 1033
1027 1034
@@ -1035,9 +1042,9 @@ abort_parallel_lookups(void *cls)
1035 * @param rd record set 1042 * @param rd record set
1036 */ 1043 */
1037static void 1044static void
1038lookup_authz_cb(void *cls, 1045lookup_authz_cb (void *cls,
1039 uint32_t rd_count, 1046 uint32_t rd_count,
1040 const struct GNUNET_GNSRECORD_Data *rd) 1047 const struct GNUNET_GNSRECORD_Data *rd)
1041{ 1048{
1042 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; 1049 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1043 struct ParallelLookup *parallel_lookup; 1050 struct ParallelLookup *parallel_lookup;
@@ -1045,56 +1052,56 @@ lookup_authz_cb(void *cls,
1045 1052
1046 cth->lookup_request = NULL; 1053 cth->lookup_request = NULL;
1047 1054
1048 GNUNET_STATISTICS_update(stats, 1055 GNUNET_STATISTICS_update (stats,
1049 "reclaim_authz_lookup_time_total", 1056 "reclaim_authz_lookup_time_total",
1050 GNUNET_TIME_absolute_get_duration( 1057 GNUNET_TIME_absolute_get_duration (
1051 cth->lookup_start_time) 1058 cth->lookup_start_time)
1052 .rel_value_us, 1059 .rel_value_us,
1053 GNUNET_YES); 1060 GNUNET_YES);
1054 GNUNET_STATISTICS_update(stats, 1061 GNUNET_STATISTICS_update (stats,
1055 "reclaim_authz_lookups_count", 1062 "reclaim_authz_lookups_count",
1056 1, 1063 1,
1057 GNUNET_YES); 1064 GNUNET_YES);
1058 1065
1059 for (int i = 0; i < rd_count; i++) 1066 for (int i = 0; i < rd_count; i++)
1060 { 1067 {
1061 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 1068 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1062 continue; 1069 continue;
1063 lbl = GNUNET_STRINGS_data_to_string_alloc(rd[i].data, rd[i].data_size); 1070 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1064 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); 1071 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl);
1065 parallel_lookup = GNUNET_new(struct ParallelLookup); 1072 parallel_lookup = GNUNET_new (struct ParallelLookup);
1066 parallel_lookup->handle = cth; 1073 parallel_lookup->handle = cth;
1067 parallel_lookup->label = lbl; 1074 parallel_lookup->label = lbl;
1068 parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get(); 1075 parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get ();
1069 parallel_lookup->lookup_request = 1076 parallel_lookup->lookup_request =
1070 GNUNET_GNS_lookup(gns, 1077 GNUNET_GNS_lookup (gns,
1071 lbl, 1078 lbl,
1072 &cth->ticket.identity, 1079 &cth->ticket.identity,
1073 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, 1080 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR,
1074 GNUNET_GNS_LO_DEFAULT, 1081 GNUNET_GNS_LO_DEFAULT,
1075 &process_parallel_lookup_result, 1082 &process_parallel_lookup_result,
1076 parallel_lookup); 1083 parallel_lookup);
1077 GNUNET_CONTAINER_DLL_insert(cth->parallel_lookups_head, 1084 GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head,
1078 cth->parallel_lookups_tail, 1085 cth->parallel_lookups_tail,
1079 parallel_lookup); 1086 parallel_lookup);
1080 } 1087 }
1081 /** 1088 /**
1082 * We started lookups. Add a timeout task. 1089 * We started lookups. Add a timeout task.
1083 * FIXME: Really needed here? 1090 * FIXME: Really needed here?
1084 */ 1091 */
1085 if (NULL != cth->parallel_lookups_head) 1092 if (NULL != cth->parallel_lookups_head)
1086 { 1093 {
1087 cth->kill_task = GNUNET_SCHEDULER_add_delayed( 1094 cth->kill_task = GNUNET_SCHEDULER_add_delayed (
1088 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 3), 1095 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3),
1089 &abort_parallel_lookups, 1096 &abort_parallel_lookups,
1090 cth); 1097 cth);
1091 return; 1098 return;
1092 } 1099 }
1093 /** 1100 /**
1094 * No references found, return empty attribute list 1101 * No references found, return empty attribute list
1095 */ 1102 */
1096 cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); 1103 cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
1097 cleanup_cth(cth); 1104 cleanup_cth (cth);
1098} 1105}
1099 1106
1100 1107
@@ -1110,37 +1117,37 @@ lookup_authz_cb(void *cls,
1110 * @return handle to the operation 1117 * @return handle to the operation
1111 */ 1118 */
1112struct RECLAIM_TICKETS_ConsumeHandle * 1119struct RECLAIM_TICKETS_ConsumeHandle *
1113RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, 1120RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1114 const struct GNUNET_RECLAIM_Ticket *ticket, 1121 const struct GNUNET_RECLAIM_Ticket *ticket,
1115 RECLAIM_TICKETS_ConsumeCallback cb, 1122 RECLAIM_TICKETS_ConsumeCallback cb,
1116 void *cb_cls) 1123 void *cb_cls)
1117{ 1124{
1118 struct RECLAIM_TICKETS_ConsumeHandle *cth; 1125 struct RECLAIM_TICKETS_ConsumeHandle *cth;
1119 char *label; 1126 char *label;
1120 1127
1121 cth = GNUNET_new(struct RECLAIM_TICKETS_ConsumeHandle); 1128 cth = GNUNET_new (struct RECLAIM_TICKETS_ConsumeHandle);
1122 1129
1123 cth->identity = *id; 1130 cth->identity = *id;
1124 GNUNET_CRYPTO_ecdsa_key_get_public(&cth->identity, &cth->identity_pub); 1131 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub);
1125 cth->attrs = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 1132 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
1126 cth->ticket = *ticket; 1133 cth->ticket = *ticket;
1127 cth->cb = cb; 1134 cth->cb = cb;
1128 cth->cb_cls = cb_cls; 1135 cth->cb_cls = cb_cls;
1129 label = 1136 label =
1130 GNUNET_STRINGS_data_to_string_alloc(&cth->ticket.rnd, sizeof(uint64_t)); 1137 GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof(uint64_t));
1131 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1138 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1132 "Looking for AuthZ info under %s\n", 1139 "Looking for AuthZ info under %s\n",
1133 label); 1140 label);
1134 cth->lookup_start_time = GNUNET_TIME_absolute_get(); 1141 cth->lookup_start_time = GNUNET_TIME_absolute_get ();
1135 cth->lookup_request = 1142 cth->lookup_request =
1136 GNUNET_GNS_lookup(gns, 1143 GNUNET_GNS_lookup (gns,
1137 label, 1144 label,
1138 &cth->ticket.identity, 1145 &cth->ticket.identity,
1139 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, 1146 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF,
1140 GNUNET_GNS_LO_DEFAULT, 1147 GNUNET_GNS_LO_DEFAULT,
1141 &lookup_authz_cb, 1148 &lookup_authz_cb,
1142 cth); 1149 cth);
1143 GNUNET_free(label); 1150 GNUNET_free (label);
1144 return cth; 1151 return cth;
1145} 1152}
1146 1153
@@ -1151,9 +1158,9 @@ RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1151 * @param cth the operation to cancel 1158 * @param cth the operation to cancel
1152 */ 1159 */
1153void 1160void
1154RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth) 1161RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth)
1155{ 1162{
1156 cleanup_cth(cth); 1163 cleanup_cth (cth);
1157 return; 1164 return;
1158} 1165}
1159 1166
@@ -1167,11 +1174,11 @@ RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
1167 * @param handle the handle to clean up 1174 * @param handle the handle to clean up
1168 */ 1175 */
1169static void 1176static void
1170cleanup_issue_handle(struct TicketIssueHandle *handle) 1177cleanup_issue_handle (struct TicketIssueHandle *handle)
1171{ 1178{
1172 if (NULL != handle->ns_qe) 1179 if (NULL != handle->ns_qe)
1173 GNUNET_NAMESTORE_cancel(handle->ns_qe); 1180 GNUNET_NAMESTORE_cancel (handle->ns_qe);
1174 GNUNET_free(handle); 1181 GNUNET_free (handle);
1175} 1182}
1176 1183
1177 1184
@@ -1184,21 +1191,21 @@ cleanup_issue_handle(struct TicketIssueHandle *handle)
1184 * @param emsg error message (or NULL on success) 1191 * @param emsg error message (or NULL on success)
1185 */ 1192 */
1186static void 1193static void
1187store_ticket_issue_cont(void *cls, int32_t success, const char *emsg) 1194store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
1188{ 1195{
1189 struct TicketIssueHandle *handle = cls; 1196 struct TicketIssueHandle *handle = cls;
1190 1197
1191 handle->ns_qe = NULL; 1198 handle->ns_qe = NULL;
1192 if (GNUNET_SYSERR == success) 1199 if (GNUNET_SYSERR == success)
1193 { 1200 {
1194 handle->cb(handle->cb_cls, 1201 handle->cb (handle->cb_cls,
1195 &handle->ticket, 1202 &handle->ticket,
1196 GNUNET_SYSERR, 1203 GNUNET_SYSERR,
1197 "Error storing AuthZ ticket in GNS"); 1204 "Error storing AuthZ ticket in GNS");
1198 return; 1205 return;
1199 } 1206 }
1200 handle->cb(handle->cb_cls, &handle->ticket, GNUNET_OK, NULL); 1207 handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL);
1201 cleanup_issue_handle(handle); 1208 cleanup_issue_handle (handle);
1202} 1209}
1203 1210
1204 1211
@@ -1210,7 +1217,7 @@ store_ticket_issue_cont(void *cls, int32_t success, const char *emsg)
1210 * @param ih handle to the operation containing relevant metadata 1217 * @param ih handle to the operation containing relevant metadata
1211 */ 1218 */
1212static void 1219static void
1213issue_ticket(struct TicketIssueHandle *ih) 1220issue_ticket (struct TicketIssueHandle *ih)
1214{ 1221{
1215 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 1222 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
1216 struct GNUNET_GNSRECORD_Data *attrs_record; 1223 struct GNUNET_GNSRECORD_Data *attrs_record;
@@ -1222,21 +1229,21 @@ issue_ticket(struct TicketIssueHandle *ih)
1222 list_len++; 1229 list_len++;
1223 1230
1224 attrs_record = 1231 attrs_record =
1225 GNUNET_malloc(list_len * sizeof(struct GNUNET_GNSRECORD_Data)); 1232 GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data));
1226 i = 0; 1233 i = 0;
1227 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1234 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1228 { 1235 {
1229 attrs_record[i].data = &le->claim->id; 1236 attrs_record[i].data = &le->claim->id;
1230 attrs_record[i].data_size = sizeof(le->claim->id); 1237 attrs_record[i].data_size = sizeof(le->claim->id);
1231 /** 1238 /**
1232 * FIXME: Should this be the attribute expiration time or ticket 1239 * FIXME: Should this be the attribute expiration time or ticket
1233 * refresh interval? Probably min(attrs.expiration) 1240 * refresh interval? Probably min(attrs.expiration)
1234 */ 1241 */
1235 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1242 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1236 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; 1243 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF;
1237 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1244 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1238 i++; 1245 i++;
1239 } 1246 }
1240 attrs_record[i].data = &ih->ticket; 1247 attrs_record[i].data = &ih->ticket;
1241 attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket); 1248 attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
1242 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1249 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
@@ -1245,17 +1252,17 @@ issue_ticket(struct TicketIssueHandle *ih)
1245 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; 1252 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
1246 1253
1247 label = 1254 label =
1248 GNUNET_STRINGS_data_to_string_alloc(&ih->ticket.rnd, sizeof(uint64_t)); 1255 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof(uint64_t));
1249 // Publish record 1256 // Publish record
1250 ih->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 1257 ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1251 &ih->identity, 1258 &ih->identity,
1252 label, 1259 label,
1253 list_len, 1260 list_len,
1254 attrs_record, 1261 attrs_record,
1255 &store_ticket_issue_cont, 1262 &store_ticket_issue_cont,
1256 ih); 1263 ih);
1257 GNUNET_free(attrs_record); 1264 GNUNET_free (attrs_record);
1258 GNUNET_free(label); 1265 GNUNET_free (label);
1259} 1266}
1260 1267
1261/************************************************* 1268/*************************************************
@@ -1269,16 +1276,16 @@ issue_ticket(struct TicketIssueHandle *ih)
1269 * @param cls handle to the operation 1276 * @param cls handle to the operation
1270 */ 1277 */
1271static void 1278static void
1272filter_tickets_error_cb(void *cls) 1279filter_tickets_error_cb (void *cls)
1273{ 1280{
1274 struct TicketIssueHandle *tih = cls; 1281 struct TicketIssueHandle *tih = cls;
1275 1282
1276 tih->ns_it = NULL; 1283 tih->ns_it = NULL;
1277 tih->cb(tih->cb_cls, 1284 tih->cb (tih->cb_cls,
1278 &tih->ticket, 1285 &tih->ticket,
1279 GNUNET_SYSERR, 1286 GNUNET_SYSERR,
1280 "Error storing AuthZ ticket in GNS"); 1287 "Error storing AuthZ ticket in GNS");
1281 cleanup_issue_handle(tih); 1288 cleanup_issue_handle (tih);
1282} 1289}
1283 1290
1284 1291
@@ -1295,11 +1302,11 @@ filter_tickets_error_cb(void *cls)
1295 * @param rd record set 1302 * @param rd record set
1296 */ 1303 */
1297static void 1304static void
1298filter_tickets_cb(void *cls, 1305filter_tickets_cb (void *cls,
1299 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 1306 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1300 const char *label, 1307 const char *label,
1301 unsigned int rd_count, 1308 unsigned int rd_count,
1302 const struct GNUNET_GNSRECORD_Data *rd) 1309 const struct GNUNET_GNSRECORD_Data *rd)
1303{ 1310{
1304 struct TicketIssueHandle *tih = cls; 1311 struct TicketIssueHandle *tih = cls;
1305 struct GNUNET_RECLAIM_Ticket *ticket = NULL; 1312 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
@@ -1315,53 +1322,53 @@ filter_tickets_cb(void *cls,
1315 unsigned int found_attrs_cnt = 0; 1322 unsigned int found_attrs_cnt = 0;
1316 1323
1317 for (int i = 0; i < rd_count; i++) 1324 for (int i = 0; i < rd_count; i++)
1325 {
1326 // found ticket
1327 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type)
1318 { 1328 {
1319 // found ticket 1329 ticket = (struct GNUNET_RECLAIM_Ticket *) rd[i].data;
1320 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type) 1330 // cmp audience
1321 { 1331 if (0 == memcmp (&tih->ticket.audience,
1322 ticket = (struct GNUNET_RECLAIM_Ticket *)rd[i].data; 1332 &ticket->audience,
1323 // cmp audience 1333 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1324 if (0 == memcmp(&tih->ticket.audience, 1334 {
1325 &ticket->audience, 1335 tih->ticket = *ticket;
1326 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1327 {
1328 tih->ticket = *ticket;
1329 continue;
1330 }
1331 ticket = NULL;
1332 }
1333
1334 // cmp requested attributes with ticket attributes
1335 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1336 continue; 1336 continue;
1337 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1337 }
1338 { 1338 ticket = NULL;
1339 // cmp attr_ref id with requested attr id
1340 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1341 " %" PRIu64 "\n %" PRIu64 "\n",
1342 *((uint64_t *)rd[i].data),
1343 le->claim->id);
1344
1345
1346 if (0 == memcmp(rd[i].data, &le->claim->id, sizeof(uint64_t)))
1347 found_attrs_cnt++;
1348 }
1349 } 1339 }
1350 1340
1341 // cmp requested attributes with ticket attributes
1342 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1343 continue;
1344 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1345 {
1346 // cmp attr_ref id with requested attr id
1347 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1348 " %" PRIu64 "\n %" PRIu64 "\n",
1349 *((uint64_t *) rd[i].data),
1350 le->claim->id);
1351
1352
1353 if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(uint64_t)))
1354 found_attrs_cnt++;
1355 }
1356 }
1357
1351 /** 1358 /**
1352 * If we found a matching ticket, return that to the caller and 1359 * If we found a matching ticket, return that to the caller and
1353 * we are done. 1360 * we are done.
1354 */ 1361 */
1355 if (attr_cnt == found_attrs_cnt && NULL != ticket) 1362 if ((attr_cnt == found_attrs_cnt)&&(NULL != ticket))
1356 { 1363 {
1357 GNUNET_NAMESTORE_zone_iteration_stop(tih->ns_it); 1364 GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it);
1358 tih->cb(tih->cb_cls, &tih->ticket, GNUNET_OK, NULL); 1365 tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL);
1359 cleanup_issue_handle(tih); 1366 cleanup_issue_handle (tih);
1360 return; 1367 return;
1361 } 1368 }
1362 1369
1363 // ticket not found in current record, checking next record set 1370 // ticket not found in current record, checking next record set
1364 GNUNET_NAMESTORE_zone_iterator_next(tih->ns_it, 1); 1371 GNUNET_NAMESTORE_zone_iterator_next (tih->ns_it, 1);
1365} 1372}
1366 1373
1367 1374
@@ -1373,14 +1380,14 @@ filter_tickets_cb(void *cls,
1373 * @param cls handle to the operation 1380 * @param cls handle to the operation
1374 */ 1381 */
1375static void 1382static void
1376filter_tickets_finished_cb(void *cls) 1383filter_tickets_finished_cb (void *cls)
1377{ 1384{
1378 struct TicketIssueHandle *tih = cls; 1385 struct TicketIssueHandle *tih = cls;
1379 1386
1380 GNUNET_CRYPTO_ecdsa_key_get_public(&tih->identity, &tih->ticket.identity); 1387 GNUNET_CRYPTO_ecdsa_key_get_public (&tih->identity, &tih->ticket.identity);
1381 tih->ticket.rnd = 1388 tih->ticket.rnd =
1382 GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); 1389 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
1383 issue_ticket(tih); 1390 issue_ticket (tih);
1384} 1391}
1385 1392
1386 1393
@@ -1396,31 +1403,31 @@ filter_tickets_finished_cb(void *cls)
1396 * FIXME: Return handle?? 1403 * FIXME: Return handle??
1397 */ 1404 */
1398void 1405void
1399RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1406RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1400 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 1407 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
1401 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, 1408 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
1402 RECLAIM_TICKETS_TicketResult cb, 1409 RECLAIM_TICKETS_TicketResult cb,
1403 void *cb_cls) 1410 void *cb_cls)
1404{ 1411{
1405 struct TicketIssueHandle *tih; 1412 struct TicketIssueHandle *tih;
1406 1413
1407 tih = GNUNET_new(struct TicketIssueHandle); 1414 tih = GNUNET_new (struct TicketIssueHandle);
1408 tih->cb = cb; 1415 tih->cb = cb;
1409 tih->cb_cls = cb_cls; 1416 tih->cb_cls = cb_cls;
1410 tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup(attrs); 1417 tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (attrs);
1411 tih->identity = *identity; 1418 tih->identity = *identity;
1412 tih->ticket.audience = *audience; 1419 tih->ticket.audience = *audience;
1413 1420
1414 // First check whether the ticket has already been issued 1421 // First check whether the ticket has already been issued
1415 tih->ns_it = 1422 tih->ns_it =
1416 GNUNET_NAMESTORE_zone_iteration_start(nsh, 1423 GNUNET_NAMESTORE_zone_iteration_start (nsh,
1417 &tih->identity, 1424 &tih->identity,
1418 &filter_tickets_error_cb, 1425 &filter_tickets_error_cb,
1419 tih, 1426 tih,
1420 &filter_tickets_cb, 1427 &filter_tickets_cb,
1421 tih, 1428 tih,
1422 &filter_tickets_finished_cb, 1429 &filter_tickets_finished_cb,
1423 tih); 1430 tih);
1424} 1431}
1425 1432
1426 1433
@@ -1434,11 +1441,11 @@ RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1434 * @param iter handle to the iteration 1441 * @param iter handle to the iteration
1435 */ 1442 */
1436static void 1443static void
1437cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter) 1444cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter)
1438{ 1445{
1439 if (NULL != iter->ns_it) 1446 if (NULL != iter->ns_it)
1440 GNUNET_NAMESTORE_zone_iteration_stop(iter->ns_it); 1447 GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it);
1441 GNUNET_free(iter); 1448 GNUNET_free (iter);
1442} 1449}
1443 1450
1444 1451
@@ -1454,22 +1461,22 @@ cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter)
1454 * @param rd record set containing a ticket 1461 * @param rd record set containing a ticket
1455 */ 1462 */
1456static void 1463static void
1457collect_tickets_cb(void *cls, 1464collect_tickets_cb (void *cls,
1458 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 1465 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1459 const char *label, 1466 const char *label,
1460 unsigned int rd_count, 1467 unsigned int rd_count,
1461 const struct GNUNET_GNSRECORD_Data *rd) 1468 const struct GNUNET_GNSRECORD_Data *rd)
1462{ 1469{
1463 struct RECLAIM_TICKETS_Iterator *iter = cls; 1470 struct RECLAIM_TICKETS_Iterator *iter = cls;
1464 1471
1465 for (int i = 0; i < rd_count; i++) 1472 for (int i = 0; i < rd_count; i++)
1466 { 1473 {
1467 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) 1474 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
1468 continue; 1475 continue;
1469 iter->cb(iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *)rd[i].data); 1476 iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data);
1470 return; 1477 return;
1471 } 1478 }
1472 GNUNET_NAMESTORE_zone_iterator_next(iter->ns_it, 1); 1479 GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1);
1473} 1480}
1474 1481
1475 1482
@@ -1479,13 +1486,13 @@ collect_tickets_cb(void *cls,
1479 * @param cls handle to the iteration 1486 * @param cls handle to the iteration
1480 */ 1487 */
1481static void 1488static void
1482collect_tickets_finished_cb(void *cls) 1489collect_tickets_finished_cb (void *cls)
1483{ 1490{
1484 struct RECLAIM_TICKETS_Iterator *iter = cls; 1491 struct RECLAIM_TICKETS_Iterator *iter = cls;
1485 1492
1486 iter->ns_it = NULL; 1493 iter->ns_it = NULL;
1487 iter->cb(iter->cb_cls, NULL); 1494 iter->cb (iter->cb_cls, NULL);
1488 cleanup_iter(iter); 1495 cleanup_iter (iter);
1489} 1496}
1490 1497
1491 1498
@@ -1495,13 +1502,13 @@ collect_tickets_finished_cb(void *cls)
1495 * @param cls the iteration handle 1502 * @param cls the iteration handle
1496 */ 1503 */
1497static void 1504static void
1498collect_tickets_error_cb(void *cls) 1505collect_tickets_error_cb (void *cls)
1499{ 1506{
1500 struct RECLAIM_TICKETS_Iterator *iter = cls; 1507 struct RECLAIM_TICKETS_Iterator *iter = cls;
1501 1508
1502 iter->ns_it = NULL; 1509 iter->ns_it = NULL;
1503 iter->cb(iter->cb_cls, NULL); 1510 iter->cb (iter->cb_cls, NULL);
1504 cleanup_iter(iter); 1511 cleanup_iter (iter);
1505} 1512}
1506 1513
1507 1514
@@ -1511,9 +1518,9 @@ collect_tickets_error_cb(void *cls)
1511 * @param iter the iteration to continue 1518 * @param iter the iteration to continue
1512 */ 1519 */
1513void 1520void
1514RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter) 1521RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter)
1515{ 1522{
1516 GNUNET_NAMESTORE_zone_iterator_next(iter->ns_it, 1); 1523 GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1);
1517} 1524}
1518 1525
1519 1526
@@ -1523,10 +1530,10 @@ RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter)
1523 * @param iter iteration to cancel 1530 * @param iter iteration to cancel
1524 */ 1531 */
1525void 1532void
1526RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter) 1533RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter)
1527{ 1534{
1528 GNUNET_NAMESTORE_zone_iteration_stop(iter->ns_it); 1535 GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it);
1529 cleanup_iter(iter); 1536 cleanup_iter (iter);
1530} 1537}
1531 1538
1532 1539
@@ -1539,25 +1546,25 @@ RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
1539 * @return a handle to the iteration 1546 * @return a handle to the iteration
1540 */ 1547 */
1541struct RECLAIM_TICKETS_Iterator * 1548struct RECLAIM_TICKETS_Iterator *
1542RECLAIM_TICKETS_iteration_start( 1549RECLAIM_TICKETS_iteration_start (
1543 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1550 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1544 RECLAIM_TICKETS_TicketIter cb, 1551 RECLAIM_TICKETS_TicketIter cb,
1545 void *cb_cls) 1552 void *cb_cls)
1546{ 1553{
1547 struct RECLAIM_TICKETS_Iterator *iter; 1554 struct RECLAIM_TICKETS_Iterator *iter;
1548 1555
1549 iter = GNUNET_new(struct RECLAIM_TICKETS_Iterator); 1556 iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
1550 iter->cb = cb; 1557 iter->cb = cb;
1551 iter->cb_cls = cb_cls; 1558 iter->cb_cls = cb_cls;
1552 iter->ns_it = 1559 iter->ns_it =
1553 GNUNET_NAMESTORE_zone_iteration_start(nsh, 1560 GNUNET_NAMESTORE_zone_iteration_start (nsh,
1554 identity, 1561 identity,
1555 &collect_tickets_error_cb, 1562 &collect_tickets_error_cb,
1556 iter, 1563 iter,
1557 &collect_tickets_cb, 1564 &collect_tickets_cb,
1558 iter, 1565 iter,
1559 &collect_tickets_finished_cb, 1566 &collect_tickets_finished_cb,
1560 iter); 1567 iter);
1561 return iter; 1568 return iter;
1562} 1569}
1563 1570
@@ -1569,39 +1576,39 @@ RECLAIM_TICKETS_iteration_start(
1569 * @return GNUNET_SYSERR on error 1576 * @return GNUNET_SYSERR on error
1570 */ 1577 */
1571int 1578int
1572RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c) 1579RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c)
1573{ 1580{
1574 // Get ticket expiration time (relative) from config 1581 // Get ticket expiration time (relative) from config
1575 if (GNUNET_OK == 1582 if (GNUNET_OK ==
1576 GNUNET_CONFIGURATION_get_value_time(c, 1583 GNUNET_CONFIGURATION_get_value_time (c,
1577 "reclaim", 1584 "reclaim",
1578 "TICKET_REFRESH_INTERVAL", 1585 "TICKET_REFRESH_INTERVAL",
1579 &ticket_refresh_interval)) 1586 &ticket_refresh_interval))
1580 { 1587 {
1581 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1588 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1582 "Configured refresh interval for tickets: %s\n", 1589 "Configured refresh interval for tickets: %s\n",
1583 GNUNET_STRINGS_relative_time_to_string(ticket_refresh_interval, 1590 GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval,
1584 GNUNET_YES)); 1591 GNUNET_YES));
1585 } 1592 }
1586 else 1593 else
1587 { 1594 {
1588 ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; 1595 ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL;
1589 } 1596 }
1590 // Connect to identity and namestore services 1597 // Connect to identity and namestore services
1591 nsh = GNUNET_NAMESTORE_connect(c); 1598 nsh = GNUNET_NAMESTORE_connect (c);
1592 if (NULL == nsh) 1599 if (NULL == nsh)
1593 { 1600 {
1594 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, 1601 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
1595 "error connecting to namestore"); 1602 "error connecting to namestore");
1596 return GNUNET_SYSERR; 1603 return GNUNET_SYSERR;
1597 } 1604 }
1598 gns = GNUNET_GNS_connect(c); 1605 gns = GNUNET_GNS_connect (c);
1599 if (NULL == gns) 1606 if (NULL == gns)
1600 { 1607 {
1601 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "error connecting to gns"); 1608 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns");
1602 return GNUNET_SYSERR; 1609 return GNUNET_SYSERR;
1603 } 1610 }
1604 stats = GNUNET_STATISTICS_create("reclaim", c); 1611 stats = GNUNET_STATISTICS_create ("reclaim", c);
1605 return GNUNET_OK; 1612 return GNUNET_OK;
1606} 1613}
1607 1614
@@ -1611,17 +1618,17 @@ RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
1611 * FIXME: cancel all pending operations (gns, ns etc) 1618 * FIXME: cancel all pending operations (gns, ns etc)
1612 */ 1619 */
1613void 1620void
1614RECLAIM_TICKETS_deinit(void) 1621RECLAIM_TICKETS_deinit (void)
1615{ 1622{
1616 if (NULL != nsh) 1623 if (NULL != nsh)
1617 GNUNET_NAMESTORE_disconnect(nsh); 1624 GNUNET_NAMESTORE_disconnect (nsh);
1618 nsh = NULL; 1625 nsh = NULL;
1619 if (NULL != gns) 1626 if (NULL != gns)
1620 GNUNET_GNS_disconnect(gns); 1627 GNUNET_GNS_disconnect (gns);
1621 gns = NULL; 1628 gns = NULL;
1622 if (NULL != stats) 1629 if (NULL != stats)
1623 { 1630 {
1624 GNUNET_STATISTICS_destroy(stats, GNUNET_NO); 1631 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
1625 stats = NULL; 1632 stats = NULL;
1626 } 1633 }
1627} 1634}