/**
* @file consensus/consensus_api.c
- * @brief
+ * @brief
* @author Florian Dold
*/
#include "platform.h"
*/
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.
*/
/**
* Called when the server has sent is a new element
- *
+ *
* @param cls consensus handle
* @param mh element message
*/
/**
* Called when the server has announced
* that the conclusion is over.
- *
+ *
* @param cls consensus handle
* @param msg conclude done message
*/
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);
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;
*
* @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'
*/
GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_INSERT);
memcpy (&element_msg[1], element->data, element->size);
-
+
if (NULL != idc)
{
i = GNUNET_new (struct InsertDoneInfo);
GNUNET_CLIENT_disconnect (consensus->client);
consensus->client = NULL;
}
- if (NULL != consensus->peers)
- GNUNET_free (consensus->peers);
GNUNET_free (consensus);
}