diff options
-rw-r--r-- | src/reclaim/gnunet-reclaim.c | 46 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 2 |
2 files changed, 38 insertions, 10 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index f56425b17..02138cfff 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -139,6 +139,11 @@ static struct GNUNET_SCHEDULER_Task *timeout; | |||
139 | */ | 139 | */ |
140 | static struct GNUNET_SCHEDULER_Task *cleanup_task; | 140 | static struct GNUNET_SCHEDULER_Task *cleanup_task; |
141 | 141 | ||
142 | /** | ||
143 | * Claim to store | ||
144 | */ | ||
145 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | ||
146 | |||
142 | static void | 147 | static void |
143 | do_cleanup(void *cls) | 148 | do_cleanup(void *cls) |
144 | { | 149 | { |
@@ -249,7 +254,6 @@ process_rvk (void *cls, int success, const char* msg) | |||
249 | static void | 254 | static void |
250 | iter_finished (void *cls) | 255 | iter_finished (void *cls) |
251 | { | 256 | { |
252 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | ||
253 | char *data; | 257 | char *data; |
254 | size_t data_size; | 258 | size_t data_size; |
255 | int type; | 259 | int type; |
@@ -303,16 +307,25 @@ iter_finished (void *cls) | |||
303 | attr_value, | 307 | attr_value, |
304 | (void**)&data, | 308 | (void**)&data, |
305 | &data_size)); | 309 | &data_size)); |
306 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, | 310 | if (NULL != claim) |
307 | type, | 311 | { |
308 | data, | 312 | claim->type = type; |
309 | data_size); | 313 | claim->data = data; |
314 | claim->data_size = data_size; | ||
315 | } else { | ||
316 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, | ||
317 | type, | ||
318 | data, | ||
319 | data_size); | ||
320 | } | ||
310 | reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, | 321 | reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, |
311 | pkey, | 322 | pkey, |
312 | claim, | 323 | claim, |
313 | &exp_interval, | 324 | &exp_interval, |
314 | &store_attr_cont, | 325 | &store_attr_cont, |
315 | NULL); | 326 | NULL); |
327 | GNUNET_free (data); | ||
328 | GNUNET_free (claim); | ||
316 | return; | 329 | return; |
317 | } | 330 | } |
318 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 331 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
@@ -326,8 +339,19 @@ iter_cb (void *cls, | |||
326 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 339 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
327 | char *attrs_tmp; | 340 | char *attrs_tmp; |
328 | char *attr_str; | 341 | char *attr_str; |
342 | const char *attr_type; | ||
329 | 343 | ||
330 | if (issue_attrs) | 344 | if ((NULL != attr_name) && (NULL != claim)) |
345 | { | ||
346 | if (0 == strcasecmp (attr_name, attr->name)) | ||
347 | { | ||
348 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, | ||
349 | attr->type, | ||
350 | attr->data, | ||
351 | attr->data_size); | ||
352 | } | ||
353 | } | ||
354 | else if (issue_attrs) | ||
331 | { | 355 | { |
332 | attrs_tmp = GNUNET_strdup (issue_attrs); | 356 | attrs_tmp = GNUNET_strdup (issue_attrs); |
333 | attr_str = strtok (attrs_tmp, ","); | 357 | attr_str = strtok (attrs_tmp, ","); |
@@ -351,8 +375,9 @@ iter_cb (void *cls, | |||
351 | attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, | 375 | attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, |
352 | attr->data, | 376 | attr->data, |
353 | attr->data_size); | 377 | attr->data_size); |
354 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 378 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); |
355 | "%s: %s\n", attr->name, attr_str); | 379 | fprintf (stdout, |
380 | "%s\t%s\t%u\t%s\n", attr->name, attr_type, attr->version, attr_str); | ||
356 | } | 381 | } |
357 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); | 382 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); |
358 | } | 383 | } |
@@ -383,9 +408,12 @@ start_get_attributes () | |||
383 | &ticket, | 408 | &ticket, |
384 | sizeof (struct GNUNET_RECLAIM_Ticket)); | 409 | sizeof (struct GNUNET_RECLAIM_Ticket)); |
385 | 410 | ||
411 | if (list) | ||
412 | fprintf (stdout, | ||
413 | "Name\tType\tVersion\tValue\n"); | ||
386 | 414 | ||
387 | attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); | 415 | attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
388 | 416 | claim = NULL; | |
389 | attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, | 417 | attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, |
390 | pkey, | 418 | pkey, |
391 | &iter_error, | 419 | &iter_error, |
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index bf8780a92..3321a79d8 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -1439,9 +1439,9 @@ check_attr_cb (void *cls, | |||
1439 | 1439 | ||
1440 | buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (rh->attrs->list_head->claim); | 1440 | buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (rh->attrs->list_head->claim); |
1441 | buf = GNUNET_malloc (buf_size); | 1441 | buf = GNUNET_malloc (buf_size); |
1442 | rh->attrs->list_head->claim->version++; | ||
1442 | GNUNET_RECLAIM_ATTRIBUTE_serialize (rh->attrs->list_head->claim, | 1443 | GNUNET_RECLAIM_ATTRIBUTE_serialize (rh->attrs->list_head->claim, |
1443 | buf); | 1444 | buf); |
1444 | rh->attrs->list_head->claim->version++; | ||
1445 | GNUNET_asprintf (&policy, "%s_%lu", | 1445 | GNUNET_asprintf (&policy, "%s_%lu", |
1446 | rh->attrs->list_head->claim->name, | 1446 | rh->attrs->list_head->claim->name, |
1447 | rh->attrs->list_head->claim->version); | 1447 | rh->attrs->list_head->claim->version); |