-fixing misc issues and bugs, including better termination logic for intersection...
[oweals/gnunet.git] / src / set / gnunet-service-set.h
index b92eb47ff1bb61cbfd9b75d3bc6c160ced2e13ee..ab81558834e8a83e3997c106f20e4b386de23c2d 100644 (file)
@@ -1,6 +1,6 @@
 /*
       This file is part of GNUnet
-      (C) 2013 Christian Grothoff (and other contributing authors)
+      (C) 2013, 2014 Christian Grothoff (and other contributing authors)
 
       GNUnet is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published
@@ -17,7 +17,6 @@
       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       Boston, MA 02111-1307, USA.
 */
-
 /**
  * @file set/gnunet-service-set.h
  * @brief common components for the implementation the different set operations
@@ -166,13 +165,27 @@ typedef void
 
 
 /**
- * Signature of functions that implement the creation of set operations
- * (currently "evaluate" and "accept").
+ * Signature of functions that implement accepting a set operation.
+ *
+ * @param op operation that is created by accepting the operation,
+ *        should be initialized by the implementation
+ */
+typedef void
+(*OpAcceptImpl) (struct Operation *op);
+
+
+/**
+ * Signature of functions that implement starting the evaluation of
+ * set operations.
  *
- * @param op operation that is created, should be initialized by the implementation
+ * @param op operation that is created, should be initialized to
+ *        begin the evaluation
+ * @param opaque_context message to be transmitted to the listener
+ *        to convince him to accept, may be NULL
  */
 typedef void
-(*OpCreateImpl) (struct Operation *op);
+(*OpEvaluateImpl) (struct Operation *op,
+                   const struct GNUNET_MessageHeader *opaque_context);
 
 
 /**
@@ -222,12 +235,12 @@ struct SetVT
   /**
    * Callback for accepting a set operation request
    */
-  OpCreateImpl accept;
+  OpAcceptImpl accept;
 
   /**
    * Callback for starting evaluation with a remote peer.
    */
-  OpCreateImpl evaluate;
+  OpEvaluateImpl evaluate;
 
   /**
    * Callback for destruction of the set state.
@@ -327,7 +340,9 @@ struct Operation
   struct OperationSpecification *spec;
 
   /**
-   * Operation-specific operation state.
+   * Operation-specific operation state.  Note that the exact
+   * type depends on this being a union or intersection operation
+   * (and thus on @e vt).
    */
   struct OperationState *state;
 
@@ -341,6 +356,25 @@ struct Operation
    */
   struct Operation *prev;
 
+  /**
+   * The identity of the requesting peer.  Needs to
+   * be stored here as the op spec might not have been created yet.
+   */
+  struct GNUNET_PeerIdentity peer;
+
+  /**
+   * Timeout task, if the incoming peer has not been accepted
+   * after the timeout, it will be disconnected.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+
+  /**
+   * Unique request id for the request from a remote peer, sent to the
+   * client, which will accept or reject the request.  Set to '0' iff
+   * the request has not been suggested yet.
+   */
+  uint32_t suggest_id;
+
   /**
    * #GNUNET_YES if this is not a "real" set operation yet, and we still
    * need to wait for the other peer to give us more details.
@@ -434,6 +468,12 @@ struct Set
    */
   enum GNUNET_SET_OperationType operation;
 
+  /**
+   * Each @e iter is assigned a unique number, so that the client
+   * can distinguish iterations.
+   */
+  uint16_t iteration_id;
+
 };
 
 
@@ -444,9 +484,11 @@ struct Set
  * operations per set.
  *
  * @param op operation to destroy
+ * @param gc #GNUNET_YES to perform garbage collection on the set
  */
 void
-_GSS_operation_destroy (struct Operation *op);
+_GSS_operation_destroy (struct Operation *op,
+                        int gc);
 
 
 /**