diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-04 18:42:04 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-09 20:38:10 +0100 |
commit | 55f6d26b7424d660c99bc89f3677b20294e87a27 (patch) | |
tree | a8080fdcf0d9688c154417e50c58055e364f8b6b /src/reclaim/gnunet-reclaim.c | |
parent | 5b6bb2ce4d60635b2af950d72b45f12686fd5218 (diff) | |
download | gnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.tar.gz gnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.zip |
Refactoring reclaim attestations
Diffstat (limited to 'src/reclaim/gnunet-reclaim.c')
-rw-r--r-- | src/reclaim/gnunet-reclaim.c | 72 |
1 files changed, 37 insertions, 35 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index c3d305eb5..b72336907 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -135,7 +135,7 @@ static struct GNUNET_RECLAIM_Ticket ticket; | |||
135 | /** | 135 | /** |
136 | * Attribute list | 136 | * Attribute list |
137 | */ | 137 | */ |
138 | static struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list; | 138 | static struct GNUNET_RECLAIM_AttributeList *attr_list; |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * Attribute expiration interval | 141 | * Attribute expiration interval |
@@ -155,7 +155,7 @@ static struct GNUNET_SCHEDULER_Task *cleanup_task; | |||
155 | /** | 155 | /** |
156 | * Claim to store | 156 | * Claim to store |
157 | */ | 157 | */ |
158 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 158 | struct GNUNET_RECLAIM_Attribute *claim; |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * Claim to delete | 161 | * Claim to delete |
@@ -165,7 +165,7 @@ static char *attr_delete; | |||
165 | /** | 165 | /** |
166 | * Claim object to delete | 166 | * Claim object to delete |
167 | */ | 167 | */ |
168 | static struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr_to_delete; | 168 | static struct GNUNET_RECLAIM_Attribute *attr_to_delete; |
169 | 169 | ||
170 | static void | 170 | static void |
171 | do_cleanup (void *cls) | 171 | do_cleanup (void *cls) |
@@ -226,9 +226,8 @@ store_attr_cont (void *cls, int32_t success, const char *emsg) | |||
226 | static void | 226 | static void |
227 | process_attrs (void *cls, | 227 | process_attrs (void *cls, |
228 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 228 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
229 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | 229 | const struct GNUNET_RECLAIM_Attribute *attr, |
230 | const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, | 230 | const struct GNUNET_RECLAIM_Attestation *attest) |
231 | const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference) | ||
232 | { | 231 | { |
233 | char *value_str; | 232 | char *value_str; |
234 | char *id; | 233 | char *id; |
@@ -245,18 +244,19 @@ process_attrs (void *cls, | |||
245 | ret = 1; | 244 | ret = 1; |
246 | return; | 245 | return; |
247 | } | 246 | } |
248 | value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, | 247 | value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type, |
249 | attr->data, | 248 | attr->data, |
250 | attr->data_size); | 249 | attr->data_size); |
251 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); | 250 | attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type); |
252 | id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); | 251 | id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); |
253 | fprintf (stdout, | 252 | fprintf (stdout, |
254 | "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", | 253 | "Name: %s; Value: %s (%s); Flag %u; ID: %s %s\n", |
255 | attr->name, | 254 | attr->name, |
256 | value_str, | 255 | value_str, |
257 | attr_type, | 256 | attr_type, |
258 | attr->flag, | 257 | attr->flag, |
259 | id); | 258 | id, |
259 | (NULL == attest) ? "" : "ATTESTED"); | ||
260 | GNUNET_free (id); | 260 | GNUNET_free (id); |
261 | } | 261 | } |
262 | 262 | ||
@@ -412,10 +412,10 @@ iter_finished (void *cls) | |||
412 | if (NULL == type_str) | 412 | if (NULL == type_str) |
413 | type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; | 413 | type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; |
414 | else | 414 | else |
415 | type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); | 415 | type = GNUNET_RECLAIM_attribute_typename_to_number (type_str); |
416 | 416 | ||
417 | GNUNET_assert (GNUNET_SYSERR != | 417 | GNUNET_assert (GNUNET_SYSERR != |
418 | GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type, | 418 | GNUNET_RECLAIM_attribute_string_to_value (type, |
419 | attr_value, | 419 | attr_value, |
420 | (void **) &data, | 420 | (void **) &data, |
421 | &data_size)); | 421 | &data_size)); |
@@ -428,7 +428,7 @@ iter_finished (void *cls) | |||
428 | else | 428 | else |
429 | { | 429 | { |
430 | claim = | 430 | claim = |
431 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size); | 431 | GNUNET_RECLAIM_attribute_new (attr_name, NULL, type, data, data_size); |
432 | } | 432 | } |
433 | reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, | 433 | reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, |
434 | pkey, | 434 | pkey, |
@@ -447,11 +447,10 @@ iter_finished (void *cls) | |||
447 | static void | 447 | static void |
448 | iter_cb (void *cls, | 448 | iter_cb (void *cls, |
449 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 449 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
450 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | 450 | const struct GNUNET_RECLAIM_Attribute *attr, |
451 | const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, | 451 | const struct GNUNET_RECLAIM_Attestation *attest) |
452 | const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference) | ||
453 | { | 452 | { |
454 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 453 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
455 | char *attrs_tmp; | 454 | char *attrs_tmp; |
456 | char *attr_str; | 455 | char *attr_str; |
457 | char *label; | 456 | char *label; |
@@ -462,10 +461,11 @@ iter_cb (void *cls, | |||
462 | { | 461 | { |
463 | if (0 == strcasecmp (attr_name, attr->name)) | 462 | if (0 == strcasecmp (attr_name, attr->name)) |
464 | { | 463 | { |
465 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, | 464 | claim = GNUNET_RECLAIM_attribute_new (attr->name, |
466 | attr->type, | 465 | &attr->attestation, |
467 | attr->data, | 466 | attr->type, |
468 | attr->data_size); | 467 | attr->data, |
468 | attr->data_size); | ||
469 | } | 469 | } |
470 | } | 470 | } |
471 | else if (issue_attrs) | 471 | else if (issue_attrs) |
@@ -479,13 +479,14 @@ iter_cb (void *cls, | |||
479 | attr_str = strtok (NULL, ","); | 479 | attr_str = strtok (NULL, ","); |
480 | continue; | 480 | continue; |
481 | } | 481 | } |
482 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); | 482 | le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); |
483 | le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, | 483 | le->attribute = GNUNET_RECLAIM_attribute_new (attr->name, |
484 | attr->type, | 484 | &attr->attestation, |
485 | attr->data, | 485 | attr->type, |
486 | attr->data_size); | 486 | attr->data, |
487 | le->claim->flag = attr->flag; | 487 | attr->data_size); |
488 | le->claim->id = attr->id; | 488 | le->attribute->flag = attr->flag; |
489 | le->attribute->id = attr->id; | ||
489 | GNUNET_CONTAINER_DLL_insert (attr_list->list_head, | 490 | GNUNET_CONTAINER_DLL_insert (attr_list->list_head, |
490 | attr_list->list_tail, | 491 | attr_list->list_tail, |
491 | le); | 492 | le); |
@@ -498,20 +499,21 @@ iter_cb (void *cls, | |||
498 | label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); | 499 | label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); |
499 | if (0 == strcasecmp (attr_delete, label)) | 500 | if (0 == strcasecmp (attr_delete, label)) |
500 | { | 501 | { |
501 | attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, | 502 | attr_to_delete = GNUNET_RECLAIM_attribute_new (attr->name, |
502 | attr->type, | 503 | &attr->attestation, |
503 | attr->data, | 504 | attr->type, |
504 | attr->data_size); | 505 | attr->data, |
506 | attr->data_size); | ||
505 | attr_to_delete->id = attr->id; | 507 | attr_to_delete->id = attr->id; |
506 | } | 508 | } |
507 | GNUNET_free (label); | 509 | GNUNET_free (label); |
508 | } | 510 | } |
509 | else if (list) | 511 | else if (list) |
510 | { | 512 | { |
511 | attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, | 513 | attr_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type, |
512 | attr->data, | 514 | attr->data, |
513 | attr->data_size); | 515 | attr->data_size); |
514 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); | 516 | attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type); |
515 | id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); | 517 | id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); |
516 | fprintf (stdout, | 518 | fprintf (stdout, |
517 | "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", | 519 | "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", |
@@ -568,7 +570,7 @@ start_process () | |||
568 | &ticket, | 570 | &ticket, |
569 | sizeof(struct GNUNET_RECLAIM_Ticket)); | 571 | sizeof(struct GNUNET_RECLAIM_Ticket)); |
570 | 572 | ||
571 | attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); | 573 | attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); |
572 | claim = NULL; | 574 | claim = NULL; |
573 | attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, | 575 | attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, |
574 | pkey, | 576 | pkey, |