diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-02-27 01:18:54 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-02-27 01:19:18 +0100 |
commit | 6da407ad72fdca282094ccdb5558ece9638e3bd3 (patch) | |
tree | 9b93ef7431143588be591e97f2bb0409ff4493ef /src/consensus/gnunet-service-consensus.c | |
parent | 3112e64ef06f71b06e9f047f2c6dd1be0941a565 (diff) | |
download | gnunet-6da407ad72fdca282094ccdb5558ece9638e3bd3.tar.gz gnunet-6da407ad72fdca282094ccdb5558ece9638e3bd3.zip |
include set size in result callback, needed by consensus
Diffstat (limited to 'src/consensus/gnunet-service-consensus.c')
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index 9d5d35c94..44b6dc21b 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c | |||
@@ -141,6 +141,7 @@ GNUNET_NETWORK_STRUCT_END | |||
141 | enum PhaseKind | 141 | enum PhaseKind |
142 | { | 142 | { |
143 | PHASE_KIND_ALL_TO_ALL, | 143 | PHASE_KIND_ALL_TO_ALL, |
144 | PHASE_KIND_ALL_TO_ALL_2, | ||
144 | PHASE_KIND_GRADECAST_LEADER, | 145 | PHASE_KIND_GRADECAST_LEADER, |
145 | PHASE_KIND_GRADECAST_ECHO, | 146 | PHASE_KIND_GRADECAST_ECHO, |
146 | PHASE_KIND_GRADECAST_ECHO_GRADE, | 147 | PHASE_KIND_GRADECAST_ECHO_GRADE, |
@@ -528,6 +529,7 @@ phasename (uint16_t phase) | |||
528 | switch (phase) | 529 | switch (phase) |
529 | { | 530 | { |
530 | case PHASE_KIND_ALL_TO_ALL: return "ALL_TO_ALL"; | 531 | case PHASE_KIND_ALL_TO_ALL: return "ALL_TO_ALL"; |
532 | case PHASE_KIND_ALL_TO_ALL_2: return "ALL_TO_ALL_2"; | ||
531 | case PHASE_KIND_FINISH: return "FINISH"; | 533 | case PHASE_KIND_FINISH: return "FINISH"; |
532 | case PHASE_KIND_GRADECAST_LEADER: return "GRADECAST_LEADER"; | 534 | case PHASE_KIND_GRADECAST_LEADER: return "GRADECAST_LEADER"; |
533 | case PHASE_KIND_GRADECAST_ECHO: return "GRADECAST_ECHO"; | 535 | case PHASE_KIND_GRADECAST_ECHO: return "GRADECAST_ECHO"; |
@@ -668,7 +670,7 @@ send_to_client_iter (void *cls, | |||
668 | GNUNET_assert (GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT == element->element_type); | 670 | GNUNET_assert (GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT == element->element_type); |
669 | ce = element->data; | 671 | ce = element->data; |
670 | 672 | ||
671 | GNUNET_assert (GNUNET_NO == ce->is_contested_marker); | 673 | GNUNET_assert (0 == ce->marker); |
672 | 674 | ||
673 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 675 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
674 | "P%d: sending element %s to client\n", | 676 | "P%d: sending element %s to client\n", |
@@ -864,11 +866,13 @@ task_other_peer (struct TaskEntry *task) | |||
864 | * | 866 | * |
865 | * @param cls closure | 867 | * @param cls closure |
866 | * @param element a result element, only valid if status is GNUNET_SET_STATUS_OK | 868 | * @param element a result element, only valid if status is GNUNET_SET_STATUS_OK |
869 | * @param current_size current set size | ||
867 | * @param status see enum GNUNET_SET_Status | 870 | * @param status see enum GNUNET_SET_Status |
868 | */ | 871 | */ |
869 | static void | 872 | static void |
870 | set_result_cb (void *cls, | 873 | set_result_cb (void *cls, |
871 | const struct GNUNET_SET_Element *element, | 874 | const struct GNUNET_SET_Element *element, |
875 | uint64_t current_size, | ||
872 | enum GNUNET_SET_Status status) | 876 | enum GNUNET_SET_Status status) |
873 | { | 877 | { |
874 | struct TaskEntry *task = cls; | 878 | struct TaskEntry *task = cls; |
@@ -940,7 +944,7 @@ set_result_cb (void *cls, | |||
940 | if ( (GNUNET_SET_STATUS_ADD_LOCAL == status) || (GNUNET_SET_STATUS_ADD_REMOTE == status) ) | 944 | if ( (GNUNET_SET_STATUS_ADD_LOCAL == status) || (GNUNET_SET_STATUS_ADD_REMOTE == status) ) |
941 | { | 945 | { |
942 | if ( (GNUNET_YES == setop->transceive_contested) && | 946 | if ( (GNUNET_YES == setop->transceive_contested) && |
943 | (GNUNET_YES == consensus_element->is_contested_marker) ) | 947 | (CONSENSUS_MARKER_CONTESTED == consensus_element->marker) ) |
944 | { | 948 | { |
945 | GNUNET_assert (NULL != output_rfn); | 949 | GNUNET_assert (NULL != output_rfn); |
946 | rfn_contest (output_rfn, task_other_peer (task)); | 950 | rfn_contest (output_rfn, task_other_peer (task)); |
@@ -1001,7 +1005,7 @@ set_result_cb (void *cls, | |||
1001 | GNUNET_assert (NULL != consensus_element); | 1005 | GNUNET_assert (NULL != consensus_element); |
1002 | if (GNUNET_YES == setop->do_not_remove) | 1006 | if (GNUNET_YES == setop->do_not_remove) |
1003 | break; | 1007 | break; |
1004 | if (GNUNET_YES == consensus_element->is_contested_marker) | 1008 | if (CONSENSUS_MARKER_CONTESTED == consensus_element->marker) |
1005 | break; | 1009 | break; |
1006 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1010 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1007 | "Removing element in Task {%s}\n", | 1011 | "Removing element in Task {%s}\n", |
@@ -1325,11 +1329,19 @@ commit_set (struct ConsensusSession *session, | |||
1325 | } | 1329 | } |
1326 | } | 1330 | } |
1327 | #else | 1331 | #else |
1332 | |||
1333 | if (PHASE_KIND_ALL_TO_ALL_2 == task->key.kind) | ||
1334 | { | ||
1335 | struct GNUNET_SET_Element element; | ||
1336 | struct ConsensusElement ce = { 0 }; | ||
1337 | } | ||
1338 | |||
1339 | |||
1328 | if ( (GNUNET_YES == setop->transceive_contested) && (GNUNET_YES == set->is_contested) ) | 1340 | if ( (GNUNET_YES == setop->transceive_contested) && (GNUNET_YES == set->is_contested) ) |
1329 | { | 1341 | { |
1330 | struct GNUNET_SET_Element element; | 1342 | struct GNUNET_SET_Element element; |
1331 | struct ConsensusElement ce = { 0 }; | 1343 | struct ConsensusElement ce = { 0 }; |
1332 | ce.is_contested_marker = GNUNET_YES; | 1344 | ce.marker = CONSENSUS_MARKER_CONTESTED; |
1333 | element.data = &ce; | 1345 | element.data = &ce; |
1334 | element.size = sizeof (struct ConsensusElement); | 1346 | element.size = sizeof (struct ConsensusElement); |
1335 | element.element_type = GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT; | 1347 | element.element_type = GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT; |
@@ -2847,11 +2859,42 @@ construct_task_graph (struct ConsensusSession *session) | |||
2847 | put_task (session->taskmap, &task); | 2859 | put_task (session->taskmap, &task); |
2848 | } | 2860 | } |
2849 | 2861 | ||
2862 | round += 1; | ||
2850 | prev_step = step; | 2863 | prev_step = step; |
2851 | step = NULL; | 2864 | step = create_step (session, round, GNUNET_NO);; |
2865 | #ifdef GNUNET_EXTRA_LOGGING | ||
2866 | step->debug_name = GNUNET_strdup ("all to all 2"); | ||
2867 | #endif | ||
2868 | step_depend_on (step, prev_step); | ||
2869 | |||
2870 | |||
2871 | for (i = 0; i < n; i++) | ||
2872 | { | ||
2873 | uint16_t p1; | ||
2874 | uint16_t p2; | ||
2875 | |||
2876 | p1 = me; | ||
2877 | p2 = i; | ||
2878 | arrange_peers (&p1, &p2, n); | ||
2879 | task = ((struct TaskEntry) { | ||
2880 | .key = (struct TaskKey) { PHASE_KIND_ALL_TO_ALL_2, p1, p2, -1, -1 }, | ||
2881 | .step = step, | ||
2882 | .start = task_start_reconcile, | ||
2883 | .cancel = task_cancel_reconcile, | ||
2884 | }); | ||
2885 | task.cls.setop.input_set = (struct SetKey) { SET_KIND_CURRENT, 0 }; | ||
2886 | task.cls.setop.output_set = task.cls.setop.input_set; | ||
2887 | task.cls.setop.do_not_remove = GNUNET_YES; | ||
2888 | put_task (session->taskmap, &task); | ||
2889 | } | ||
2852 | 2890 | ||
2853 | round += 1; | 2891 | round += 1; |
2854 | 2892 | ||
2893 | prev_step = step; | ||
2894 | step = NULL; | ||
2895 | |||
2896 | |||
2897 | |||
2855 | /* Byzantine union */ | 2898 | /* Byzantine union */ |
2856 | 2899 | ||
2857 | /* sequential repetitions of the gradecasts */ | 2900 | /* sequential repetitions of the gradecasts */ |