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.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @file rps/gnunet-service-rps_sampler_elem.h
21 * @brief sampler element implementation
22 * @author Julius Bünger
25 #ifndef RPS_SAMPLER_ELEM_H
26 #define RPS_SAMPLER_ELEM_H
30 /***********************************************************************
31 * WARNING: This section needs to be reviewed regarding the use of
32 * functions providing (pseudo)randomness!
33 ***********************************************************************/
36 * Used to indicate whether a sampler element is empty.
45 * A sampler element sampling one PeerID at a time.
47 struct RPS_SamplerElement
50 * Min-wise linear permutation used by this sampler.
52 * This is an key later used by a hmac.
54 struct GNUNET_CRYPTO_AuthKey auth_key;
57 * The PeerID this sampler currently samples.
59 struct GNUNET_PeerIdentity peer_id;
62 * The according hash value of this PeerID.
64 struct GNUNET_HashCode peer_id_hash;
68 * Time of last request.
70 struct GNUNET_TIME_Absolute last_client_request;
73 * Flag that indicates that we are not holding a valid PeerID right now.
75 enum RPS_SamplerEmpty is_empty;
80 struct GNUNET_TIME_Absolute birth;
83 * How many times a PeerID was put in this sampler.
88 * How many times this sampler changed the peer_id.
93 * The file name this sampler element should log to
100 * Reinitialise a previously initialised sampler element.
102 * @param sampler pointer to the memory that keeps the value.
105 RPS_sampler_elem_reinit (struct RPS_SamplerElement *sampler_el);
109 * Create a sampler element and initialise it.
111 * In this implementation this means choosing an auth_key for later use in
114 * @return a newly created RPS_SamplerElement which currently holds no id.
116 struct RPS_SamplerElement *
117 RPS_sampler_elem_create (void);
121 * Destroy a sampler element.
123 * @param sampler_elem the element to destroy
126 RPS_sampler_elem_destroy (struct RPS_SamplerElement *sampler_elem);
130 * Input an PeerID into the given sampler element.
132 * @param sampler the sampler the @a s_elem belongs to.
136 RPS_sampler_elem_next (struct RPS_SamplerElement *s_elem,
137 const struct GNUNET_PeerIdentity *new_ID);
140 * Initialise the min-wise independent function of the given sampler element.
142 * @param s_elem the sampler element
143 * @param auth_key the key to use
146 RPS_sampler_elem_set (struct RPS_SamplerElement *s_elem,
147 struct GNUNET_CRYPTO_AuthKey auth_key);
150 #endif /* RPS_SAMPLER_ELEM_H */
151 /* end of gnunet-service-rps.c */