aboutsummaryrefslogtreecommitdiff
path: root/src/consensus
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2013-07-23 21:27:17 +0000
committerFlorian Dold <florian.dold@gmail.com>2013-07-23 21:27:17 +0000
commit4d16dd35e67216b69a7d49d967ccdebcd1238344 (patch)
tree261ec0cba4af5a16286e0311000c298bfffd460b /src/consensus
parentc8ebf525e5dda3f4f9da3fafc2bff239f6c5e4ce (diff)
downloadgnunet-4d16dd35e67216b69a7d49d967ccdebcd1238344.tar.gz
gnunet-4d16dd35e67216b69a7d49d967ccdebcd1238344.zip
-send elements to client
Diffstat (limited to 'src/consensus')
-rw-r--r--src/consensus/gnunet-service-consensus.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index 1245dcca4..2cf5bb4d4 100644
--- a/src/consensus/gnunet-service-consensus.c
+++ b/src/consensus/gnunet-service-consensus.c
@@ -302,6 +302,35 @@ destroy_session (struct ConsensusSession *session)
302} 302}
303 303
304 304
305
306/**
307 * Iterator for set elements.
308 *
309 * @param cls closure
310 * @param element the current element, NULL if all elements have been
311 * iterated over
312 * @return GNUNET_YES to continue iterating, GNUNET_NO to stop.
313 */
314static int
315send_to_client_iter (void *cls,
316 const struct GNUNET_SET_Element *element)
317{
318 struct ConsensusSession *session = cls;
319
320 if (NULL != element)
321 {
322 struct GNUNET_MQ_Envelope *ev;
323 struct GNUNET_CONSENSUS_ElementMessage *m;
324
325 ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_RECEIVED_ELEMENT);
326 m->element_type = htons (element->type);
327 memcpy (&m[1], element->data, element->size);
328 GNUNET_MQ_send (session->client_mq, ev);
329 }
330 return GNUNET_YES;
331}
332
333
305/** 334/**
306 * Start the next round. 335 * Start the next round.
307 * This function can be invoked as a timeout task, or called manually (tc will be NULL then). 336 * This function can be invoked as a timeout task, or called manually (tc will be NULL then).
@@ -336,8 +365,10 @@ round_over (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
336 subround_over (session, NULL); 365 subround_over (session, NULL);
337 break; 366 break;
338 case CONSENSUS_ROUND_EXCHANGE: 367 case CONSENSUS_ROUND_EXCHANGE:
339 /* FIXME: send all elements to client */ 368 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "P%d: finished, sending elements to client\n",
369 session->local_peer_idx);
340 session->current_round = CONSENSUS_ROUND_FINISH; 370 session->current_round = CONSENSUS_ROUND_FINISH;
371 GNUNET_SET_iterate (session->element_set, send_to_client_iter, session);
341 default: 372 default:
342 GNUNET_assert (0); 373 GNUNET_assert (0);
343 } 374 }