set api changes
authorFlorian Dold <florian.dold@gmail.com>
Tue, 22 Sep 2015 01:47:36 +0000 (01:47 +0000)
committerFlorian Dold <florian.dold@gmail.com>
Tue, 22 Sep 2015 01:47:36 +0000 (01:47 +0000)
src/include/gnunet_set_service.h
src/set/gnunet-service-set_union.c
src/set/gnunet-set-profiler.c
src/set/set_api.c

index 1000aea7b189b1b61f968b43903a0214644c4b46..f9ae122b445fc5c17ec5b95f422598211528b8d6 100644 (file)
@@ -99,9 +99,32 @@ enum GNUNET_SET_Status
    * Everything went ok, we are transmitting an element of the
    * result (in set, or to be removed from set, depending on
    * the `enum GNUNET_SET_ResultMode`).
+   *
+   * Only applies to
+   * #GNUNET_SET_RESULT_FULL,
+   * #GNUNET_SET_RESULT_ADDED,
+   * #GNUNET_SET_RESULT_REMOVED,
    */
   GNUNET_SET_STATUS_OK,
 
+  /**
+   * Element should be added to the result set
+   * of the local peer, i.e. the local peer is
+   * missing an element.
+   *
+   * Only applies to #GNUNET_SET_RESULT_SYMMETRIC
+   */
+  GNUNET_SET_STATUS_ADD_LOCAL,
+
+  /**
+   * Element should be added to the result set
+   * of the remove peer, i.e. the remote peer is
+   * missing an element.
+   *
+   * Only applies to #GNUNET_SET_RESULT_SYMMETRIC
+   */
+  GNUNET_SET_STATUS_ADD_REMOTE,
+
   /**
    * The other peer refused to to the operation with us,
    * or something went wrong.
@@ -129,20 +152,32 @@ enum GNUNET_SET_ResultMode
 {
   /**
    * Client gets every element in the resulting set.
+   *
+   * Only supported for set intersection.
    */
   GNUNET_SET_RESULT_FULL,
 
   /**
-   * Client gets only elements that have been added to the set.
-   * Only works with set union.
+   * Client gets notified of the required changes
+   * for both the local and the remote set.
+   *
+   * Only supported for set 
+   */
+  GNUNET_SET_RESULT_SYMMETRIC,
+
+  /**
+   * Client gets only elements that have been removed from the set.
+   *
+   * Only supported for set intersection.
    */
-  GNUNET_SET_RESULT_ADDED,
+  GNUNET_SET_RESULT_REMOVED,
 
   /**
    * Client gets only elements that have been removed from the set.
-   * Only works with set intersection.
+   *
+   * Only supported for set union.
    */
-  GNUNET_SET_RESULT_REMOVED
+  GNUNET_SET_RESULT_ADDED
 };
 
 
index 5975ef19f3f600b566fe86d7c53487917eb58ba6..5b452cae1598fd5ef3099065a71d69fdba174db7 100644 (file)
@@ -1003,7 +1003,12 @@ send_client_element (struct Operation *op,
     GNUNET_break (0);
     return;
   }
-  rm->result_status = htons (GNUNET_SET_STATUS_OK);
+
+  if (GNUNET_SET_RESULT_ADDED == op->spec->result_mode)
+    rm->result_status = htons (GNUNET_SET_STATUS_OK);
+  else if (GNUNET_SET_RESULT_SYMMETRIC == op->spec->result_mode)
+    rm->result_status = htons (GNUNET_SET_STATUS_ADD_LOCAL);
+
   rm->request_id = htonl (op->spec->client_request_id);
   rm->element_type = element->element_type;
   memcpy (&rm[1], element->data, element->size);
@@ -1167,7 +1172,7 @@ handle_p2p_elements (void *cls,
 
   op_register_element (op, ee);
   /* only send results immediately if the client wants it */
-  if (GNUNET_SET_RESULT_ADDED == op->spec->result_mode)
+  if (GNUNET_SET_RESULT_FULL != op->spec->result_mode)
     send_client_element (op, &ee->element);
 }
 
index 286cc6fb35d505f8a1677736b9b9aaf387ebd80f..1569c29b7e5d894df78d7fda6f28f60a48d319f8 100644 (file)
@@ -150,7 +150,7 @@ set_listen_cb (void *cls,
   GNUNET_assert (NULL == info2.oh);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "set listen cb called\n");
-  info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_ADDED,
+  info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_SYMMETRIC,
                                set_result_cb, &info2);
   GNUNET_SET_commit (info2.oh, info2.set);
 }
@@ -273,7 +273,7 @@ run (void *cls, char *const *args, const char *cfgfile,
                                     &app_id, set_listen_cb, NULL);
 
   info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL,
-                                 GNUNET_SET_RESULT_ADDED,
+                                 GNUNET_SET_RESULT_SYMMETRIC,
                                  set_result_cb, &info1);
   GNUNET_SET_commit (info1.oh, info1.set);
   GNUNET_SET_destroy (info1.set);
index 920571a01877da9ebf2663710cce511cadbd9a1a..51a494d7fe92d23204fbd9368ce55e968c397a4b 100644 (file)
@@ -417,6 +417,8 @@ handle_result (void *cls,
     switch (result_status)
     {
     case GNUNET_SET_STATUS_OK:
+    case GNUNET_SET_STATUS_ADD_LOCAL:
+    case GNUNET_SET_STATUS_ADD_REMOTE:
       break;
     case GNUNET_SET_STATUS_FAILURE:
       oh->result_cb = NULL;