gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r27008 - gnunet/src/set


From: gnunet
Subject: [GNUnet-SVN] r27008 - gnunet/src/set
Date: Tue, 30 Apr 2013 13:53:21 +0200

Author: dold
Date: 2013-04-30 13:53:21 +0200 (Tue, 30 Apr 2013)
New Revision: 27008

Modified:
   gnunet/src/set/gnunet-service-set.c
   gnunet/src/set/gnunet-service-set.h
   gnunet/src/set/gnunet-service-set_union.c
Log:
fix/docs

Modified: gnunet/src/set/gnunet-service-set.c
===================================================================
--- gnunet/src/set/gnunet-service-set.c 2013-04-30 11:05:11 UTC (rev 27007)
+++ gnunet/src/set/gnunet-service-set.c 2013-04-30 11:53:21 UTC (rev 27008)
@@ -146,6 +146,11 @@
 }
 
 
+/**
+ * Destroy an incoming request from a remote peer
+ *
+ * @param incoming remote request to destroy
+ */
 static void
 destroy_incoming (struct Incoming *incoming)
 {
@@ -225,7 +230,6 @@
     GNUNET_MQ_send (listener->client_mq, mqm);
     return;
   }
-  /* FIXME: send a reject message */
 }
 
 
@@ -590,7 +594,7 @@
     {handle_client_create, NULL, GNUNET_MESSAGE_TYPE_SET_CREATE, 0},
     {handle_client_listen, NULL, GNUNET_MESSAGE_TYPE_SET_LISTEN, 0},
     {handle_client_add, NULL, GNUNET_MESSAGE_TYPE_SET_ADD, 0},
-    {handle_client_remove, NULL, GNUNET_MESSAGE_TYPE_SET_ADD, 0},
+    {handle_client_remove, NULL, GNUNET_MESSAGE_TYPE_SET_REMOVE, 0},
     {handle_client_cancel, NULL, GNUNET_MESSAGE_TYPE_SET_CANCEL, 0},
     {handle_client_evaluate, NULL, GNUNET_MESSAGE_TYPE_SET_EVALUATE, 0},
     {handle_client_ack, NULL, GNUNET_MESSAGE_TYPE_SET_ACK, 0},

Modified: gnunet/src/set/gnunet-service-set.h
===================================================================
--- gnunet/src/set/gnunet-service-set.h 2013-04-30 11:05:11 UTC (rev 27007)
+++ gnunet/src/set/gnunet-service-set.h 2013-04-30 11:53:21 UTC (rev 27008)
@@ -210,22 +210,54 @@
 _GSS_client_disconnect (struct GNUNET_SERVER_Client *client);
 
 
+/**
+ * Create a new set supporting the union operation
+ *
+ * @return the newly created set
+ */
 struct Set *
 _GSS_union_set_create (void);
 
 
+/**
+ * Evaluate a union operation with
+ * a remote peer.
+ *
+ * @param m the evaluate request message from the client
+ * @parem set the set to evaluate the operation with
+ */
 void
 _GSS_union_evaluate (struct EvaluateMessage *m, struct Set *set);
 
 
+/**
+ * Add the element from the given element message to the set.
+ *
+ * @param m message with the element
+ * @param set set to add the element to
+ */
 void
 _GSS_union_add (struct ElementMessage *m, struct Set *set);
 
 
+/**
+ * Remove the element given in the element message from the set.
+ * Only marks the element as removed, so that older set operations can still 
exchange it.
+ *
+ * @param m message with the element
+ * @param set set to remove the element from
+ */
 void
 _GSS_union_remove (struct ElementMessage *m, struct Set *set);
 
 
+/**
+ * Accept an union operation request from a remote peer
+ *
+ * @param m the accept message from the client
+ * @param set the set of the client
+ * @param incoming information about the requesting remote peer
+ */
 void
 _GSS_union_accept (struct AcceptMessage *m, struct Set *set,
                    struct Incoming *incoming);

