gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 163/164: Added some more comments


From: gnunet
Subject: [gnunet] 163/164: Added some more comments
Date: Fri, 30 Jul 2021 15:33:49 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit 891ae7f4048b73d6a9324e0eb739b903b2078270
Author: Elias Summermatter <elias.summermatter@seccom.ch>
AuthorDate: Thu Jun 17 11:39:55 2021 +0200

    Added some more comments
---
 src/setu/gnunet-service-setu.c | 73 +++++++++++++++++++++++++++++++++++++++++-
 src/setu/ibf.c                 | 31 ++++++++++++++++--
 2 files changed, 101 insertions(+), 3 deletions(-)

diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index e5e7d7591..bc181b1c2 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -526,7 +526,7 @@ struct Operation
   uint64_t local_set_diff;
 
   /**
-   *
+   * Boolean to enforce an active passive switch
    */
   bool active_passive_switch_required;
 };
@@ -812,9 +812,24 @@ struct per_store_struct perf_store;
 
 enum MESSAGE_CONTROL_FLOW_STATE
 {
+  /**
+   *  Initial message state
+   */
   MSG_CFS_UNINITIALIZED,
+
+  /**
+   *  Track that a message has been sent
+   */
   MSG_CFS_SENT,
+
+  /**
+   *  Track that receiving this message is expected
+   */
   MSG_CFS_EXPECTED,
+
+  /**
+   * Track that message has been recieved
+   */
   MSG_CFS_RECEIVED,
 };
 
@@ -824,8 +839,17 @@ enum MESSAGE_CONTROL_FLOW_STATE
 
 enum MESSAGE_TYPE
 {
+  /**
+   * Offer message type
+   */
   OFFER_MESSAGE,
+  /**
+   * Demand message type
+   */
   DEMAND_MESSAGE,
+  /**
+   * Elemente message type
+   */
   ELEMENT_MESSAGE,
 };
 
@@ -835,8 +859,17 @@ enum MESSAGE_TYPE
 
 struct messageControlFlowElement
 {
+  /**
+   * Track the message control state of the offer message
+   */
   enum MESSAGE_CONTROL_FLOW_STATE offer;
+  /**
+   * Track the message control state of the demand message
+   */
   enum MESSAGE_CONTROL_FLOW_STATE demand;
+  /**
+   * Track the message control state of the element message
+   */
   enum MESSAGE_CONTROL_FLOW_STATE element;
 };
 
