diff options
author | Gabor X Toth <*@tg-x.net> | 2013-08-15 10:09:33 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2013-08-15 10:09:33 +0000 |
commit | 9b731d2b45c2ddc2ea24de7a0c87a672a6856f3a (patch) | |
tree | 70d1ad32b0500fb38af21e6916665c509090f269 /src/include | |
parent | 5e7b0418545ff38967a2d2edc0ebab8e8030f336 (diff) | |
download | gnunet-9b731d2b45c2ddc2ea24de7a0c87a672a6856f3a.tar.gz gnunet-9b731d2b45c2ddc2ea24de7a0c87a672a6856f3a.zip |
psycstore: added state_hash_update() and counters_get(); psyc: async state_get*(); multicast: membership test & replay params
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_env_lib.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_multicast_service.h | 37 | ||||
-rw-r--r-- | src/include/gnunet_psyc_service.h | 101 | ||||
-rw-r--r-- | src/include/gnunet_psycstore_service.h | 171 | ||||
-rw-r--r-- | src/include/gnunet_social_service.h | 4 |
5 files changed, 211 insertions, 104 deletions
diff --git a/src/include/gnunet_env_lib.h b/src/include/gnunet_env_lib.h index bde21eaac..e086882ed 100644 --- a/src/include/gnunet_env_lib.h +++ b/src/include/gnunet_env_lib.h | |||
@@ -40,8 +40,6 @@ enum GNUNET_ENV_Operator | |||
40 | * Assign value for a persistent state variable. | 40 | * Assign value for a persistent state variable. |
41 | * | 41 | * |
42 | * If an assigned value is NULL, the variable is deleted. | 42 | * If an assigned value is NULL, the variable is deleted. |
43 | * If the variable name that comes with thi operator is empty, | ||
44 | * it means a full state reset, the channel state is zeroed. | ||
45 | */ | 43 | */ |
46 | GNUNET_ENV_OP_ASSIGN = '=', | 44 | GNUNET_ENV_OP_ASSIGN = '=', |
47 | 45 | ||
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h index b4f9bc099..23d871a39 100644 --- a/src/include/gnunet_multicast_service.h +++ b/src/include/gnunet_multicast_service.h | |||
@@ -394,7 +394,7 @@ struct GNUNET_MULTICAST_MembershipTestHandle; | |||
394 | 394 | ||
395 | 395 | ||
396 | /** | 396 | /** |
397 | * Call informing multicast about the decision taken for membership test. | 397 | * Call informing multicast about the decision taken for a membership test. |
398 | * | 398 | * |
399 | * @param mth Handle that was given for the query. | 399 | * @param mth Handle that was given for the query. |
400 | * @param result #GNUNET_YES if peer was a member, #GNUNET_NO if peer was not a member, | 400 | * @param result #GNUNET_YES if peer was a member, #GNUNET_NO if peer was not a member, |
@@ -412,14 +412,18 @@ GNUNET_MULTICAST_membership_test_result (struct GNUNET_MULTICAST_MembershipTestH | |||
412 | * message can be replayed. | 412 | * message can be replayed. |
413 | * | 413 | * |
414 | * @param cls Closure. | 414 | * @param cls Closure. |
415 | * @param member_id Identity of the member that we want to test. | 415 | * @param member_key Identity of the member that we want to test. |
416 | * @param fragment_id Message fragment ID for which we want to do the test. | 416 | * @param message_id Message ID for which to perform the test. |
417 | * @param group_generation Group generation of the message. It has relevance if | ||
418 | * the message consists of multiple fragments with different group | ||
419 | * generations. | ||
417 | * @param mth Handle to give to GNUNET_MULTICAST_membership_test_answer(). | 420 | * @param mth Handle to give to GNUNET_MULTICAST_membership_test_answer(). |
418 | */ | 421 | */ |
419 | typedef void | 422 | typedef void |
420 | (*GNUNET_MULTICAST_MembershipTestCallback) (void *cls, | 423 | (*GNUNET_MULTICAST_MembershipTestCallback) (void *cls, |
421 | const struct GNUNET_CRYPTO_EccPublicKey *member_key, | 424 | const struct GNUNET_CRYPTO_EccPublicKey *member_key, |
422 | uint64_t fragment_id, | 425 | uint64_t message_id, |
426 | uint64_t group_generation, | ||
423 | struct GNUNET_MULTICAST_MembershipTestHandle *mth); | 427 | struct GNUNET_MULTICAST_MembershipTestHandle *mth); |
424 | 428 | ||
425 | 429 | ||
@@ -472,13 +476,17 @@ struct GNUNET_MULTICAST_ReplayHandle; | |||
472 | * group is left, the replay handle must no longer be used. | 476 | * group is left, the replay handle must no longer be used. |
473 | * | 477 | * |
474 | * @param cls Closure (set from GNUNET_MULTICAST_origin_start() | 478 | * @param cls Closure (set from GNUNET_MULTICAST_origin_start() |
475 | * or GNUNET_MULTICAST_member_join()). | 479 | * or GNUNET_MULTICAST_member_join()). |
476 | * @param fragment_id Which message fragment should be replayed. | 480 | * @param fragment_id Which message fragment should be replayed. |
481 | * @param message_id Which message should be replayed. | ||
482 | * @param flags Flags for the replay. | ||
477 | * @param rh Handle to pass to message transmit function. | 483 | * @param rh Handle to pass to message transmit function. |
478 | */ | 484 | */ |
479 | typedef void | 485 | typedef void |
480 | (*GNUNET_MULTICAST_ReplayCallback) (void *cls, | 486 | (*GNUNET_MULTICAST_ReplayCallback) (void *cls, |
481 | uint64_t fragment_id, | 487 | uint64_t fragment_id, |
488 | uint64_t message_id, | ||
489 | uint64_t flags, | ||
482 | struct GNUNET_MULTICAST_ReplayHandle *rh); | 490 | struct GNUNET_MULTICAST_ReplayHandle *rh); |
483 | 491 | ||
484 | 492 | ||
@@ -517,6 +525,9 @@ enum GNUNET_MULTICAST_ReplayErrorCode | |||
517 | /** | 525 | /** |
518 | * Replay a message from the multicast group. | 526 | * Replay a message from the multicast group. |
519 | * | 527 | * |
528 | * FIXME: use notify callbacks here too (or in a replay2() function), | ||
529 | * to be able to use the replay functionality for state sync as well. | ||
530 | * | ||
520 | * @param rh Replay handle identifying which replay operation was requested. | 531 | * @param rh Replay handle identifying which replay operation was requested. |
521 | * @param msg Replayed message fragment, NULL if unknown/error. | 532 | * @param msg Replayed message fragment, NULL if unknown/error. |
522 | * @param ec Error code. | 533 | * @param ec Error code. |
@@ -545,6 +556,9 @@ GNUNET_MULTICAST_replay (struct GNUNET_MULTICAST_ReplayHandle *rh, | |||
545 | * FIXME: we'll likely want to use NOT the p521 curve here, but a cheaper | 556 | * FIXME: we'll likely want to use NOT the p521 curve here, but a cheaper |
546 | * one in the future. | 557 | * one in the future. |
547 | * @param policy Group policy specifying join and history restrictions. | 558 | * @param policy Group policy specifying join and history restrictions. |
559 | * FIXME: needed? Ít would be enough to have this on the PSYC layer, as | ||
560 | * access control to enforce the policy is done by the membership test | ||
561 | * and join request callbacks of the API. | ||
548 | * @param last_fragment_id Last fragment ID to continue counting fragments from | 562 | * @param last_fragment_id Last fragment ID to continue counting fragments from |
549 | * when restarting the origin. 0 for a new group. | 563 | * when restarting the origin. 0 for a new group. |
550 | * @param join_cb Function called to approve / disapprove joining of a peer. | 564 | * @param join_cb Function called to approve / disapprove joining of a peer. |
@@ -689,14 +703,25 @@ struct GNUNET_MULTICAST_MemberReplayHandle; | |||
689 | * needed and not known to the client. | 703 | * needed and not known to the client. |
690 | * | 704 | * |
691 | * @param member Membership handle. | 705 | * @param member Membership handle. |
692 | * @param message_id ID of a message that this client would like to see replayed. | 706 | * @param fragment_id ID of a message fragment that this client would like to |
707 | see replayed. | ||
708 | * @param message_id ID of a message that this client would like to see | ||
709 | * replayed. Typically only one of the @a fragment_id and @a message_id | ||
710 | * is given. Specifying a @a message_id would return the last fragment | ||
711 | * of the message, which allows requesting the preceding fragments of the | ||
712 | * message by looking at the @e fragment_delta header field. | ||
713 | * @param flags Additional flags for the replay request. It is used & defined | ||
714 | * by the replay callback. E.g. the PSYC service would use this to | ||
715 | * implement state synchronization. | ||
693 | * @param message_cb Function to be called for the replayed message. | 716 | * @param message_cb Function to be called for the replayed message. |
694 | * @param message_cb_cls Closure for @a message_cb. | 717 | * @param message_cb_cls Closure for @a message_cb. |
695 | * @return Replay request handle, NULL on error. | 718 | * @return Replay request handle, NULL on error. |
696 | */ | 719 | */ |
697 | struct GNUNET_MULTICAST_MemberReplayHandle * | 720 | struct GNUNET_MULTICAST_MemberReplayHandle * |
698 | GNUNET_MULTICAST_member_request_replay (struct GNUNET_MULTICAST_Member *member, | 721 | GNUNET_MULTICAST_member_request_replay (struct GNUNET_MULTICAST_Member *member, |
722 | uint64_t fragment_id, | ||
699 | uint64_t message_id, | 723 | uint64_t message_id, |
724 | uint64_t flags, | ||
700 | GNUNET_MULTICAST_MessageCallback message_cb, | 725 | GNUNET_MULTICAST_MessageCallback message_cb, |
701 | void *message_cb_cls); | 726 | void *message_cb_cls); |
702 | 727 | ||
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index 5f48f7f34..273aa26f4 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h | |||
@@ -304,6 +304,11 @@ enum GNUNET_PSYC_MasterTransmitFlags | |||
304 | * transmitting this message. | 304 | * transmitting this message. |
305 | */ | 305 | */ |
306 | GNUNET_PSYC_MASTER_TRANSMIT_INC_GROUP_GEN = 1 << 1, | 306 | GNUNET_PSYC_MASTER_TRANSMIT_INC_GROUP_GEN = 1 << 1, |
307 | |||
308 | /** | ||
309 | * Add PSYC header variable with the hash of the current channel state. | ||
310 | */ | ||
311 | GNUNET_PSYC_MASTER_TRANSMIT_ADD_STATE_HASH = 1 << 2 | ||
307 | }; | 312 | }; |
308 | 313 | ||
309 | 314 | ||
@@ -564,9 +569,10 @@ GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *channel, | |||
564 | * Function called to inform a member about stored state values for a channel. | 569 | * Function called to inform a member about stored state values for a channel. |
565 | * | 570 | * |
566 | * @param cls Closure. | 571 | * @param cls Closure. |
567 | * @param name Name of the state variable. | 572 | * @param name Name of the state variable. A NULL value indicates that there |
568 | * @param value Value of the state variable. | 573 | * are no more state variables to be returned. |
569 | * @param value_size Number of bytes in @a value. | 574 | * @param value_size Number of bytes in @a value. |
575 | * @param value Value of the state variable. | ||
570 | */ | 576 | */ |
571 | typedef void | 577 | typedef void |
572 | (*GNUNET_PSYC_StateCallback) (void *cls, | 578 | (*GNUNET_PSYC_StateCallback) (void *cls, |
@@ -575,6 +581,15 @@ typedef void | |||
575 | const void *value); | 581 | const void *value); |
576 | 582 | ||
577 | 583 | ||
584 | /** | ||
585 | * Function called when a requested operation has finished. | ||
586 | * | ||
587 | * @param cls Closure. | ||
588 | */ | ||
589 | typedef void | ||
590 | (*GNUNET_PSYC_FinishCallback) (void *cls); | ||
591 | |||
592 | |||
578 | /** | 593 | /** |
579 | * Handle to a story telling operation. | 594 | * Handle to a story telling operation. |
580 | */ | 595 | */ |
@@ -593,14 +608,13 @@ struct GNUNET_PSYC_Story; | |||
593 | * @param start_message_id Earliest interesting point in history. | 608 | * @param start_message_id Earliest interesting point in history. |
594 | * @param end_message_id Last (exclusive) interesting point in history. | 609 | * @param end_message_id Last (exclusive) interesting point in history. |
595 | * @param method Function to invoke on messages received from the story. | 610 | * @param method Function to invoke on messages received from the story. |
596 | * @param method_cls Closure for @a method. | ||
597 | * @param finish_cb Function to call when the requested story has been fully | 611 | * @param finish_cb Function to call when the requested story has been fully |
598 | * told (counting message IDs might not suffice, as some messages | 612 | * told (counting message IDs might not suffice, as some messages |
599 | * might be secret and thus the listener would not know the story is | 613 | * might be secret and thus the listener would not know the story is |
600 | * finished without being told explicitly); once this function | 614 | * finished without being told explicitly); once this function |
601 | * has been called, the client must not call | 615 | * has been called, the client must not call |
602 | * GNUNET_PSYC_channel_story_tell_cancel() anymore. | 616 | * GNUNET_PSYC_channel_story_tell_cancel() anymore. |
603 | * @param finish_cb_cls Closure to finish_cb. | 617 | * @param cls Closure for the callbacks. |
604 | * @return Handle to cancel story telling operation. | 618 | * @return Handle to cancel story telling operation. |
605 | */ | 619 | */ |
606 | struct GNUNET_PSYC_Story * | 620 | struct GNUNET_PSYC_Story * |
@@ -608,9 +622,8 @@ GNUNET_PSYC_channel_story_tell (struct GNUNET_PSYC_Channel *channel, | |||
608 | uint64_t start_message_id, | 622 | uint64_t start_message_id, |
609 | uint64_t end_message_id, | 623 | uint64_t end_message_id, |
610 | GNUNET_PSYC_Method method, | 624 | GNUNET_PSYC_Method method, |
611 | void *method_cls, | 625 | GNUNET_PSYC_FinishCallback *finish_cb, |
612 | void (*finish_cb)(void *), | 626 | void *cls); |
613 | void *finish_cb_cls); | ||
614 | 627 | ||
615 | 628 | ||
616 | /** | 629 | /** |
@@ -624,57 +637,61 @@ GNUNET_PSYC_channel_story_tell (struct GNUNET_PSYC_Channel *channel, | |||
624 | void | 637 | void |
625 | GNUNET_PSYC_channel_story_tell_cancel (struct GNUNET_PSYC_Story *story); | 638 | GNUNET_PSYC_channel_story_tell_cancel (struct GNUNET_PSYC_Story *story); |
626 | 639 | ||
640 | struct GNUNET_PSYC_StateQuery; | ||
641 | |||
627 | 642 | ||
628 | /** | 643 | /** |
629 | * Call the given callback on all matching values (including variables) in the | 644 | * Return all channel state variables whose name matches a given prefix. |
630 | * channel state. | ||
631 | * | ||
632 | * The callback is invoked synchronously on all matching states (as the state is | ||
633 | * fully replicated in the library in this process; channel states should be | ||
634 | * small, large data is to be passed as streaming data to methods). | ||
635 | * | 645 | * |
636 | * A name matches if it includes the @a state_name prefix, thus requesting the | 646 | * A name matches if it starts with the given @a name_prefix, thus requesting the |
637 | * empty state ("") will match all values; requesting "_a_b" will also return | 647 | * empty prefix ("") will match all values; requesting "_a_b" will also return |
638 | * values stored under "_a_b_c". | 648 | * values stored under "_a_b_c". |
639 | * | 649 | * |
650 | * The @a state_cb is invoked on all matching state variables asynchronously, as | ||
651 | * the state is stored in and retrieved from the PSYCstore, | ||
652 | * | ||
640 | * @param channel Channel handle. | 653 | * @param channel Channel handle. |
641 | * @param state_name Name of the state to query (full name | 654 | * @param name_prefix Prefix of the state variable name to match. |
642 | * might be longer, this is only the prefix that must match). | 655 | * @param cb Function to call with the matching state variables. |
643 | * @param cb Function to call on the matching state values. | 656 | * @param cb_cls Closure for the callbacks. |
644 | * @param cb_cls Closure for @a cb. | 657 | * @return Handle that can be used to cancel the query operation. |
645 | * @return Message ID for which the state was returned (last seen | 658 | */ |
646 | * message ID). | 659 | struct GNUNET_PSYC_StateQuery * |
647 | */ | ||
648 | uint64_t | ||
649 | GNUNET_PSYC_channel_state_get_all (struct GNUNET_PSYC_Channel *channel, | 660 | GNUNET_PSYC_channel_state_get_all (struct GNUNET_PSYC_Channel *channel, |
650 | const char *state_name, | 661 | const char *name_prefix, |
651 | GNUNET_PSYC_StateCallback cb, | 662 | GNUNET_PSYC_StateCallback cb, |
652 | void *cb_cls); | 663 | void *cb_cls); |
653 | 664 | ||
654 | 665 | ||
655 | /** | 666 | /** |
656 | * Obtain the current value of the best-matching value in the state | 667 | * Retrieve the best matching channel state variable. |
657 | * (including variables). | ||
658 | * | ||
659 | * Note that variables are only valid during a #GNUNET_PSYC_Method invocation, as | ||
660 | * variables are only valid for the duration of a method invocation. | ||
661 | * | 668 | * |
662 | * If the requested variable name does not have an exact state in | 669 | * If the requested variable name is not present in the state, the nearest |
663 | * the state, the nearest less-specific name is matched; for example, | 670 | * less-specific name is matched; for example, requesting "_a_b" will match "_a" |
664 | * requesting "_a_b" will match "_a" if "_a_b" does not exist. | 671 | * if "_a_b" does not exist. |
665 | * | 672 | * |
666 | * @param channel Channel handle. | 673 | * @param channel Channel handle. |
667 | * @param variable_name Name of the variable to query. | 674 | * @param full_name Full name of the requested variable, the actual variable |
668 | * @param[out] return_value_size Set to number of bytes in variable, | 675 | * returned might have a shorter name.. |
669 | * needed as variables might contain binary data and | 676 | * @param cb Function called once when a matching state variable is found. |
670 | * might also not be 0-terminated; set to 0 on errors. | 677 | * Not called if there's no matching state variable. |
671 | * @return NULL on error (no matching state or variable), pointer | 678 | * @param cb_cls Closure for the callbacks. |
672 | * to the respective value otherwise. | 679 | * @return Handle that can be used to cancel the query operation. |
673 | */ | 680 | */ |
674 | const void * | 681 | struct GNUNET_PSYC_StateQuery * |
675 | GNUNET_PSYC_channel_state_get (struct GNUNET_PSYC_Channel *channel, | 682 | GNUNET_PSYC_channel_state_get (struct GNUNET_PSYC_Channel *channel, |
676 | const char *variable_name, | 683 | const char *full_name, |
677 | size_t *return_value_size); | 684 | GNUNET_PSYC_StateCallback cb, |
685 | void *cb_cls); | ||
686 | |||
687 | |||
688 | /** | ||
689 | * Cancel a state query operation. | ||
690 | * | ||
691 | * @param query Handle for the operation to cancel. | ||
692 | */ | ||
693 | void | ||
694 | GNUNET_PSYC_channel_state_get_cancel (struct GNUNET_PSYC_StateQuery *query); | ||
678 | 695 | ||
679 | 696 | ||
680 | #if 0 /* keep Emacsens' auto-indent happy */ | 697 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/include/gnunet_psycstore_service.h b/src/include/gnunet_psycstore_service.h index 5c79e2073..cd93c165f 100644 --- a/src/include/gnunet_psycstore_service.h +++ b/src/include/gnunet_psycstore_service.h | |||
@@ -76,14 +76,53 @@ struct GNUNET_PSYCSTORE_OperationHandle; | |||
76 | 76 | ||
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Callback used to return the latest value of counters of a channel. | ||
80 | * | ||
81 | * @see GNUNET_PSYCSTORE_counters_get() | ||
82 | * | ||
83 | * @param *cls Closure. | ||
84 | * @param fragment_id Latest message fragment ID, used by multicast. | ||
85 | * @param message_id Latest message ID, used by PSYC. | ||
86 | * @param group_generation Latest group generation, used by PSYC. | ||
87 | */ | ||
88 | typedef void | ||
89 | (*GNUNET_PSYCSTORE_CountersCallback) (void *cls, | ||
90 | uint64_t fragment_id, | ||
91 | uint64_t message_id, | ||
92 | uint64_t group_generation); | ||
93 | |||
94 | |||
95 | /** | ||
96 | * Retrieve latest values of counters for a channel. | ||
97 | * | ||
98 | * The current value of counters are needed when a channel master is restarted, | ||
99 | * so that it can continue incrementing the counters from their last value. | ||
100 | * | ||
101 | * @param h Handle for the PSYCstore. | ||
102 | * @param channel_key Public key that identifies the channel. | ||
103 | * @param cb Callback to call with the result. | ||
104 | * @param cb_cls Closure for the callback. | ||
105 | * | ||
106 | * @return | ||
107 | */ | ||
108 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
109 | GNUNET_PSYCSTORE_counters_get (struct GNUNET_PSYCSTORE_Handle *h, | ||
110 | GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
111 | GNUNET_PSYCSTORE_CountersCallback *cb, | ||
112 | void *cb_cls); | ||
113 | |||
114 | |||
115 | /** | ||
79 | * Function called with the result of an asynchronous operation. | 116 | * Function called with the result of an asynchronous operation. |
80 | * | 117 | * |
81 | * @param result #GNUNET_SYSERR on error, | 118 | * @param result #GNUNET_SYSERR on error, |
82 | * #GNUNET_YES on success or if the peer was a member, | 119 | * #GNUNET_YES on success or if the peer was a member, |
83 | * #GNUNET_NO if the peer was not a member | 120 | * #GNUNET_NO if the peer was not a member |
84 | */ | 121 | */ |
85 | typedef void (*GNUNET_PSYCSTORE_ResultCallback)(void *cls, | 122 | typedef void |
86 | int result); | 123 | (*GNUNET_PSYCSTORE_ResultCallback) (void *cls, |
124 | int result); | ||
125 | |||
87 | 126 | ||
88 | /** | 127 | /** |
89 | * Store join/leave events for a PSYC channel in order to be able to answer | 128 | * Store join/leave events for a PSYC channel in order to be able to answer |
@@ -92,9 +131,12 @@ typedef void (*GNUNET_PSYCSTORE_ResultCallback)(void *cls, | |||
92 | * @param h Handle for the PSYCstore. | 131 | * @param h Handle for the PSYCstore. |
93 | * @param channel_key The channel where the event happened. | 132 | * @param channel_key The channel where the event happened. |
94 | * @param slave_key Public key of joining/leaving slave. | 133 | * @param slave_key Public key of joining/leaving slave. |
134 | * @param did_join #GNUNET_YES on join, #GNUNET_NO on part. | ||
95 | * @param announced_at ID of the message that announced the membership change. | 135 | * @param announced_at ID of the message that announced the membership change. |
96 | * @param effective_since Message ID this membership change is in effect since. | 136 | * @param effective_since Message ID this membership change is in effect since. |
97 | * @param did_join #GNUNET_YES on join, #GNUNET_NO on part. | 137 | * @param group_generation In case of a part, the last group generation the |
138 | * slave has access to. It has relevance when a larger message have | ||
139 | * fragments with different group generations. | ||
98 | * @param rcb Callback to call with the result of the storage operation. | 140 | * @param rcb Callback to call with the result of the storage operation. |
99 | * @param rcb_cls Closure for the callback. | 141 | * @param rcb_cls Closure for the callback. |
100 | * | 142 | * |
@@ -104,24 +146,26 @@ struct GNUNET_PSYCSTORE_OperationHandle * | |||
104 | GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, | 146 | GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, |
105 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | 147 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, |
106 | const struct GNUNET_CRYPTO_EccPublicKey *slave_key, | 148 | const struct GNUNET_CRYPTO_EccPublicKey *slave_key, |
149 | int did_join, | ||
107 | uint64_t announced_at, | 150 | uint64_t announced_at, |
108 | uint64_t effective_since, | 151 | uint64_t effective_since, |
109 | int did_join, | 152 | uint64_t group_generation, |
110 | GNUNET_PSYCSTORE_ResultCallback rcb, | 153 | GNUNET_PSYCSTORE_ResultCallback rcb, |
111 | void *rcb_cls); | 154 | void *rcb_cls); |
112 | 155 | ||
113 | 156 | ||
114 | /** | 157 | /** |
115 | * Test if a peer was a member of the channel when the message fragment with the | 158 | * Test if a peer was a member of the channel during the given period specified by the group generation. |
116 | * specified ID was sent to the channel. | ||
117 | * | 159 | * |
118 | * This is useful in case of retransmissions to check if the peer was authorized | 160 | * This is useful when relaying and replaying messages to check if a particular slave has access to the message fragment with a given group generation. It is also used when handling join requests to determine whether the slave is currently admitted to the channel. |
119 | * to see the requested message. | ||
120 | * | 161 | * |
121 | * @param h Handle for the PSYCstore. | 162 | * @param h Handle for the PSYCstore. |
122 | * @param channel_key The channel we are interested in. | 163 | * @param channel_key The channel we are interested in. |
123 | * @param slave_key Public key of slave whose membership to check. | 164 | * @param slave_key Public key of slave whose membership to check. |
124 | * @param fragment_id Message fragment ID to check. | 165 | * @param message_id Message ID for which to do the membership test. |
166 | * @param group_generation Group generation of the fragment of the message to | ||
167 | * test. It has relevance if the message consists of multiple fragments | ||
168 | * with different group generations. | ||
125 | * @param rcb Callback to call with the test result. | 169 | * @param rcb Callback to call with the test result. |
126 | * @param rcb_cls Closure for the callback. | 170 | * @param rcb_cls Closure for the callback. |
127 | * | 171 | * |
@@ -131,7 +175,8 @@ struct GNUNET_PSYCSTORE_OperationHandle * | |||
131 | GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, | 175 | GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, |
132 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | 176 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, |
133 | const struct GNUNET_CRYPTO_EccPublicKey *slave_key, | 177 | const struct GNUNET_CRYPTO_EccPublicKey *slave_key, |
134 | uint64_t fragment_id, | 178 | uint64_t message_id, |
179 | uint64_t group_generation, | ||
135 | GNUNET_PSYCSTORE_ResultCallback rcb, | 180 | GNUNET_PSYCSTORE_ResultCallback rcb, |
136 | void *rcb_cls); | 181 | void *rcb_cls); |
137 | 182 | ||
@@ -160,12 +205,14 @@ GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h, | |||
160 | * GNUNET_PSYCSTORE_fragment_get() or GNUNET_PSYCSTORE_message_get() call. | 205 | * GNUNET_PSYCSTORE_fragment_get() or GNUNET_PSYCSTORE_message_get() call. |
161 | * | 206 | * |
162 | * @param cls Closure. | 207 | * @param cls Closure. |
163 | * @param message The retrieved message fragment. | 208 | * @param message The retrieved message fragment. A NULL value indicates that |
209 | * there are no more results to be returned. | ||
164 | * @param flags Message flags indicating fragmentation status. | 210 | * @param flags Message flags indicating fragmentation status. |
165 | */ | 211 | */ |
166 | typedef void (*GNUNET_PSYCSTORE_FragmentResultCallback)(void *cls, | 212 | typedef void |
167 | const struct GNUNET_MULTICAST_MessageHeader *message, | 213 | (*GNUNET_PSYCSTORE_FragmentCallback) (void *cls, |
168 | enum GNUNET_PSYC_MessageFlags flags); | 214 | const struct GNUNET_MULTICAST_MessageHeader *message, |
215 | enum GNUNET_PSYC_MessageFlags flags); | ||
169 | 216 | ||
170 | 217 | ||
171 | /** | 218 | /** |
@@ -174,8 +221,8 @@ typedef void (*GNUNET_PSYCSTORE_FragmentResultCallback)(void *cls, | |||
174 | * @param h Handle for the PSYCstore. | 221 | * @param h Handle for the PSYCstore. |
175 | * @param channel_key The channel we are interested in. | 222 | * @param channel_key The channel we are interested in. |
176 | * @param fragment_id Fragment ID to check. Use 0 to get the latest message fragment. | 223 | * @param fragment_id Fragment ID to check. Use 0 to get the latest message fragment. |
177 | * @param rcb Callback to call with the result of the operation. | 224 | * @param cb Callback to call with the retrieved fragment. |
178 | * @param rcb_cls Closure for the callback. | 225 | * @param cb_cls Closure for the callback. |
179 | * | 226 | * |
180 | * @return Handle that can be used to cancel the operation. | 227 | * @return Handle that can be used to cancel the operation. |
181 | */ | 228 | */ |
@@ -183,8 +230,8 @@ struct GNUNET_PSYCSTORE_OperationHandle * | |||
183 | GNUNET_PSYCSTORE_fragment_get (struct GNUNET_PSYCSTORE_Handle *h, | 230 | GNUNET_PSYCSTORE_fragment_get (struct GNUNET_PSYCSTORE_Handle *h, |
184 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | 231 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, |
185 | uint64_t fragment_id, | 232 | uint64_t fragment_id, |
186 | GNUNET_PSYCSTORE_FragmentResultCallback rcb, | 233 | GNUNET_PSYCSTORE_FragmentCallback cb, |
187 | void *rcb_cls); | 234 | void *cb_cls); |
188 | 235 | ||
189 | 236 | ||
190 | /** | 237 | /** |
@@ -193,8 +240,8 @@ GNUNET_PSYCSTORE_fragment_get (struct GNUNET_PSYCSTORE_Handle *h, | |||
193 | * @param h Handle for the PSYCstore. | 240 | * @param h Handle for the PSYCstore. |
194 | * @param channel_key The channel we are interested in. | 241 | * @param channel_key The channel we are interested in. |
195 | * @param message_id Message ID to check. Use 0 to get the latest message. | 242 | * @param message_id Message ID to check. Use 0 to get the latest message. |
196 | * @param rcb Callback to call with the result of the operation. | 243 | * @param cb Callback to call with the retrieved fragments. |
197 | * @param rcb_cls Closure for the callback. | 244 | * @param cb_cls Closure for the callback. |
198 | * | 245 | * |
199 | * @return Handle that can be used to cancel the operation. | 246 | * @return Handle that can be used to cancel the operation. |
200 | */ | 247 | */ |
@@ -202,25 +249,22 @@ struct GNUNET_PSYCSTORE_OperationHandle * | |||
202 | GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h, | 249 | GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h, |
203 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | 250 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, |
204 | uint64_t message_id, | 251 | uint64_t message_id, |
205 | GNUNET_PSYCSTORE_FragmentResultCallback rcb, | 252 | GNUNET_PSYCSTORE_FragmentCallback cb, |
206 | void *rcb_cls); | 253 | void *cb_cls); |
207 | 254 | ||
208 | 255 | ||
209 | /** | 256 | /** |
210 | * Modify the channel state. | 257 | * Apply modifiers of a message to the current channel state. |
211 | * | ||
212 | * Applies the operation to the current channel state. | ||
213 | * | 258 | * |
214 | * An error is returned if there are missing messages containing state | 259 | * An error is returned if there are missing messages containing state |
215 | * operations before the current one. | 260 | * operations before the current one. |
216 | * | 261 | * |
217 | * @param h Handle for the PSYCstore. | 262 | * @param h Handle for the PSYCstore. |
218 | * @param channel_key The channel we are interested in. | 263 | * @param channel_key The channel we are interested in. |
219 | * @param message_id ID of the message that contains this state modifier. | 264 | * @param message_id ID of the message that contains the @a modifiers. |
220 | * @param oper Operation to perform. | 265 | * @param state_delta Value of the _state_delta PSYC header variable of the message. |
221 | * @param name Name of variable. | 266 | * @param modifier_count Number of elements in the @a modifiers array. |
222 | * @param value_size Size of @a value. | 267 | * @param modifiers List of modifiers to apply. |
223 | * @param value Value of variable. | ||
224 | * @param rcb Callback to call with the result of the operation. | 268 | * @param rcb Callback to call with the result of the operation. |
225 | * @param rcb_cls Closure for the callback. | 269 | * @param rcb_cls Closure for the callback. |
226 | * | 270 | * |
@@ -230,37 +274,58 @@ struct GNUNET_PSYCSTORE_OperationHandle * | |||
230 | GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h, | 274 | GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h, |
231 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | 275 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, |
232 | uint64_t message_id, | 276 | uint64_t message_id, |
233 | enum GNUNET_ENV_Operator *oper, | 277 | uint64_t state_delta, |
234 | const char *name, | 278 | size_t modifier_count, |
235 | size_t value_size, | 279 | const struct GNUNET_ENV_Modifier *modifiers, |
236 | const void *value, | ||
237 | GNUNET_PSYCSTORE_ResultCallback rcb, | 280 | GNUNET_PSYCSTORE_ResultCallback rcb, |
238 | void *rcb_cls); | 281 | void *rcb_cls); |
239 | 282 | ||
240 | 283 | ||
241 | /** | 284 | /** |
285 | * Update signed values of state variables in the state store. | ||
286 | * | ||
287 | * @param h Handle for the PSYCstore. | ||
288 | * @param channel_key The channel we are interested in. | ||
289 | * @param message_id Message ID that contained the state @a hash. | ||
290 | * @param hash Hash of the serialized full state. | ||
291 | * @param rcb Callback to call with the result of the operation. | ||
292 | * @param rcb_cls Closure for the callback. | ||
293 | * | ||
294 | */ | ||
295 | struct GNUNET_PSYCSTORE_OperationHandle * | ||
296 | GNUNET_PSYCSTORE_state_hash_update (struct GNUNET_PSYCSTORE_Handle *h, | ||
297 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
298 | uint64_t message_id, | ||
299 | const struct GNUNET_HashCode *hash, | ||
300 | GNUNET_PSYCSTORE_ResultCallback rcb, | ||
301 | void *rcb_cls); | ||
302 | |||
303 | |||
304 | /** | ||
242 | * Function called with the value of a state variable. | 305 | * Function called with the value of a state variable. |
243 | * | 306 | * |
244 | * @param cls Closure. | 307 | * @param cls Closure. |
245 | * @param name Name of variable. | 308 | * @param name Name of the state variable. A NULL value indicates that there are no more |
246 | * @param size Size of @a value. | 309 | * state variables to be returned. |
247 | * @param value Value of variable. | 310 | * @param value_size Number of bytes in @a value. |
311 | * @param value Value of the state variable. | ||
248 | t * | 312 | t * |
249 | */ | 313 | */ |
250 | typedef void (*GNUNET_PSYCSTORE_StateResultCallback)(void *cls, | 314 | typedef void |
251 | const char *name, | 315 | (*GNUNET_PSYCSTORE_StateCallback) (void *cls, |
252 | size_t size, | 316 | const char *name, |
253 | const void *value); | 317 | size_t value_size, |
318 | const void *value); | ||
254 | 319 | ||
255 | 320 | ||
256 | /** | 321 | /** |
257 | * Retrieve the given state variable for a channel. | 322 | * Retrieve the best matching state variable. |
258 | * | 323 | * |
259 | * @param h Handle for the PSYCstore. | 324 | * @param h Handle for the PSYCstore. |
260 | * @param channel_key The channel we are interested in. | 325 | * @param channel_key The channel we are interested in. |
261 | * @param name Name of variable to get. | 326 | * @param name Name of variable to match, the returned variable might be less specific. |
262 | * @param rcb Callback to call with the result. | 327 | * @param cb Callback to return matching state variables. |
263 | * @param rcb_cls Closure for the callback. | 328 | * @param cb_cls Closure for the callback. |
264 | * | 329 | * |
265 | * @return Handle that can be used to cancel the operation. | 330 | * @return Handle that can be used to cancel the operation. |
266 | */ | 331 | */ |
@@ -268,25 +333,27 @@ struct GNUNET_PSYCSTORE_OperationHandle * | |||
268 | GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h, | 333 | GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h, |
269 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | 334 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, |
270 | const char *name, | 335 | const char *name, |
271 | GNUNET_PSYCSTORE_StateResultCallback rcb, | 336 | GNUNET_PSYCSTORE_StateCallback cb, |
272 | void *rcb_cls); | 337 | void *cb_cls); |
273 | 338 | ||
274 | 339 | ||
275 | /** | 340 | /** |
276 | * Retrieve all state variables for a channel. | 341 | * Retrieve all state variables for a channel with the given prefix. |
277 | * | 342 | * |
278 | * @param h Handle for the PSYCstore. | 343 | * @param h Handle for the PSYCstore. |
279 | * @param channel_key The channel we are interested in. | 344 | * @param channel_key The channel we are interested in. |
280 | * @param rcb Callback to call with the result. | 345 | * @param name_prefix Prefix of state variable names to match. |
281 | * @param rcb_cls Closure for the callback. | 346 | * @param cb Callback to return matching state variables. |
347 | * @param cb_cls Closure for the callback. | ||
282 | * | 348 | * |
283 | * @return Handle that can be used to cancel the operation. | 349 | * @return Handle that can be used to cancel the operation. |
284 | */ | 350 | */ |
285 | struct GNUNET_PSYCSTORE_OperationHandle * | 351 | struct GNUNET_PSYCSTORE_OperationHandle * |
286 | GNUNET_PSYCSTORE_state_get_all (struct GNUNET_PSYCSTORE_Handle *h, | 352 | GNUNET_PSYCSTORE_state_get_all (struct GNUNET_PSYCSTORE_Handle *h, |
287 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | 353 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, |
288 | GNUNET_PSYCSTORE_StateResultCallback rcb, | 354 | const char *name_prefix, |
289 | void *rcb_cls); | 355 | GNUNET_PSYCSTORE_StateCallback cb, |
356 | void *cb_cls); | ||
290 | 357 | ||
291 | 358 | ||
292 | /** | 359 | /** |
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h index 4ac1965d6..a71272327 100644 --- a/src/include/gnunet_social_service.h +++ b/src/include/gnunet_social_service.h | |||
@@ -300,7 +300,7 @@ GNUNET_SOCIAL_home_reject_entry (struct GNUNET_SOCIAL_Home *home, | |||
300 | * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name(). | 300 | * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name(). |
301 | * | 301 | * |
302 | * @param nym Pseudonym to map to a cryptographic identifier. | 302 | * @param nym Pseudonym to map to a cryptographic identifier. |
303 | * @param[out] identity Set to the public key of the nym. | 303 | * @param[out] nym_key Set to the public key of the nym. |
304 | */ | 304 | */ |
305 | void | 305 | void |
306 | GNUNET_SOCIAL_nym_get_key (struct GNUNET_SOCIAL_Nym *nym, | 306 | GNUNET_SOCIAL_nym_get_key (struct GNUNET_SOCIAL_Nym *nym, |
@@ -342,7 +342,7 @@ enum GNUNET_PSYC_AnnouncementFlags | |||
342 | * New objects can be still added to the now empty home using the @e env | 342 | * New objects can be still added to the now empty home using the @e env |
343 | * parameter of the same announcement. | 343 | * parameter of the same announcement. |
344 | */ | 344 | */ |
345 | GNUNET_SOCIAL_ANNOUNCEMENT_CLEAR_OBJECTS = 1 << 0, | 345 | GNUNET_SOCIAL_ANNOUNCEMENT_CLEAR_OBJECTS = 1 << 0 |
346 | }; | 346 | }; |
347 | 347 | ||
348 | 348 | ||