- struct GNUNET_CONSENSUS_Handle *consensus;
- struct QueuedMessage *qmsg;
- size_t msg_size;
-
- consensus = (struct GNUNET_CONSENSUS_Handle *) cls;
- consensus->th = NULL;
-
- qmsg = consensus->messages_head;
- GNUNET_CONTAINER_DLL_remove (consensus->messages_head, consensus->messages_tail, qmsg);
-
- if (NULL == buf)
- {
- if (NULL != qmsg->idc)
- {
- qmsg->idc (qmsg->idc_cls, GNUNET_YES);
- }
- return 0;
- }
-
- msg_size = ntohs (qmsg->msg->size);
-
- GNUNET_assert (size >= msg_size);
-
- memcpy (buf, qmsg->msg, msg_size);
- if (NULL != qmsg->idc)
- {
- qmsg->idc (qmsg->idc_cls, GNUNET_YES);
- }
- GNUNET_free (qmsg->msg);
- GNUNET_free (qmsg);
- /* FIXME: free the messages */
-
- send_next (consensus);
-
- return msg_size;
-}
-
-
-/**
- * Schedule transmitting the next message.
- *
- * @param consensus consensus handle
- */
-static void
-send_next (struct GNUNET_CONSENSUS_Handle *consensus)
-{
- if (NULL != consensus->th)
- return;
-
- if (NULL != consensus->messages_head)
- {
- consensus->th =
- GNUNET_CLIENT_notify_transmit_ready (consensus->client, ntohs (consensus->messages_head->msg->size),
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_NO, &transmit_queued, consensus);
- }
-}