@@ -1150,6 +1183,9 @@ static int
 check_valid_phase (const uint8_t allowed_phases[], size_t size_phases, struct
                    Operation *op)
 {
+  /**
+   * Iterate over allowed phases
+   */
   for (uint32_t phase_ctr = 0; phase_ctr < size_phases; phase_ctr++)
   {
     uint8_t phase = allowed_phases[phase_ctr];
@@ -1186,6 +1222,10 @@ update_message_control_flow (struct 
GNUNET_CONTAINER_MultiHashMap *hash_map,
   struct messageControlFlowElement *cfe = NULL;
   enum MESSAGE_CONTROL_FLOW_STATE *mcfs;
 
+  /**
+   * Check logic for forbidden messages
+   */
+
   cfe = GNUNET_CONTAINER_multihashmap_get (hash_map, hash_code);
   if ((ELEMENT_MESSAGE == mt) && (cfe != NULL))
   {
@@ -1205,6 +1245,10 @@ update_message_control_flow (struct 
GNUNET_CONTAINER_MultiHashMap *hash_map,
     }
   }
 
+  /**
+   * In case the element hash is not in the hashmap create a new entry
+   */
+
   if (NULL == cfe)
   {
     cfe = GNUNET_new (struct messageControlFlowElement);
@@ -1217,6 +1261,9 @@ update_message_control_flow (struct 
GNUNET_CONTAINER_MultiHashMap *hash_map,
     }
   }
 
+  /**
+   * Set state of message
+   */
 
   if (OFFER_MESSAGE == mt)
   {
@@ -1235,6 +1282,10 @@ update_message_control_flow (struct 
GNUNET_CONTAINER_MultiHashMap *hash_map,
     return GNUNET_SYSERR;
   }
 
+  /**
+   * Check if state is allowed
+   */
+
   if (new_mcfs <= *mcfs)
   {
     return GNUNET_NO;
@@ -1263,6 +1314,10 @@ is_message_in_message_control_flow (struct
 
   cfe = GNUNET_CONTAINER_multihashmap_get (hash_map, hash_code);
 
+  /**
+  * Set state of message
+  */
+
   if (cfe != NULL)
   {
     if (OFFER_MESSAGE == mt)
@@ -1281,6 +1336,10 @@ is_message_in_message_control_flow (struct
     {
       return GNUNET_SYSERR;
     }
+
+    /**
+     * Evaluate if set is in message
+     */
     if (*mcfs != MSG_CFS_UNINITIALIZED)
     {
       return GNUNET_YES;
@@ -1355,6 +1414,10 @@ create_randomized_element_iterator (void *cls,
   struct GNUNET_HashContext *hashed_key_context =
     GNUNET_CRYPTO_hash_context_start ();
   struct GNUNET_HashCode new_key;
+
+  /**
+   * Hash element with new salt to randomize hashmap
+   */
   GNUNET_CRYPTO_hash_context_read (hashed_key_context,
                                    &key,
                                    sizeof(struct IBF_Key));
@@ -1461,11 +1524,19 @@ check_byzantine_bounds (struct Operation *op)
 {
   if (op->byzantine != GNUNET_YES)
     return GNUNET_OK;
+
+  /**
+   * Check  upper byzantine bounds
+   */
   if (op->remote_element_count + op->remote_set_diff >
       op->byzantine_upper_bound)
     return GNUNET_SYSERR;
   if (op->local_element_count + op->local_set_diff > op->byzantine_upper_bound)
     return GNUNET_SYSERR;
+
+  /**
+  * Check lower byzantine bounds
+  */
   if (op->remote_element_count < op->byzantine_lower_bound)
     return GNUNET_SYSERR;
   return GNUNET_OK;
diff --git a/src/setu/ibf.c b/src/setu/ibf.c
index 8cb899a38..7d726236d 100644
--- a/src/setu/ibf.c
+++ b/src/setu/ibf.c
@@ -380,14 +380,25 @@ pack_counter (const struct InvertibleBloomFilter *ibf,
   uint8_t store = 0;
   uint16_t byte_ctr = 0;
 
+  /**
+  * Iterate over IBF bucket
+  */
   for (uint64_t i = start; i< (count + start);)
   {
     uint64_t count_val_to_write = ibf->count[i].count_val;
     uint8_t count_len_to_write = counter_max_length;
 
+    /**
+    * Pack and compose counters to byte values
+    */
     while ((count_len_to_write + store_size) >= 8)
     {
       uint8_t bit_shift = 0;
+
+      /**
+      * Shift bits if more than a byte has to be written
+       * or the store size is not empty
+      */
       if ((store_size > 0) || (count_len_to_write > 8))
       {
         uint8_t bit_unused = 8 - store_size;
@@ -408,6 +419,10 @@ pack_counter (const struct InvertibleBloomFilter *ibf,
     count_len_to_write = 0;
     i++;
   }
+
+  /**
+  * Pack data left in story before finishing
+  */
   if (store_size > 0)
   {
     buf[byte_ctr] = store << (8 - store_size);
@@ -439,17 +454,29 @@ unpack_counter (const struct InvertibleBloomFilter *ibf,
   uint64_t store_bit_ctr = 0;
   uint64_t byte_ctr = 0;
 
-  while (1)
+  /**
+  * Iterate over received bytes
+  */
+  while (true)
   {
     uint8_t byte_read = buf[byte_ctr];
     uint8_t bit_to_read_left = 8;
     byte_ctr++;
+
+    /**
+    * Pack data left in story before finishing
+    */
     while (bit_to_read_left >= 0)
     {
-
+      /**
+      * Stop decoding when end is reached
+      */
       if (ibf_counter_ctr > (count - 1))
         return;
 
+      /*
+       * Unpack the counter
+       */
       if ((store_bit_ctr + bit_to_read_left) >= counter_max_length)
       {
         uint8_t bytes_used = counter_max_length - store_bit_ctr;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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