GNUnet 0.22.2
gnunet-service-rps_sampler.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C)
4
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.
9
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.
14
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/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
27#ifndef RPS_SAMPLER_H
28#define RPS_SAMPLER_H
29#include <inttypes.h>
30#include "rps-sampler_common.h"
31
32
36struct RPS_Sampler;
37
42
43
50unsigned int
52
53
60void
61RPS_sampler_resize (struct RPS_Sampler *sampler, unsigned int new_size);
62
63
71struct RPS_Sampler *
72RPS_sampler_init (size_t init_size,
74
75
82void
83RPS_sampler_update (struct RPS_Sampler *sampler,
84 const struct GNUNET_PeerIdentity *id);
85
86
102void
104 const struct GNUNET_PeerIdentity *id);
105
106
123 uint32_t num_peers,
125 void *cls);
126
132void
134
135
143uint32_t
145 const struct GNUNET_PeerIdentity *id);
146
147
153void
155
156#endif
157/* end of gnunet-service-rps.c */
static struct GNUNET_RPS_Request_Handle * req_handle
Request handle.
Definition: gnunet-rps.c:41
void RPS_sampler_update(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Update every sampler element of this sampler with given peer.
struct RPS_Sampler * RPS_sampler_init(size_t init_size, struct GNUNET_TIME_Relative max_round_interval)
Initialise a tuple of samplers.
void RPS_sampler_reinitialise_by_value(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Reinitialise all previously initialised sampler elements with the given value.
void RPS_sampler_resize(struct RPS_Sampler *sampler, unsigned int new_size)
Grow or shrink the size of the sampler.
void RPS_sampler_request_cancel(struct RPS_SamplerRequestHandle *req_handle)
Cancel a request issued through RPS_sampler_n_rand_peers_ready_cb.
void RPS_sampler_destroy(struct RPS_Sampler *sampler)
Cleans the samplers.
unsigned int RPS_sampler_get_size(struct RPS_Sampler *sampler)
Get the size of the sampler.
struct RPS_SamplerRequestHandle * RPS_sampler_get_n_rand_peers(struct RPS_Sampler *sampler, uint32_t num_peers, RPS_sampler_n_rand_peers_ready_cb cb, void *cls)
Get n random peers out of the sampled peers.
uint32_t RPS_sampler_count_id(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Counts how many Samplers currently hold a given PeerID.
static unsigned int num_peers
Number of peers.
Code common to client and service sampler.
void(* RPS_sampler_n_rand_peers_ready_cb)(const struct GNUNET_PeerIdentity *ids, uint32_t num_peers, void *cls)
Callback that is called from _get_n_rand_peers() when the PeerIDs are ready.
The identity of the host (wraps the signing key of the peer).
Time for relative time used by GNUnet, in microseconds.
Closure to _get_n_rand_peers_ready_cb()
struct RPS_Sampler * sampler
Sampler.
void * cls
Closure given to the callback.
Sampler with its own array of SamplerElements.
struct GNUNET_TIME_Relative max_round_interval
Maximum time a round takes.