Modified: gnunet/src/set/gnunet-service-set_union.c
===================================================================
--- gnunet/src/set/gnunet-service-set_union.c   2013-04-30 11:05:11 UTC (rev 
27007)
+++ gnunet/src/set/gnunet-service-set_union.c   2013-04-30 11:53:21 UTC (rev 
27008)
@@ -330,8 +330,6 @@
 };
 
 
-
-
 /**
  * Destroy a union operation, and free all resources
  * associated with it.
@@ -945,6 +943,12 @@
 }
 
 
+/**
+ * Handle a done message from a remote peer
+ * 
+ * @param cls the union operation
+ * @param mh the message
+ */
 static void
 handle_p2p_done (void *cls, const struct GNUNET_MessageHeader *mh)
 {
@@ -1009,8 +1013,14 @@
   eo->phase = PHASE_EXPECT_SE;
 }
 
-       
 
+/**
+ * Evaluate a union operation with
+ * a remote peer.
+ *
+ * @param m the evaluate request message from the client
+ * @parem set the set to evaluate the operation with
+ */
 void
 _GSS_union_evaluate (struct EvaluateMessage *m, struct Set *set)
 {
@@ -1029,9 +1039,17 @@
       GNUNET_STREAM_open (configuration, &eo->peer, 
GNUNET_APPLICATION_TYPE_SET,
                           stream_open_cb, eo,
                           GNUNET_STREAM_OPTION_END);
+  /* the stream open callback will kick off the operation */
 }
 
 
+/**
+ * Accept an union operation request from a remote peer
+ *
+ * @param m the accept message from the client
+ * @param set the set of the client
+ * @param incoming information about the requesting remote peer
+ */
 void
 _GSS_union_accept (struct AcceptMessage *m, struct Set *set,
                    struct Incoming *incoming)
@@ -1054,6 +1072,11 @@
 }
 
 
+/**
+ * Create a new set supporting the union operation
+ *
+ * @return the newly created set
+ */
 struct Set *
 _GSS_union_set_create (void)
 {
@@ -1064,23 +1087,34 @@
   set = GNUNET_malloc (sizeof (struct Set) + sizeof (struct UnionState));
   set->state.u = (struct UnionState *) &set[1];
   set->operation = GNUNET_SET_OPERATION_UNION;
+  /* keys of the hash map are stored in the element entrys, thus we do not
+   * want the hash map to copy them */
+  set->state.u->elements = GNUNET_CONTAINER_multihashmap_create (1, 
GNUNET_YES);
   set->state.u->se = strata_estimator_create (SE_STRATA_COUNT,
                                               SE_IBF_SIZE, SE_IBF_HASH_NUM);  
   return set;
 }
 
 
+/**
+ * Add the element from the given element message to the set.
+ *
+ * @param m message with the element
+ * @param set set to add the element to
+ */
 void
 _GSS_union_add (struct ElementMessage *m, struct Set *set)
 {
   struct ElementEntry *ee;
   struct ElementEntry *ee_dup;
   uint16_t element_size;
-  
+
+  GNUNET_assert (GNUNET_SET_OPERATION_UNION == set->operation);
   element_size = ntohs (m->header.size) - sizeof *m;
   ee = GNUNET_malloc (element_size + sizeof *ee);
   ee->element.size = element_size;
   ee->element.data = &ee[1];
+  ee->generation_added = set->state.u->current_generation;
   memcpy (ee->element.data, &m[1], element_size);
   GNUNET_CRYPTO_hash (ee->element.data, element_size, &ee->element_hash);
   ee_dup = GNUNET_CONTAINER_multihashmap_get (set->state.u->elements, 
&ee->element_hash);
@@ -1109,8 +1143,8 @@
   struct GNUNET_HashCode hash;
   struct ElementEntry *ee;
 
+  GNUNET_assert (GNUNET_SET_OPERATION_UNION == set->operation);
   GNUNET_CRYPTO_hash (&m[1], ntohs (m->header.size), &hash);
-  
   ee = GNUNET_CONTAINER_multihashmap_get (set->state.u->elements, &hash);
   if (NULL == ee)
   {




reply via email to

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