diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-05-22 16:25:38 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-05-22 16:25:38 +0200 |
commit | b2e257ecb9c82b19f6ab23431faa3605718d3f01 (patch) | |
tree | 767b8cf35d6e1c9a741ee7e87f33dc852a6593cc /src/reclaim/gnunet-service-reclaim_tickets.c | |
parent | f9c41505dd2ad80d08d6b516c534df0a66ea55fc (diff) | |
download | gnunet-b2e257ecb9c82b19f6ab23431faa3605718d3f01.tar.gz gnunet-b2e257ecb9c82b19f6ab23431faa3605718d3f01.zip |
clang-format and cleanup
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.c | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index f18b11cb1..d20a4e3bf 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -25,7 +25,6 @@ | |||
25 | * | 25 | * |
26 | */ | 26 | */ |
27 | #include <inttypes.h> | 27 | #include <inttypes.h> |
28 | |||
29 | #include "gnunet-service-reclaim_tickets.h" | 28 | #include "gnunet-service-reclaim_tickets.h" |
30 | 29 | ||
31 | #define DEFAULT_TICKET_REFRESH_INTERVAL GNUNET_TIME_UNIT_HOURS | 30 | #define DEFAULT_TICKET_REFRESH_INTERVAL GNUNET_TIME_UNIT_HOURS |
@@ -406,7 +405,7 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
406 | } | 405 | } |
407 | /** find a new place for this attribute **/ | 406 | /** find a new place for this attribute **/ |
408 | rvk->move_attr->new_id = | 407 | rvk->move_attr->new_id = |
409 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 408 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); |
410 | new_rd = *rd; | 409 | new_rd = *rd; |
411 | claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); | 410 | claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); |
412 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 411 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -421,7 +420,7 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
421 | sizeof (uint64_t)); | 420 | sizeof (uint64_t)); |
422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); | 421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); |
423 | rvk->ns_qe = GNUNET_NAMESTORE_records_store ( | 422 | rvk->ns_qe = GNUNET_NAMESTORE_records_store ( |
424 | nsh, &rvk->identity, new_label, 1, &new_rd, &move_attr_finished, rvk); | 423 | nsh, &rvk->identity, new_label, 1, &new_rd, &move_attr_finished, rvk); |
425 | GNUNET_free (new_label); | 424 | GNUNET_free (new_label); |
426 | GNUNET_free (claim); | 425 | GNUNET_free (claim); |
427 | GNUNET_free (attr_data); | 426 | GNUNET_free (attr_data); |
@@ -506,7 +505,7 @@ process_tickets (void *cls) | |||
506 | } | 505 | } |
507 | } | 506 | } |
508 | rvk->ns_qe = GNUNET_NAMESTORE_records_store ( | 507 | rvk->ns_qe = GNUNET_NAMESTORE_records_store ( |
509 | nsh, &rvk->identity, le->label, le->rd_count, rd, &ticket_processed, rvk); | 508 | nsh, &rvk->identity, le->label, le->rd_count, rd, &ticket_processed, rvk); |
510 | GNUNET_free (le->label); | 509 | GNUNET_free (le->label); |
511 | GNUNET_free (le->data); | 510 | GNUNET_free (le->data); |
512 | GNUNET_free (le); | 511 | GNUNET_free (le); |
@@ -555,8 +554,8 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk) | |||
555 | if (NULL == rvk->move_attr) { | 554 | if (NULL == rvk->move_attr) { |
556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n"); | 555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n"); |
557 | rvk->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( | 556 | rvk->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( |
558 | nsh, &rvk->identity, &rvk_ns_iter_err, rvk, &rvk_ticket_update, rvk, | 557 | nsh, &rvk->identity, &rvk_ns_iter_err, rvk, &rvk_ticket_update, rvk, |
559 | &rvk_ticket_update_finished, rvk); | 558 | &rvk_ticket_update_finished, rvk); |
560 | return; | 559 | return; |
561 | } | 560 | } |
562 | label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, | 561 | label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, |
@@ -564,7 +563,7 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk) | |||
564 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label); | 563 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label); |
565 | 564 | ||
566 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup ( | 565 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup ( |
567 | nsh, &rvk->identity, label, &rvk_ns_err, rvk, &rvk_move_attr_cb, rvk); | 566 | nsh, &rvk->identity, label, &rvk_ns_err, rvk, &rvk_move_attr_cb, rvk); |
568 | GNUNET_free (label); | 567 | GNUNET_free (label); |
569 | } | 568 | } |
570 | 569 | ||
@@ -644,7 +643,7 @@ RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, | |||
644 | label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t)); | 643 | label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t)); |
645 | 644 | ||
646 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup ( | 645 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup ( |
647 | nsh, identity, label, &rvk_attrs_err_cb, rvk, &revoke_attrs_cb, rvk); | 646 | nsh, identity, label, &rvk_attrs_err_cb, rvk, &revoke_attrs_cb, rvk); |
648 | return rvk; | 647 | return rvk; |
649 | } | 648 | } |
650 | 649 | ||
@@ -700,10 +699,10 @@ process_parallel_lookup_result (void *cls, uint32_t rd_count, | |||
700 | GNUNET_free (parallel_lookup->label); | 699 | GNUNET_free (parallel_lookup->label); |
701 | 700 | ||
702 | GNUNET_STATISTICS_update ( | 701 | GNUNET_STATISTICS_update ( |
703 | stats, "attribute_lookup_time_total", | 702 | stats, "attribute_lookup_time_total", |
704 | GNUNET_TIME_absolute_get_duration (parallel_lookup->lookup_start_time) | 703 | GNUNET_TIME_absolute_get_duration (parallel_lookup->lookup_start_time) |
705 | .rel_value_us, | 704 | .rel_value_us, |
706 | GNUNET_YES); | 705 | GNUNET_YES); |
707 | GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES); | 706 | GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES); |
708 | 707 | ||
709 | 708 | ||
@@ -713,7 +712,7 @@ process_parallel_lookup_result (void *cls, uint32_t rd_count, | |||
713 | if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR) { | 712 | if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR) { |
714 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); | 713 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
715 | attr_le->claim = | 714 | attr_le->claim = |
716 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); | 715 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); |
717 | GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, cth->attrs->list_tail, | 716 | GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, cth->attrs->list_tail, |
718 | attr_le); | 717 | attr_le); |
719 | } | 718 | } |
@@ -758,9 +757,9 @@ lookup_authz_cb (void *cls, uint32_t rd_count, | |||
758 | cth->lookup_request = NULL; | 757 | cth->lookup_request = NULL; |
759 | 758 | ||
760 | GNUNET_STATISTICS_update ( | 759 | GNUNET_STATISTICS_update ( |
761 | stats, "reclaim_authz_lookup_time_total", | 760 | stats, "reclaim_authz_lookup_time_total", |
762 | GNUNET_TIME_absolute_get_duration (cth->lookup_start_time).rel_value_us, | 761 | GNUNET_TIME_absolute_get_duration (cth->lookup_start_time).rel_value_us, |
763 | GNUNET_YES); | 762 | GNUNET_YES); |
764 | GNUNET_STATISTICS_update (stats, "reclaim_authz_lookups_count", 1, | 763 | GNUNET_STATISTICS_update (stats, "reclaim_authz_lookups_count", 1, |
765 | GNUNET_YES); | 764 | GNUNET_YES); |
766 | 765 | ||
@@ -774,16 +773,16 @@ lookup_authz_cb (void *cls, uint32_t rd_count, | |||
774 | parallel_lookup->label = lbl; | 773 | parallel_lookup->label = lbl; |
775 | parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get (); | 774 | parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get (); |
776 | parallel_lookup->lookup_request = GNUNET_GNS_lookup ( | 775 | parallel_lookup->lookup_request = GNUNET_GNS_lookup ( |
777 | gns, lbl, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, | 776 | gns, lbl, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, |
778 | GNUNET_GNS_LO_DEFAULT, &process_parallel_lookup_result, | 777 | GNUNET_GNS_LO_DEFAULT, &process_parallel_lookup_result, |
779 | parallel_lookup); | 778 | parallel_lookup); |
780 | GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, | 779 | GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, |
781 | cth->parallel_lookups_tail, parallel_lookup); | 780 | cth->parallel_lookups_tail, parallel_lookup); |
782 | } | 781 | } |
783 | if (NULL != cth->parallel_lookups_head) { | 782 | if (NULL != cth->parallel_lookups_head) { |
784 | cth->kill_task = GNUNET_SCHEDULER_add_delayed ( | 783 | cth->kill_task = GNUNET_SCHEDULER_add_delayed ( |
785 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), | 784 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), |
786 | &abort_parallel_lookups, cth); | 785 | &abort_parallel_lookups, cth); |
787 | return; | 786 | return; |
788 | } | 787 | } |
789 | cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); | 788 | cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); |
@@ -807,13 +806,13 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, | |||
807 | cth->cb = cb; | 806 | cth->cb = cb; |
808 | cth->cb_cls = cb_cls; | 807 | cth->cb_cls = cb_cls; |
809 | label = | 808 | label = |
810 | GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); | 809 | GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); |
811 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for AuthZ info under %s\n", | 810 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for AuthZ info under %s\n", |
812 | label); | 811 | label); |
813 | cth->lookup_start_time = GNUNET_TIME_absolute_get (); | 812 | cth->lookup_start_time = GNUNET_TIME_absolute_get (); |
814 | cth->lookup_request = GNUNET_GNS_lookup ( | 813 | cth->lookup_request = GNUNET_GNS_lookup ( |
815 | gns, label, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, | 814 | gns, label, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, |
816 | GNUNET_GNS_LO_DEFAULT, &lookup_authz_cb, cth); | 815 | GNUNET_GNS_LO_DEFAULT, &lookup_authz_cb, cth); |
817 | GNUNET_free (label); | 816 | GNUNET_free (label); |
818 | return cth; | 817 | return cth; |
819 | } | 818 | } |
@@ -872,7 +871,7 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
872 | list_len++; | 871 | list_len++; |
873 | 872 | ||
874 | attrs_record = | 873 | attrs_record = |
875 | GNUNET_malloc (list_len * sizeof (struct GNUNET_GNSRECORD_Data)); | 874 | GNUNET_malloc (list_len * sizeof (struct GNUNET_GNSRECORD_Data)); |
876 | i = 0; | 875 | i = 0; |
877 | for (le = ih->attrs->list_head; NULL != le; le = le->next) { | 876 | for (le = ih->attrs->list_head; NULL != le; le = le->next) { |
878 | attrs_record[i].data = &le->claim->id; | 877 | attrs_record[i].data = &le->claim->id; |
@@ -888,10 +887,10 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
888 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; | 887 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; |
889 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; | 888 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; |
890 | attrs_record[i].flags = | 889 | attrs_record[i].flags = |
891 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; | 890 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; |
892 | 891 | ||
893 | label = | 892 | label = |
894 | GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); | 893 | GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); |
895 | // Publish record | 894 | // Publish record |
896 | ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &ih->identity, label, | 895 | ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &ih->identity, label, |
897 | list_len, attrs_record, | 896 | list_len, attrs_record, |
@@ -915,7 +914,7 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | |||
915 | tih->identity = *identity; | 914 | tih->identity = *identity; |
916 | GNUNET_CRYPTO_ecdsa_key_get_public (identity, &tih->ticket.identity); | 915 | GNUNET_CRYPTO_ecdsa_key_get_public (identity, &tih->ticket.identity); |
917 | tih->ticket.rnd = | 916 | tih->ticket.rnd = |
918 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 917 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); |
919 | tih->ticket.audience = *audience; | 918 | tih->ticket.audience = *audience; |
920 | issue_ticket (tih); | 919 | issue_ticket (tih); |
921 | } | 920 | } |
@@ -987,8 +986,8 @@ RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter) | |||
987 | 986 | ||
988 | struct RECLAIM_TICKETS_Iterator * | 987 | struct RECLAIM_TICKETS_Iterator * |
989 | RECLAIM_TICKETS_iteration_start ( | 988 | RECLAIM_TICKETS_iteration_start ( |
990 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 989 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
991 | RECLAIM_TICKETS_TicketIter cb, void *cb_cls) | 990 | RECLAIM_TICKETS_TicketIter cb, void *cb_cls) |
992 | { | 991 | { |
993 | struct RECLAIM_TICKETS_Iterator *iter; | 992 | struct RECLAIM_TICKETS_Iterator *iter; |
994 | 993 | ||
@@ -996,8 +995,8 @@ RECLAIM_TICKETS_iteration_start ( | |||
996 | iter->cb = cb; | 995 | iter->cb = cb; |
997 | iter->cb_cls = cb_cls; | 996 | iter->cb_cls = cb_cls; |
998 | iter->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( | 997 | iter->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( |
999 | nsh, identity, &collect_tickets_error_cb, iter, &collect_tickets_cb, iter, | 998 | nsh, identity, &collect_tickets_error_cb, iter, &collect_tickets_cb, iter, |
1000 | &collect_tickets_finished_cb, iter); | 999 | &collect_tickets_finished_cb, iter); |
1001 | return iter; | 1000 | return iter; |
1002 | } | 1001 | } |
1003 | 1002 | ||
@@ -1012,10 +1011,10 @@ RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
1012 | "TICKET_REFRESH_INTERVAL", | 1011 | "TICKET_REFRESH_INTERVAL", |
1013 | &ticket_refresh_interval)) { | 1012 | &ticket_refresh_interval)) { |
1014 | GNUNET_log ( | 1013 | GNUNET_log ( |
1015 | GNUNET_ERROR_TYPE_DEBUG, | 1014 | GNUNET_ERROR_TYPE_DEBUG, |
1016 | "Configured refresh interval for tickets: %s\n", | 1015 | "Configured refresh interval for tickets: %s\n", |
1017 | GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval, | 1016 | GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval, |
1018 | GNUNET_YES)); | 1017 | GNUNET_YES)); |
1019 | } else { | 1018 | } else { |
1020 | ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; | 1019 | ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; |
1021 | } | 1020 | } |