add set operation options
authorFlorian Dold <florian.dold@gmail.com>
Thu, 23 Feb 2017 14:15:33 +0000 (15:15 +0100)
committerFlorian Dold <florian.dold@gmail.com>
Thu, 23 Feb 2017 16:47:38 +0000 (17:47 +0100)
14 files changed:
src/consensus/gnunet-service-consensus.c
src/dv/gnunet-service-dv.c
src/include/gnunet_protocols.h
src/include/gnunet_set_service.h
src/revocation/gnunet-service-revocation.c
src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
src/scalarproduct/gnunet-service-scalarproduct_alice.c
src/scalarproduct/gnunet-service-scalarproduct_bob.c
src/set/gnunet-set-profiler.c
src/set/set_api.c
src/set/test_set_api.c
src/set/test_set_intersection_result_full.c
src/set/test_set_union_result_symmetric.c

index 16ca6a57f12350cb164567e1fd95f5384bc35e78..4036d2b117b1eeed421e1625fb0e699d45b968d6 100644 (file)
@@ -2013,6 +2013,7 @@ task_start_reconcile (struct TaskEntry *task)
                                     &session->global_id,
                                     &rcm.header,
                                     GNUNET_SET_RESULT_SYMMETRIC,
+                                    (struct GNUNET_SET_Option[]) { 0 },
                                     set_result_cb,
                                     task);
 
@@ -2439,6 +2440,7 @@ set_listen_cb (void *cls,
 
   task->cls.setop.op = GNUNET_SET_accept (request,
                                           GNUNET_SET_RESULT_SYMMETRIC,
+                                          (struct GNUNET_SET_Option[]) { 0 },
                                           set_result_cb,
                                           task);
 
index 6adaa04d9dfe92f916a4587b615656601ee74282..e4b664f4b653f50728bfaa2d807ff65834959d8c 100644 (file)
@@ -1528,6 +1528,7 @@ listen_set_union (void *cls,
                                        GNUNET_SET_OPERATION_UNION);
   neighbor->set_op = GNUNET_SET_accept (request,
                                        GNUNET_SET_RESULT_ADDED,
+                                        (struct GNUNET_SET_Option[]) { 0 },
                                        &handle_set_union_result,
                                        neighbor);
   neighbor->consensus_insertion_offset = 0;
@@ -1558,6 +1559,7 @@ initiate_set_union (void *cls)
                                          &neighbor->real_session_id,
                                          NULL,
                                          GNUNET_SET_RESULT_ADDED,
+                                         (struct GNUNET_SET_Option[]) { 0 },
                                          &handle_set_union_result,
                                          neighbor);
   neighbor->consensus_insertion_offset = 0;
index eeb9a8a92f2e3d9e35ddb53101025aaa436edddf..a10c0ca5d1a8d99eed73caefda55afba724810f8 100644 (file)
@@ -1795,6 +1795,13 @@ extern "C"
  */
 #define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT 596
 
+/**
+ * Request all missing elements from the other peer,
+ * based on their sets and the elements we previously sent
+ * with #GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS.
+ */
+#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_GET_MISSING 597
+
 
 /*******************************************************************************
  * TESTBED LOGGER message types
index 52613ad593ff8a834196375266491678bedaf469..f9b477f47e6250c50593c0edfad75a62566c79bb 100644 (file)
@@ -153,6 +153,7 @@ enum GNUNET_SET_Status
 };
 
 
+
 /**
  * The way results are given to the client.
  */
@@ -211,6 +212,54 @@ struct GNUNET_SET_Element
 };
 
 
