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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file rps/gnunet-service-rps_sampler_elem.h
23 * @brief sampler element implementation
24 * @author Julius Bünger
27 #ifndef RPS_SAMPLER_ELEM_H
28 #define RPS_SAMPLER_ELEM_H
32 /***********************************************************************
33 * WARNING: This section needs to be reviewed regarding the use of
34 * functions providing (pseudo)randomness!
35 ***********************************************************************/
38 * Used to indicate whether a sampler element is empty.
47 * A sampler element sampling one PeerID at a time.
49 struct RPS_SamplerElement
52 * Min-wise linear permutation used by this sampler.
54 * This is an key later used by a hmac.
56 struct GNUNET_CRYPTO_AuthKey auth_key;
59 * The PeerID this sampler currently samples.
61 struct GNUNET_PeerIdentity peer_id;
64 * The according hash value of this PeerID.
66 struct GNUNET_HashCode peer_id_hash;
70 * Time of last request.
72 struct GNUNET_TIME_Absolute last_client_request;
75 * Flag that indicates that we are not holding a valid PeerID right now.
77 enum RPS_SamplerEmpty is_empty;
82 struct GNUNET_TIME_Absolute birth;
85 * How many times a PeerID was put in this sampler.
90 * How many times this sampler changed the peer_id.
95 * The file name this sampler element should log to
102 * Reinitialise a previously initialised sampler element.
104 * @param sampler_el The sampler element to (re-) initialise
107 RPS_sampler_elem_reinit (struct RPS_SamplerElement *sampler_elem);
111 * Create a sampler element and initialise it.
113 * In this implementation this means choosing an auth_key for later use in
116 * @return a newly created RPS_SamplerElement which currently holds no id.
118 struct RPS_SamplerElement *
119 RPS_sampler_elem_create (void);
123 * Destroy a sampler element.
125 * @param sampler_elem the element to destroy
128 RPS_sampler_elem_destroy (struct RPS_SamplerElement *sampler_elem);
132 * Update a sampler element with a PeerID
134 * @param sampler_elem The sampler element to update
135 * @param new_ID The PeerID to update with
138 RPS_sampler_elem_next (struct RPS_SamplerElement *sampler_elem,
139 const struct GNUNET_PeerIdentity *new_ID);
142 * Set the min-wise independent function of the given sampler element.
144 * @param sampler_elem the sampler element
145 * @param auth_key the key to use
148 RPS_sampler_elem_set (struct RPS_SamplerElement *sampler_elem,
149 struct GNUNET_CRYPTO_AuthKey auth_key);
152 #endif /* RPS_SAMPLER_ELEM_H */
153 /* end of gnunet-service-rps.c */