X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fconsensus%2Fconsensus_api.c;h=d8e65c52fd202ecd150737219c9189183b605cb8;hb=2032baa561c7fefbe2605f5d6b979a295a61637d;hp=7690dc059406f57e01fcf4fe4e789d373a1ae32b;hpb=6b8400966a5e6c2194785b3a33f91b748cfa7b7b;p=oweals%2Fgnunet.git diff --git a/src/consensus/consensus_api.c b/src/consensus/consensus_api.c index 7690dc059..d8e65c52f 100644 --- a/src/consensus/consensus_api.c +++ b/src/consensus/consensus_api.c @@ -20,7 +20,7 @@ /** * @file consensus/consensus_api.c - * @brief + * @brief * @author Florian Dold */ #include "platform.h" @@ -64,16 +64,6 @@ struct GNUNET_CONSENSUS_Handle */ struct GNUNET_HashCode session_id; - /** - * Number of peers in the consensus. Optionally includes the local peer. - */ - int num_peers; - - /** - * Peer identities of peers participating in the consensus, includes the local peer. - */ - struct GNUNET_PeerIdentity **peers; - /** * GNUNES_YES iff the join message has been sent to the service. */ @@ -113,7 +103,7 @@ struct InsertDoneInfo /** * Called when the server has sent is a new element - * + * * @param cls consensus handle * @param mh element message */ @@ -139,7 +129,7 @@ handle_new_element (void *cls, /** * Called when the server has announced * that the conclusion is over. - * + * * @param cls consensus handle * @param msg conclude done message */ @@ -194,15 +184,7 @@ GNUNET_CONSENSUS_create (const struct GNUNET_CONFIGURATION_Handle *cfg, consensus->cfg = cfg; consensus->new_element_cb = new_element_cb; consensus->new_element_cls = new_element_cls; - consensus->num_peers = num_peers; consensus->session_id = *session_id; - - if (0 == num_peers) - consensus->peers = NULL; - else if (num_peers > 0) - consensus->peers = - GNUNET_memdup (peers, num_peers * sizeof (struct GNUNET_PeerIdentity)); - consensus->client = GNUNET_CLIENT_connect ("consensus", cfg); consensus->mq = GNUNET_MQ_queue_for_connection_client (consensus->client, mq_handlers, NULL, consensus); @@ -214,10 +196,10 @@ GNUNET_CONSENSUS_create (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN); join_msg->session_id = consensus->session_id; - join_msg->num_peers = htonl (consensus->num_peers); + join_msg->num_peers = htonl (num_peers); memcpy(&join_msg[1], - consensus->peers, - consensus->num_peers * sizeof (struct GNUNET_PeerIdentity)); + peers, + num_peers * sizeof (struct GNUNET_PeerIdentity)); GNUNET_MQ_send (consensus->mq, ev); return consensus; @@ -238,7 +220,7 @@ idc_adapter (void *cls) * * @param consensus handle for the consensus session * @param element the element to be inserted - * @param idc function called when we are done with this element and it + * @param idc function called when we are done with this element and it * is thus allowed to call GNUNET_CONSENSUS_insert again * @param idc_cls closure for 'idc' */ @@ -258,7 +240,7 @@ GNUNET_CONSENSUS_insert (struct GNUNET_CONSENSUS_Handle *consensus, GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_INSERT); memcpy (&element_msg[1], element->data, element->size); - + if (NULL != idc) { i = GNUNET_new (struct InsertDoneInfo); @@ -266,6 +248,7 @@ GNUNET_CONSENSUS_insert (struct GNUNET_CONSENSUS_Handle *consensus, i->cls = idc_cls; GNUNET_MQ_notify_sent (ev, idc_adapter, i); } + GNUNET_MQ_send (consensus->mq, ev); } @@ -317,8 +300,6 @@ GNUNET_CONSENSUS_destroy (struct GNUNET_CONSENSUS_Handle *consensus) GNUNET_CLIENT_disconnect (consensus->client); consensus->client = NULL; } - if (NULL != consensus->peers) - GNUNET_free (consensus->peers); GNUNET_free (consensus); }