+/**
+ * Possible options to pass to a set operation.
+ *
+ * Used as tag for struct #GNUNET_SET_Option.
+ */
+enum GNUNET_SET_OptionType
+{
+  /**
+   * Fail set operations when the other peer shows weird behavior
+   * that might by a Byzantine fault.
+   *
+   * For set union, 'v.num' is a lower bound on elements
+   * that the other peer must have in common with us.
+   */
+  GNUNET_SET_OPTION_BYZANTINE=1,
+  /**
+   * Do not use the optimized set operation, but send full sets.
+   * Might trigger Byzantine fault detection.
+   */
+  GNUNET_SET_OPTION_FORCE_FULL=2,
+  /**
+   * Only use optimized set operations, even though for this
+   * particular set operation they might be much slower.
+   * Might trigger Byzantine fault detection.
+   */
+  GNUNET_SET_OPTION_FORCE_DELTA=4,
+};
+
+
+/**
+ * Option for set operations.
+ */
+struct GNUNET_SET_Option
+{
+  /**
+   * Type of the option.
+   */
+  enum GNUNET_SET_OptionType type;
+
+  /**
+   * Value for the option, only used with some options.
+   */
+  union {
+    uint64_t num;
+  } v;
+};
+
+
 /**
  * Continuation used for some of the set operations
  *
@@ -367,6 +416,7 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer,
                     const struct GNUNET_HashCode *app_id,
                     const struct GNUNET_MessageHeader *context_msg,
                     enum GNUNET_SET_ResultMode result_mode,
+                    struct GNUNET_SET_Option options[],
                     GNUNET_SET_ResultIterator result_cb,
                     void *result_cls);
 
@@ -420,6 +470,7 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh);
 struct GNUNET_SET_OperationHandle *
 GNUNET_SET_accept (struct GNUNET_SET_Request *request,
                    enum GNUNET_SET_ResultMode result_mode,
+                   struct GNUNET_SET_Option options[],
                    GNUNET_SET_ResultIterator result_cb,
                    void *result_cls);
 
index 2965808fa9b1916ce376aa814f0c42edd29b81e0..b5669d9ea8314fbb098cfd470af7054c4bd56bb0 100644 (file)
@@ -509,6 +509,7 @@ transmit_task_cb (void *cls)
                                        &revocation_set_union_app_id,
                                        NULL,
                                        GNUNET_SET_RESULT_ADDED,
+                                       (struct GNUNET_SET_Option[]) { 0 },
                                        &add_revocation,
                                        peer_entry);
   if (GNUNET_OK !=
@@ -755,6 +756,7 @@ handle_revocation_union_request (void *cls,
   }
   peer_entry->so = GNUNET_SET_accept (request,
                                       GNUNET_SET_RESULT_ADDED,
+                                      (struct GNUNET_SET_Option[]) { 0 },
                                       &add_revocation,
                                       peer_entry);
   if (GNUNET_OK !=
index 9f8d98657f50af57cf84bbc32d259ae1a687cfcb..34149435c7cfc5bc0a00357142833b6dfef44c9f 100644 (file)
@@ -788,6 +788,7 @@ cb_intersection_request_alice (void *cls,
   s->intersection_op
     = GNUNET_SET_accept (request,
                          GNUNET_SET_RESULT_REMOVED,
+                         (struct GNUNET_SET_Option[]) { 0 },
                          &cb_intersection_element_removed,
                          s);
   if (NULL == s->intersection_op)
index 7fd69a4ea50c8075282ed0e58f38581c8306e602..db8241bb7b69ca0474715b51d647690ff96cc6f0 100644 (file)
@@ -670,6 +670,7 @@ start_intersection (struct BobServiceSession *s)
                           &set_sid,
                           NULL,
                           GNUNET_SET_RESULT_REMOVED,
+                          (struct GNUNET_SET_Option[]) { 0 },
                           &cb_intersection_element_removed,
                           s);
   if (GNUNET_OK !=
index 779d84b603ef6a87ce83be62ced9802f1fdd7594..f99ff616851c23348090ac7386bfcc733b2c723c 100644 (file)
@@ -1022,6 +1022,7 @@ cb_intersection_request_alice (void *cls,
   s->intersection_op
     = GNUNET_SET_accept (request,
                          GNUNET_SET_RESULT_REMOVED,
+                         (struct GNUNET_SET_Option[]) { 0 },
                          &cb_intersection_element_removed,
                          s);
   if (NULL == s->intersection_op)
index a2bceba43f4db9c19867758dbfd314ab92971ab1..4da2ba50e43b950d9082786becbbb0784d2a47a8 100644 (file)
@@ -964,6 +964,7 @@ start_intersection (struct BobServiceSession *s)
                           &s->session_id,
                           NULL,
                           GNUNET_SET_RESULT_REMOVED,
+                          (struct GNUNET_SET_Option[]) { 0 },
                           &cb_intersection_element_removed,
                           s);
   if (GNUNET_OK !=
index f89817ff57da9dbbe7c7be9d19c56db18766c77e..22a9d85cff099fe17147aa6281f2c2307148a00f 100644 (file)
@@ -225,7 +225,8 @@ set_listen_cb (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "set listen cb called\n");
   info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_SYMMETRIC,
-                               set_result_cb, &info2);
+                                (struct GNUNET_SET_Option[]) { 0 },
+                                set_result_cb, &info2);
   GNUNET_SET_commit (info2.oh, info2.set);
 }
 
@@ -352,6 +353,7 @@ run (void *cls,
 
   info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL,
                                  GNUNET_SET_RESULT_SYMMETRIC,
+                                 (struct GNUNET_SET_Option[]) { 0 },
                                  set_result_cb, &info1);
   GNUNET_SET_commit (info1.oh, info1.set);
   GNUNET_SET_destroy (info1.set);
index baeee6da0feec62bff7203b0c7765124646d69b9..c2e2cd1e96544b71337d1aa4c78300938d8c3cd5 100644 (file)
@@ -766,6 +766,7 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer,
                     const struct GNUNET_HashCode *app_id,
                     const struct GNUNET_MessageHeader *context_msg,
                     enum GNUNET_SET_ResultMode result_mode,
+                    struct GNUNET_SET_Option options[],
                     GNUNET_SET_ResultIterator result_cb,
                     void *result_cls)
 {
@@ -1006,6 +1007,7 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh)
 struct GNUNET_SET_OperationHandle *
 GNUNET_SET_accept (struct GNUNET_SET_Request *request,
                    enum GNUNET_SET_ResultMode result_mode,
+                   struct GNUNET_SET_Option options[],
                    GNUNET_SET_ResultIterator result_cb,
                    void *result_cls)
 {
index 21af45f8ac5f002433be6a3e5130f047de36a791..4bc6bd1c3ace06538b13fdc7cda95d4603077461 100644 (file)
@@ -149,6 +149,7 @@ listen_cb (void *cls,
   listen_handle = NULL;
   oh2 = GNUNET_SET_accept (request,
                            GNUNET_SET_RESULT_ADDED,
+                           (struct GNUNET_SET_Option[]) { 0 },
                            &result_cb_set2,
                            NULL);
   GNUNET_SET_commit (oh2,
@@ -179,6 +180,7 @@ start (void *cls)
                             &app_id,
                             &context_msg,
                             GNUNET_SET_RESULT_ADDED,
+                            (struct GNUNET_SET_Option[]) { 0 },
                             &result_cb_set1,
                             NULL);
   GNUNET_SET_commit (oh1,
@@ -378,6 +380,7 @@ run (void *cls,
                               &app_id,
                               NULL,
                               GNUNET_SET_RESULT_ADDED,
+                              (struct GNUNET_SET_Option[]) { 0 },
                               NULL,
                               NULL);
 
index b2d6ce8a96b1d11f574cdf481a811313eca24b64..cbe1ce1492ec1655630f70dfc61951f95917a336 100644 (file)
@@ -133,6 +133,7 @@ listen_cb (void *cls,
   listen_handle = NULL;
   oh2 = GNUNET_SET_accept (request,
                            GNUNET_SET_RESULT_FULL,
+                           (struct GNUNET_SET_Option[]) { 0 },
                            &result_cb_set2,
                            NULL);
   GNUNET_SET_commit (oh2,
@@ -163,6 +164,7 @@ start (void *cls)
                             &app_id,
                             &context_msg,
                             GNUNET_SET_RESULT_FULL,
+                            (struct GNUNET_SET_Option[]) { 0 },
                             &result_cb_set1,
                             NULL);
   GNUNET_SET_commit (oh1,
index ab191a34a8408de8afdb7ca46cb075f9bf299f09..8dff40ec0e317c49c6e8535ea944ec0c6b636ac2 100644 (file)
@@ -184,6 +184,7 @@ listen_cb (void *cls,
   listen_handle = NULL;
   oh2 = GNUNET_SET_accept (request,
                            GNUNET_SET_RESULT_SYMMETRIC,
+                           (struct GNUNET_SET_Option[]) { 0 },
                            &result_cb_set2,
                            NULL);
   GNUNET_SET_commit (oh2,
@@ -212,6 +213,7 @@ start (void *cls)
                             &app_id,
                             &context_msg,
                             GNUNET_SET_RESULT_SYMMETRIC,
+                            (struct GNUNET_SET_Option[]) { 0 },
                             &result_cb_set1, NULL);
   GNUNET_SET_commit (oh1, set1);
 }