gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r27007 - gnunet/src/set
Date: Tue, 30 Apr 2013 13:05:11 +0200

Author: dold
Date: 2013-04-30 13:05:11 +0200 (Tue, 30 Apr 2013)
New Revision: 27007

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


Modified: gnunet/src/set/gnunet-service-set_union.c
===================================================================
--- gnunet/src/set/gnunet-service-set_union.c   2013-04-30 10:44:25 UTC (rev 
27006)
+++ gnunet/src/set/gnunet-service-set_union.c   2013-04-30 11:05:11 UTC (rev 
27007)
@@ -454,6 +454,13 @@
 }
 
 
+/**
+ * Insert an element into the union operation's
+ * key-to-element mapping
+ *
+ * @param the union operation
+ * @param ee the element entry
+ */
 static void
 insert_element (struct UnionEvaluateOperation *eo, struct ElementEntry *ee)
 {
@@ -476,11 +483,16 @@
   }
   GNUNET_CONTAINER_multihashmap32_put (eo->key_to_element, (uint32_t) 
ibf_key.key_val, k,
                                        
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
-  if (NULL != eo->local_ibf)
-    ibf_insert (eo->local_ibf, ibf_key);
 }
 
 
+/**
+ * Insert a key into an ibf.
+ *
+ * @param cls the ibf
+ * @param key unused
+ * @param value the key entry to get the key from
+ */
 static int
 prepare_ibf_iterator (void *cls,
                       uint32_t key,
@@ -494,6 +506,15 @@
 }
 
 
+/**
+ * Iterator for initializing the
+ * key-to-element mapping of a union operation
+ *
+ * @param cls the union operation
+ * @param key unised
+ * @param value the element entry to insert
+ *        into the key-to-element mapping
+ */
 static int
 init_key_to_element_iterator (void *cls,
                               const struct GNUNET_HashCode *key,
@@ -514,6 +535,13 @@
 }
 
 
+/**
+ * Create an ibf with the operation's elements
+ * of the specified size
+ *
+ * @param eo the union operation
+ * @param size size of the ibf to create
+ */
 static void
 prepare_ibf (struct UnionEvaluateOperation *eo, uint16_t size)
 {
@@ -593,6 +621,14 @@
   eo->phase = PHASE_EXPECT_IBF;
 }
 
+
+/**
+ * Compute the necessary order of an ibf
+ * from the size of the symmetric set difference.
+ *
+ * @param diff the difference
+ * @return the required size of the ibf
+ */
 static unsigned int
 get_order_from_difference (unsigned int diff)
 {
@@ -607,6 +643,12 @@
 }
 
 
+/**
+ * Handle a strata estimator from a remote peer
+ *
+ * @param the union operation
+ * @param mh the message
+ */
 static void
 handle_p2p_strata_estimator (void *cls, const struct GNUNET_MessageHeader *mh)
 {
@@ -635,6 +677,13 @@
 
 
 
+/**
+ * Iterator to send elements to a remote peer
+ *
+ * @param cls closure with the element key and the union operation
+ * @param key ignored
+ * @param value the key entry
+ */
 static int
 send_element_iterator (void *cls,
                       uint32_t key,
@@ -746,6 +795,12 @@
 }
 
 
+/**
+ * Handle an IBF message from a remote peer.
+ *
+ * @param cls the union operation
+ * @param mh the header of the message
+ */
 static void
 handle_p2p_ibf (void *cls, const struct GNUNET_MessageHeader *mh)
 {
@@ -820,6 +875,12 @@
 }
 
 
+/**
+ * Handle an element message from a remote peer.
+ *
+ * @param cls the union operation
+ * @param mh the message
+ */
 static void
 handle_p2p_elements (void *cls, const struct GNUNET_MessageHeader *mh)
 {
@@ -845,6 +906,12 @@
 }
 
 
+/**
+ * Handle an element request from a remote peer.
+ *
+ * @param cls the union operation
+ * @param mh the message
+ */
 static void
 handle_p2p_element_requests (void *cls, const struct GNUNET_MessageHeader *mh)
 {
@@ -954,6 +1021,10 @@
   eo = GNUNET_new (struct UnionEvaluateOperation);
   eo->peer = m->peer;
   eo->set = set;
+  eo->request_id = htons(m->request_id);
+  eo->se = strata_estimator_dup (set->state.u->se);
+  eo->salt = ntohs (m->salt);
+  eo->app_id = m->app_id;
   eo->socket = 
       GNUNET_STREAM_open (configuration, &eo->peer, 
GNUNET_APPLICATION_TYPE_SET,
                           stream_open_cb, eo,
@@ -971,9 +1042,9 @@
   eo->generation_created = set->state.u->current_generation++;
   eo->set = set;
   eo->peer = incoming->peer;
-  eo->app_id = incoming->app_id;
   eo->salt = ntohs (incoming->salt);
   eo->request_id = m->request_id;
+  eo->se = strata_estimator_dup (set->state.u->se);
   eo->set = set;
   eo->mq = incoming->mq;
   /* the peer's socket is now ours, we'll receive all messages */

Modified: gnunet/src/set/set.h
===================================================================
--- gnunet/src/set/set.h        2013-04-30 10:44:25 UTC (rev 27006)
+++ gnunet/src/set/set.h        2013-04-30 11:05:11 UTC (rev 27007)
@@ -135,9 +135,15 @@
    */
   uint32_t request_id GNUNET_PACKED;
 
-  uint16_t salt;
+  /**
+   * Salt to use for the operation
+   */
+  uint16_t salt GNUNET_PACKED;
 
-  uint16_t reserved;
+  /**
+   * Padding
+   */
+  uint16_t reserved GNUNET_PACKED;
 
   /* rest: inner message */
 };

Modified: gnunet/src/set/strata_estimator.c
===================================================================
--- gnunet/src/set/strata_estimator.c   2013-04-30 10:44:25 UTC (rev 27006)
+++ gnunet/src/set/strata_estimator.c   2013-04-30 11:05:11 UTC (rev 27007)
@@ -132,7 +132,28 @@
   return count;
 }
 
+/**
+ * Make a copy of a strata estimator.
+ *
+ * @param se the strata estimator to copy
+ * @return the copy
+ */
+struct StrataEstimator *
+strata_estimator_dup (struct StrataEstimator *se)
+{
+  struct StrataEstimator *c;
+  int i;
 
+  c = GNUNET_malloc (sizeof (struct StrataEstimator));
+  c->strata_count = se->strata_count;
+  c->ibf_size = se->ibf_size;
+  c->strata = GNUNET_malloc (sizeof (struct InvertibleBloomFilter *) * 
se->strata_count);
+  for (i = 0; i < se->strata_count; i++)
+    c->strata[i] = ibf_dup (se->strata[i]);
+  return c;
+}
+
+
 void
 strata_estimator_destroy (struct StrataEstimator *se)
 {

Modified: gnunet/src/set/strata_estimator.h
===================================================================
--- gnunet/src/set/strata_estimator.h   2013-04-30 10:44:25 UTC (rev 27006)
+++ gnunet/src/set/strata_estimator.h   2013-04-30 11:05:11 UTC (rev 27007)
@@ -73,6 +73,16 @@
 strata_estimator_destroy (struct StrataEstimator *se);
 
 
+/**
+ * Make a copy of a strata estimator.
+ *
+ * @param se the strata estimator to copy
+ * @return the copy
+ */
+struct StrataEstimator *
+strata_estimator_dup (struct StrataEstimator *se);
+
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif




reply via email to

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