migrating towards XDG configuration specification (#3000)
[oweals/gnunet.git] / src / consensus / consensus_api.c
index a1dc4082616010de81a5c162cc95af0254e36f9e..d8e65c52fd202ecd150737219c9189183b605cb8 100644 (file)
@@ -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,18 +184,10 @@ 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, consensus);
+                                                         mq_handlers, NULL, consensus);
 
   GNUNET_assert (consensus->client != NULL);
 
@@ -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);
 }