diff options
author | Gabor X Toth <*@tg-x.net> | 2014-07-27 11:35:43 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2014-07-27 11:35:43 +0000 |
commit | 1ac8baae5380d8f83efb31390568b717e871823a (patch) | |
tree | dc363148002cba0f94d9e2c9a6f3b2576bb39793 /src/psycstore/test_psycstore.c | |
parent | 0ea6bab62cd1d29e32c5d442d865e1b6bf82bef1 (diff) | |
download | gnunet-1ac8baae5380d8f83efb31390568b717e871823a.tar.gz gnunet-1ac8baae5380d8f83efb31390568b717e871823a.zip |
psycstore: add option to perform membership test when retrieving fragment or message
Diffstat (limited to 'src/psycstore/test_psycstore.c')
-rw-r--r-- | src/psycstore/test_psycstore.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/psycstore/test_psycstore.c b/src/psycstore/test_psycstore.c index 8ecc7a96f..3ef2439e3 100644 --- a/src/psycstore/test_psycstore.c +++ b/src/psycstore/test_psycstore.c | |||
@@ -331,7 +331,6 @@ message_get_result (void *cls, int64_t result, const char *err_msg) | |||
331 | GNUNET_assert (result > 0 && fcls->n && fcls->n_expected); | 331 | GNUNET_assert (result > 0 && fcls->n && fcls->n_expected); |
332 | 332 | ||
333 | 333 | ||
334 | |||
335 | modifiers[0] = (struct GNUNET_ENV_Modifier) { | 334 | modifiers[0] = (struct GNUNET_ENV_Modifier) { |
336 | .oper = '=', | 335 | .oper = '=', |
337 | .name = "_sync_foo", | 336 | .name = "_sync_foo", |
@@ -361,7 +360,7 @@ message_get_fragment_result (void *cls, int64_t result, const char *err_msg) | |||
361 | 360 | ||
362 | fcls->n = 0; | 361 | fcls->n = 0; |
363 | fcls->n_expected = 3; | 362 | fcls->n_expected = 3; |
364 | op = GNUNET_PSYCSTORE_message_get (h, &channel_pub_key, | 363 | op = GNUNET_PSYCSTORE_message_get (h, &channel_pub_key, &slave_pub_key, |
365 | GNUNET_ntohll (fcls->msg[0]->message_id), | 364 | GNUNET_ntohll (fcls->msg[0]->message_id), |
366 | &fragment_result, | 365 | &fragment_result, |
367 | &message_get_result, fcls); | 366 | &message_get_result, fcls); |
@@ -378,7 +377,7 @@ fragment_get_result (void *cls, int64_t result, const char *err_msg) | |||
378 | 377 | ||
379 | fcls->n = 1; | 378 | fcls->n = 1; |
380 | fcls->n_expected = 2; | 379 | fcls->n_expected = 2; |
381 | op = GNUNET_PSYCSTORE_message_get_fragment (h, &channel_pub_key, | 380 | op = GNUNET_PSYCSTORE_message_get_fragment (h, &channel_pub_key, &slave_pub_key, |
382 | GNUNET_ntohll (fcls->msg[1]->message_id), | 381 | GNUNET_ntohll (fcls->msg[1]->message_id), |
383 | GNUNET_ntohll (fcls->msg[1]->fragment_offset), | 382 | GNUNET_ntohll (fcls->msg[1]->fragment_offset), |
384 | &fragment_result, | 383 | &fragment_result, |
@@ -396,10 +395,10 @@ fragment_store_result (void *cls, int64_t result, const char *err_msg) | |||
396 | GNUNET_assert (GNUNET_OK == result); | 395 | GNUNET_assert (GNUNET_OK == result); |
397 | 396 | ||
398 | if ((intptr_t) cls == GNUNET_YES) | 397 | if ((intptr_t) cls == GNUNET_YES) |
399 | { | 398 | { /* last fragment */ |
400 | fcls.n = 0; | 399 | fcls.n = 0; |
401 | fcls.n_expected = 1; | 400 | fcls.n_expected = 1; |
402 | op = GNUNET_PSYCSTORE_fragment_get (h, &channel_pub_key, | 401 | op = GNUNET_PSYCSTORE_fragment_get (h, &channel_pub_key, &slave_pub_key, |
403 | GNUNET_ntohll (fcls.msg[0]->fragment_id), | 402 | GNUNET_ntohll (fcls.msg[0]->fragment_id), |
404 | &fragment_result, | 403 | &fragment_result, |
405 | &fragment_get_result, &fcls); | 404 | &fragment_get_result, &fcls); |
@@ -408,12 +407,8 @@ fragment_store_result (void *cls, int64_t result, const char *err_msg) | |||
408 | 407 | ||
409 | 408 | ||
410 | void | 409 | void |
411 | membership_test_result (void *cls, int64_t result, const char *err_msg) | 410 | fragment_store () |
412 | { | 411 | { |
413 | op = NULL; | ||
414 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "membership_test:\t%d\n", result); | ||
415 | GNUNET_assert (GNUNET_OK == result); | ||
416 | |||
417 | struct GNUNET_MULTICAST_MessageHeader *msg; | 412 | struct GNUNET_MULTICAST_MessageHeader *msg; |
418 | fcls.flags[0] = GNUNET_PSYCSTORE_MESSAGE_STATE; | 413 | fcls.flags[0] = GNUNET_PSYCSTORE_MESSAGE_STATE; |
419 | fcls.msg[0] = msg = GNUNET_malloc (sizeof (*msg) + sizeof (channel_pub_key)); | 414 | fcls.msg[0] = msg = GNUNET_malloc (sizeof (*msg) + sizeof (channel_pub_key)); |
@@ -461,6 +456,18 @@ membership_test_result (void *cls, int64_t result, const char *err_msg) | |||
461 | &fragment_store_result, (void *) GNUNET_YES); | 456 | &fragment_store_result, (void *) GNUNET_YES); |
462 | } | 457 | } |
463 | 458 | ||
459 | |||
460 | void | ||
461 | membership_test_result (void *cls, int64_t result, const char *err_msg) | ||
462 | { | ||
463 | op = NULL; | ||
464 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "membership_test:\t%d\n", result); | ||
465 | GNUNET_assert (GNUNET_OK == result); | ||
466 | |||
467 | fragment_store (); | ||
468 | } | ||
469 | |||
470 | |||
464 | void | 471 | void |
465 | membership_store_result (void *cls, int64_t result, const char *err_msg) | 472 | membership_store_result (void *cls, int64_t result, const char *err_msg) |
466 | { | 473 | { |
@@ -469,7 +476,7 @@ membership_store_result (void *cls, int64_t result, const char *err_msg) | |||
469 | GNUNET_assert (GNUNET_OK == result); | 476 | GNUNET_assert (GNUNET_OK == result); |
470 | 477 | ||
471 | op = GNUNET_PSYCSTORE_membership_test (h, &channel_pub_key, &slave_pub_key, | 478 | op = GNUNET_PSYCSTORE_membership_test (h, &channel_pub_key, &slave_pub_key, |
472 | 4, 1, | 479 | INT64_MAX - 10, 2, |
473 | &membership_test_result, NULL); | 480 | &membership_test_result, NULL); |
474 | } | 481 | } |
475 | 482 | ||
@@ -502,7 +509,8 @@ run (void *cls, | |||
502 | GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key); | 509 | GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key); |
503 | 510 | ||
504 | op = GNUNET_PSYCSTORE_membership_store (h, &channel_pub_key, &slave_pub_key, | 511 | op = GNUNET_PSYCSTORE_membership_store (h, &channel_pub_key, &slave_pub_key, |
505 | GNUNET_YES, 4, 2, 1, | 512 | GNUNET_YES, INT64_MAX - 5, |
513 | INT64_MAX - 10, 2, | ||
506 | &membership_store_result, NULL); | 514 | &membership_store_result, NULL); |
507 | } | 515 | } |
508 | 516 | ||