gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r25143 - in gnunet/src: consensus include


From: gnunet
Subject: [GNUnet-SVN] r25143 - in gnunet/src: consensus include
Date: Mon, 26 Nov 2012 18:12:25 +0100

Author: dold
Date: 2012-11-26 18:12:24 +0100 (Mon, 26 Nov 2012)
New Revision: 25143

Modified:
   gnunet/src/consensus/consensus_api.c
   gnunet/src/include/gnunet_consensus_service.h
Log:
fixed doxygen


Modified: gnunet/src/consensus/consensus_api.c
===================================================================
--- gnunet/src/consensus/consensus_api.c        2012-11-26 16:27:24 UTC (rev 
25142)
+++ gnunet/src/consensus/consensus_api.c        2012-11-26 17:12:24 UTC (rev 
25143)
@@ -151,8 +151,6 @@
 message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
 {
   struct GNUNET_CONSENSUS_Handle *consensus = cls;
-  GNUNET_CONSENSUS_InsertDoneCallback idc;
-  void *idc_cls;
 
   if (msg == NULL)
   {
@@ -171,13 +169,6 @@
 
   switch (ntohs(msg->type))
   {
-    case GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_INSERT_ACK:
-      idc = consensus->idc;
-      consensus->idc = NULL;
-      idc_cls = consensus->idc_cls;
-      consensus->idc_cls = NULL;
-      idc(idc_cls, GNUNET_YES);
-      break;
     case GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_RECEIVED_ELEMENT:
       handle_new_element(consensus, (struct GNUNET_CONSENSUS_ElementMessage *) 
msg);
       break;
@@ -210,7 +201,9 @@
 {
   struct GNUNET_CONSENSUS_ElementMessage *msg;
   struct GNUNET_CONSENSUS_Handle *consensus;
+  GNUNET_CONSENSUS_InsertDoneCallback idc;
   int msize;
+  void *idc_cls;
 
   GNUNET_assert (NULL != buf);
 
@@ -220,7 +213,6 @@
 
   consensus->th = NULL;
 
-
   msg = buf;
 
   msize = sizeof (struct GNUNET_CONSENSUS_ElementMessage) +
@@ -232,6 +224,13 @@
          consensus->insert_element->data,
          consensus->insert_element->size);
 
+
+  idc = consensus->idc;
+  consensus->idc = NULL;
+  idc_cls = consensus->idc_cls;
+  consensus->idc_cls = NULL;
+  idc(idc_cls, GNUNET_YES);
+
   return msize;
 }
 
@@ -328,8 +327,40 @@
 }
 
 
+/**
+ * Function called to notify a client about the connection
+ * begin ready to queue more data.  "buf" will be
+ * NULL and "size" zero if the connection was closed for
+ * writing in the meantime.
+ *
+ * @param cls the consensus handle
+ * @param size number of bytes available in buf
+ * @param buf where the callee should write the message
+ * @return number of bytes written to buf
+ */
+static size_t
+transmit_begin (void *cls, size_t size, void *buf)
+{
+  struct GNUNET_MessageHeader *msg;
+  struct GNUNET_CONSENSUS_Handle *consensus;
+  int msize;
 
+  GNUNET_assert (NULL != buf);
 
+  consensus = cls;
+  consensus->th = NULL;
+
+  msg = buf;
+
+  msize = sizeof (struct GNUNET_MessageHeader);
+
+  msg->type = htons (GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_BEGIN);
+  msg->size = htons (msize);
+
+  return msize;
+}
+
+
 /**
  * Create a consensus session.
  *
@@ -339,9 +370,7 @@
  *              Inclusion of the local peer is optional.
  * @param session_id session identifier
  *                   Allows a group of peers to have more than consensus 
session.
- * @param num_initial_elements number of entries in the 'initial_elements' 
array
- * @param initial_elements our elements for the consensus (each of 
'element_size'
- * @param new_element callback, called when a new element is added to the set 
by
+ * @param new_element_cb callback, called when a new element is added to the 
set by
  *                    another peer
  * @param new_element_cls closure for new_element
  * @return handle to use, NULL on error
@@ -351,11 +380,7 @@
                         unsigned int num_peers,
                         const struct GNUNET_PeerIdentity *peers,
                          const struct GNUNET_HashCode *session_id,
-                         /*
-                        unsigned int num_initial_elements,
-                         const struct GNUNET_CONSENSUS_Element 
**initial_elements,
-                         */
-                         GNUNET_CONSENSUS_NewElementCallback new_element,
+                         GNUNET_CONSENSUS_NewElementCallback new_element_cb,
                          void *new_element_cls)
 {
   struct GNUNET_CONSENSUS_Handle *consensus;
@@ -364,7 +389,7 @@
 
   consensus = GNUNET_malloc (sizeof (struct GNUNET_CONSENSUS_Handle));
   consensus->cfg = cfg;
-  consensus->new_element_cb = new_element;
+  consensus->new_element_cb = new_element_cb;
   consensus->new_element_cls = new_element_cls;
   consensus->num_peers = num_peers;
   consensus->session_id = *session_id;
@@ -448,6 +473,25 @@
 
 
 /**
+ * Begin reconciling elements with other peers.
+ *
+ * @param consensus handle for the consensus session
+ */
+void
+GNUNET_CONSENSUS_begin (struct GNUNET_CONSENSUS_Handle *consensus)
+{
+  GNUNET_assert (NULL == consensus->idc);
+  GNUNET_assert (NULL == consensus->insert_element);
+
+  consensus->th =
+      GNUNET_CLIENT_notify_transmit_ready (consensus->client,
+                                           sizeof (struct 
GNUNET_MessageHeader),
+                                           GNUNET_TIME_UNIT_FOREVER_REL,
+                                           GNUNET_NO, &transmit_begin, 
consensus);
+}
+
+
+/**
  * We are finished inserting new elements into the consensus;
  * try to conclude the consensus within a given time window.
  *

Modified: gnunet/src/include/gnunet_consensus_service.h
===================================================================
--- gnunet/src/include/gnunet_consensus_service.h       2012-11-26 16:27:24 UTC 
(rev 25142)
+++ gnunet/src/include/gnunet_consensus_service.h       2012-11-26 17:12:24 UTC 
(rev 25143)
@@ -85,6 +85,8 @@
 
 /**
  * Create a consensus session.
+ * The set being reconciled is initially empty.  Only reconcile with other 
peers
+ * after GNUNET_CONSENSUS_reconcile has been called.
  *
  * @param cfg
  * @param num_peers
@@ -92,9 +94,7 @@
  *              Inclusion of the local peer is optional.
  * @param session_id session identifier
  *                   Allows a group of peers to have more than consensus 
session.
- * @param num_initial_elements number of entries in the 'initial_elements' 
array
- * @param initial_elements our elements for the consensus (each of 
'element_size'
- * @param new_element callback, called when a new element is added to the set 
by
+ * @param new_element_cb callback, called when a new element is added to the 
set by
  *                    another peer
  * @param new_element_cls closure for new_element
  * @return handle to use, NULL on error
@@ -104,11 +104,7 @@
                         unsigned int num_peers,
                         const struct GNUNET_PeerIdentity *peers,
                          const struct GNUNET_HashCode *session_id,
-                         /*
-                        unsigned int num_initial_elements,
-                         const struct GNUNET_CONSENSUS_Element 
**initial_elements,
-                         */
-                         GNUNET_CONSENSUS_NewElementCallback new_element,
+                         GNUNET_CONSENSUS_NewElementCallback new_element_cb,
                          void *new_element_cls);
 
 
@@ -126,8 +122,9 @@
 
 
 /**
- * Insert an element in the set being reconsiled.  Must not be called after
- * "GNUNET_CONSENSUS_conclude".
+ * Insert an element in the set being reconsiled.  Only transmit changes to
+ * other peers if "GNUNET_CONSENSUS_begin" has been called.
+ * Must not be called after "GNUNET_CONSENSUS_conclude".
  *
  * @param consensus handle for the consensus session
  * @param element the element to be inserted
@@ -143,6 +140,18 @@
 
 
 /**
+ * Begin reconciling elements with other peers.
+ * May not be called if an insert operation has not yet finished.
+ *
+ * @param consensus handle for the consensus session
+ */
+void
+GNUNET_CONSENSUS_begin (struct GNUNET_CONSENSUS_Handle *consensus);
+
+
+
+
+/**
  * Called when a conclusion was successful.
  *
  * @param cls




reply via email to

[Prev in Thread] Current Thread [Next in Thread]