2 This file is part of GNUnet.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
17 * @file rps/gnunet-service-rps_sampler_elem.h
18 * @brief sampler element implementation
19 * @author Julius Bünger
22 #ifndef RPS_SAMPLER_ELEM_H
23 #define RPS_SAMPLER_ELEM_H
27 /***********************************************************************
28 * WARNING: This section needs to be reviewed regarding the use of
29 * functions providing (pseudo)randomness!
30 ***********************************************************************/
33 * Used to indicate whether a sampler element is empty.
42 * A sampler element sampling one PeerID at a time.
44 struct RPS_SamplerElement
47 * Min-wise linear permutation used by this sampler.
49 * This is an key later used by a hmac.
51 struct GNUNET_CRYPTO_AuthKey auth_key;
54 * The PeerID this sampler currently samples.
56 struct GNUNET_PeerIdentity peer_id;
59 * The according hash value of this PeerID.
61 struct GNUNET_HashCode peer_id_hash;
65 * Time of last request.
67 struct GNUNET_TIME_Absolute last_client_request;
70 * Flag that indicates that we are not holding a valid PeerID right now.
72 enum RPS_SamplerEmpty is_empty;
77 struct GNUNET_TIME_Absolute birth;
80 * How many times a PeerID was put in this sampler.
85 * How many times this sampler changed the peer_id.
90 * The file name this sampler element should log to
97 * Reinitialise a previously initialised sampler element.
99 * @param sampler pointer to the memory that keeps the value.
102 RPS_sampler_elem_reinit (struct RPS_SamplerElement *sampler_el);
106 * Create a sampler element and initialise it.
108 * In this implementation this means choosing an auth_key for later use in
111 * @return a newly created RPS_SamplerElement which currently holds no id.
113 struct RPS_SamplerElement *
114 RPS_sampler_elem_create (void);
118 * Destroy a sampler element.
120 * @param sampler_elem the element to destroy
123 RPS_sampler_elem_destroy (struct RPS_SamplerElement *sampler_elem);
127 * Input an PeerID into the given sampler element.
129 * @param sampler the sampler the @a s_elem belongs to.
133 RPS_sampler_elem_next (struct RPS_SamplerElement *s_elem,
134 const struct GNUNET_PeerIdentity *new_ID);
137 * Initialise the min-wise independent function of the given sampler element.
139 * @param s_elem the sampler element
140 * @param auth_key the key to use
143 RPS_sampler_elem_set (struct RPS_SamplerElement *s_elem,
144 struct GNUNET_CRYPTO_AuthKey auth_key);
147 #endif /* RPS_SAMPLER_ELEM_H */
148 /* end of gnunet-service-rps.c */