GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
#define GNUNET_SERVICE_SET_H_PRIVATE
#include "platform.h"
-#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_applications.h"
-#include "gnunet_util_lib.h"
#include "gnunet_core_service.h"
#include "gnunet_mesh_service.h"
#include "gnunet_set_service.h"
/* forward declarations */
struct Set;
struct TunnelContext;
+struct ElementEntry;
/**
};
+
+
/**
* Signature of functions that create the implementation-specific
* state for a set supporting a specific operation.
* @param set implementation-specific set state
* @param msg element message from the client
*/
-typedef void (*AddRemoveImpl) (struct SetState *state, const struct GNUNET_SET_Element *element);
+typedef void (*AddRemoveImpl) (struct SetState *state, struct ElementEntry *ee);
/**
};
+/**
+ * Information about an element element in the set.
+ * All elements are stored in a hash-table
+ * from their hash-code to their 'struct Element',
+ * so that the remove and add operations are reasonably
+ * fast.
+ */
+struct ElementEntry
+{
+ /**
+ * The actual element. The data for the element
+ * should be allocated at the end of this struct.
+ */
+ struct GNUNET_SET_Element element;
+
+ /**
+ * Hash of the element.
+ * Will be used to derive the different IBF keys
+ * for different salts.
+ */
+ struct GNUNET_HashCode element_hash;
+
+ /**
+ * Generation the element was added by the client.
+ * Operations of earlier generations will not consider the element.
+ */
+ unsigned int generation_added;
+
+ /**
+ * GNUNET_YES if the element has been removed in some generation.
+ */
+ int removed;
+
+ /**
+ * Generation the element was removed by the client.
+ * Operations of later generations will not consider the element.
+ * Only valid if is_removed is GNUNET_YES.
+ */
+ unsigned int generation_removed;
+
+ /**
+ * GNUNET_YES if the element is a remote element, and does not belong
+ * to the operation's set.
+ */
+ int remote;
+};
+
+
/**
* A set that supports a specific operation
* with other peers.
* Implementation-specific state.
*/
struct SetState *state;
+
+ /**
+ * Current state of iterating elements for the client.
+ * NULL if we are not currently iterating.
+ */
+ struct GNUNET_CONTAINER_MultiHashMapIterator *iter;
+
+ /**
+ * Maps 'struct GNUNET_HashCode' to 'struct ElementEntry'.
+ */
+ struct GNUNET_CONTAINER_MultiHashMap *elements;
+
+ /**
+ * Current generation, that is, number of
+ * previously executed operations on this set
+ */
+ unsigned int current_generation;
};