From 6da407ad72fdca282094ccdb5558ece9638e3bd3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 27 Feb 2017 01:18:54 +0100 Subject: include set size in result callback, needed by consensus --- src/consensus/consensus_protocol.h | 8 ++++- src/consensus/gnunet-service-consensus.c | 53 +++++++++++++++++++++++++++++--- src/consensus/plugin_block_consensus.c | 2 +- 3 files changed, 56 insertions(+), 7 deletions(-) (limited to 'src/consensus') diff --git a/src/consensus/consensus_protocol.h b/src/consensus/consensus_protocol.h index 161c939cd..43b6a9632 100644 --- a/src/consensus/consensus_protocol.h +++ b/src/consensus/consensus_protocol.h @@ -89,6 +89,12 @@ struct GNUNET_CONSENSUS_RoundContextMessage }; +enum { + CONSENSUS_MARKER_CONTESTED, + CONSENSUS_MARKER_SIZE, +}; + + /** * Consensus element, either marker or payload. */ @@ -103,7 +109,7 @@ struct ConsensusElement /** * Is this a marker element? */ - uint8_t is_contested_marker; + uint8_t marker; /* rest: element data */ }; 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 enum PhaseKind { PHASE_KIND_ALL_TO_ALL, + PHASE_KIND_ALL_TO_ALL_2, PHASE_KIND_GRADECAST_LEADER, PHASE_KIND_GRADECAST_ECHO, PHASE_KIND_GRADECAST_ECHO_GRADE, @@ -528,6 +529,7 @@ phasename (uint16_t phase) switch (phase) { case PHASE_KIND_ALL_TO_ALL: return "ALL_TO_ALL"; + case PHASE_KIND_ALL_TO_ALL_2: return "ALL_TO_ALL_2"; case PHASE_KIND_FINISH: return "FINISH"; case PHASE_KIND_GRADECAST_LEADER: return "GRADECAST_LEADER"; case PHASE_KIND_GRADECAST_ECHO: return "GRADECAST_ECHO"; @@ -668,7 +670,7 @@ send_to_client_iter (void *cls, GNUNET_assert (GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT == element->element_type); ce = element->data; - GNUNET_assert (GNUNET_NO == ce->is_contested_marker); + GNUNET_assert (0 == ce->marker); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "P%d: sending element %s to client\n", @@ -864,11 +866,13 @@ task_other_peer (struct TaskEntry *task) * * @param cls closure * @param element a result element, only valid if status is GNUNET_SET_STATUS_OK + * @param current_size current set size * @param status see enum GNUNET_SET_Status */ static void set_result_cb (void *cls, const struct GNUNET_SET_Element *element, + uint64_t current_size, enum GNUNET_SET_Status status) { struct TaskEntry *task = cls; @@ -940,7 +944,7 @@ set_result_cb (void *cls, if ( (GNUNET_SET_STATUS_ADD_LOCAL == status) || (GNUNET_SET_STATUS_ADD_REMOTE == status) ) { if ( (GNUNET_YES == setop->transceive_contested) && - (GNUNET_YES == consensus_element->is_contested_marker) ) + (CONSENSUS_MARKER_CONTESTED == consensus_element->marker) ) { GNUNET_assert (NULL != output_rfn); rfn_contest (output_rfn, task_other_peer (task)); @@ -1001,7 +1005,7 @@ set_result_cb (void *cls, GNUNET_assert (NULL != consensus_element); if (GNUNET_YES == setop->do_not_remove) break; - if (GNUNET_YES == consensus_element->is_contested_marker) + if (CONSENSUS_MARKER_CONTESTED == consensus_element->marker) break; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing element in Task {%s}\n", @@ -1325,11 +1329,19 @@ commit_set (struct ConsensusSession *session, } } #else + + if (PHASE_KIND_ALL_TO_ALL_2 == task->key.kind) + { + struct GNUNET_SET_Element element; + struct ConsensusElement ce = { 0 }; + } + + if ( (GNUNET_YES == setop->transceive_contested) && (GNUNET_YES == set->is_contested) ) { struct GNUNET_SET_Element element; struct ConsensusElement ce = { 0 }; - ce.is_contested_marker = GNUNET_YES; + ce.marker = CONSENSUS_MARKER_CONTESTED; element.data = &ce; element.size = sizeof (struct ConsensusElement); element.element_type = GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT; @@ -2847,11 +2859,42 @@ construct_task_graph (struct ConsensusSession *session) put_task (session->taskmap, &task); } + round += 1; prev_step = step; - step = NULL; + step = create_step (session, round, GNUNET_NO);; +#ifdef GNUNET_EXTRA_LOGGING + step->debug_name = GNUNET_strdup ("all to all 2"); +#endif + step_depend_on (step, prev_step); + + + for (i = 0; i < n; i++) + { + uint16_t p1; + uint16_t p2; + + p1 = me; + p2 = i; + arrange_peers (&p1, &p2, n); + task = ((struct TaskEntry) { + .key = (struct TaskKey) { PHASE_KIND_ALL_TO_ALL_2, p1, p2, -1, -1 }, + .step = step, + .start = task_start_reconcile, + .cancel = task_cancel_reconcile, + }); + task.cls.setop.input_set = (struct SetKey) { SET_KIND_CURRENT, 0 }; + task.cls.setop.output_set = task.cls.setop.input_set; + task.cls.setop.do_not_remove = GNUNET_YES; + put_task (session->taskmap, &task); + } round += 1; + prev_step = step; + step = NULL; + + + /* Byzantine union */ /* sequential repetitions of the gradecasts */ diff --git a/src/consensus/plugin_block_consensus.c b/src/consensus/plugin_block_consensus.c index 3ad335760..0cb64867e 100644 --- a/src/consensus/plugin_block_consensus.c +++ b/src/consensus/plugin_block_consensus.c @@ -63,7 +63,7 @@ block_plugin_consensus_evaluate (void *cls, const struct ConsensusElement *ce = reply_block; - if ( (GNUNET_YES == ce->is_contested_marker) || + if ( (0 != ce->marker) || (0 == ce->payload_type ) ) return GNUNET_BLOCK_EVALUATION_OK_MORE; -- cgit v1.2.3