improve logging, indentation
[oweals/gnunet.git] / src / set / gnunet-service-set.h
index fb079d03feec7ffdea7499b2abf90ada8f759df5..86313d17966c4182023f56ac51d807129e0bfa2a 100644 (file)
@@ -1,6 +1,6 @@
 /*
       This file is part of GNUnet
-      Copyright (C) 2013, 2014 Christian Grothoff (and other contributing authors)
+      Copyright (C) 2013, 2014 GNUnet e.V.
 
       GNUnet is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published
@@ -119,6 +119,30 @@ struct OperationSpecification
    * When are elements sent to the client, and which elements are sent?
    */
   enum GNUNET_SET_ResultMode result_mode;
+
+  /**
+   * Always use delta operation instead of sending full sets,
+   * even it it's less efficient.
+   */
+  int force_delta;
+
+  /**
+   * Always send full sets, even if delta operations would
+   * be more efficient.
+   */
+  int force_full;
+
+  /**
+   * #GNUNET_YES to fail operations where Byzantine faults
+   * are suspected
+   */
+  int byzantine;
+
+  /**
+   * Lower bound for the set size, used only when
+   * byzantine mode is enabled.
+   */
+  int byzantine_lower_bound;
 };
 
 
@@ -126,7 +150,7 @@ struct OperationSpecification
  * Signature of functions that create the implementation-specific
  * state for a set supporting a specific operation.
  *
- * @return a set state specific to the supported operation
+ * @return a set state specific to the supported operation, NULL on error
  */
 typedef struct SetState *
 (*CreateImpl) (void);
@@ -188,20 +212,6 @@ typedef void
                    const struct GNUNET_MessageHeader *opaque_context);
 
 
-/**
- * Signature of functions that implement the message handling for
- * the different set operations.
- *
- * @param op operation state
- * @param msg received message
- * @return #GNUNET_OK on success, #GNUNET_SYSERR to
- *         destroy the operation and the tunnel
- */
-typedef int
-(*MsgHandlerImpl) (struct Operation *op,
-                   const struct GNUNET_MessageHeader *msg);
-
-
 /**
  * Signature of functions that implement operation cancellation
  *
@@ -251,11 +261,6 @@ struct SetVT
    */
   DestroySetImpl destroy_set;
 
-  /**
-   * Callback for handling operation-specific messages.
-   */
-  MsgHandlerImpl msg_handler;
-
   /**
    * Callback for handling the remote peer's disconnect.
    */
@@ -323,6 +328,9 @@ struct ElementEntry
    */
   struct MutationEvent *mutations;
 
+  /**
+   * Number of elements in the array @a mutations.
+   */
   unsigned int mutations_size;
 
   /**
@@ -333,6 +341,9 @@ struct ElementEntry
 };
 
 
+struct Listener;
+
+
 /**
  * Operation context used to execute a set operation.
  */
@@ -350,6 +361,11 @@ struct Operation
    */
   struct GNUNET_CADET_Channel *channel;
 
+  /**
+   * Port this operation runs on.
+   */
+  struct Listener *listener;
+
   /**
    * Message queue for the channel.
    */
@@ -391,6 +407,11 @@ struct Operation
    */
   struct GNUNET_SCHEDULER_Task *timeout_task;
 
+  /**
+   * The type of the operation.
+   */
+  enum GNUNET_SET_OperationType operation;
+
   /**
    * 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
@@ -482,8 +503,8 @@ struct PendingMutation
 
   /**
    * Message that describes the desired mutation.
-   * May only be a GNUNET_MESSAGE_TYPE_SET_ADD or
-   * GNUNET_MESSAGE_TYPE_SET_REMOVE.
+   * May only be a #GNUNET_MESSAGE_TYPE_SET_ADD or
+   * #GNUNET_MESSAGE_TYPE_SET_REMOVE.
    */
   struct GNUNET_MessageHeader *mutation_message;
 };
@@ -509,7 +530,7 @@ struct Set
    * Client that owns the set.  Only one client may own a set,
    * and there can only be one set per client.
    */
-  struct GNUNET_SERVER_Client *client;
+  struct GNUNET_SERVICE_Client *client;
 
   /**
    * Message queue for the client.
@@ -557,6 +578,9 @@ struct Set
    */
   struct GenerationRange *excluded_generations;
 
+  /**
+   * Number of elements in array @a excluded_generations.
+   */
   unsigned int excluded_generations_size;
 
   /**
@@ -570,6 +594,11 @@ struct Set
    */
   uint16_t iteration_id;
 
+  /**
+   * Generation we're currently iteration over.
+   */
+  unsigned int iter_generation;
+
   /**
    * Content, possibly shared by multiple sets,
    * and thus reference counted.
@@ -578,6 +607,9 @@ struct Set
 };
 
 
+extern struct GNUNET_STATISTICS_Handle *_GSS_statistics;
+
+
 /**
  * Destroy the given operation.  Call the implementation-specific
  * cancel function of the operation.  Disconnects from the remote