GNUnet  0.11.x
rps-sampler_client.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_CLIENT_H
28 #define RPS_SAMPLER_CLIENT_H
29 #include <inttypes.h>
30 #include "rps-sampler_common.h"
31 
32 
36 struct RPS_Sampler;
37 
42 
47 
48 
55 unsigned int
57 
58 
65 void
66 RPS_sampler_resize (struct RPS_Sampler *sampler, unsigned int new_size);
67 
68 
76 struct RPS_Sampler *
77 RPS_sampler_mod_init (size_t init_size,
79 
80 
87 void
88 RPS_sampler_update (struct RPS_Sampler *sampler,
89  const struct GNUNET_PeerIdentity *id);
90 
91 
101 void
103  const struct GNUNET_PeerIdentity *id);
104 
105 
120  uint32_t num_peers,
122  void *cls);
123 
124 
130 void
132 
133 
142 uint32_t
144  const struct GNUNET_PeerIdentity *id);
145 
146 
152 void
154 
155 #endif /* RPS_SAMPLER_CLIENT_H */
156 /* end of gnunet-service-rps.c */
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.
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.
void * cls
Closure given to the callback.
void RPS_sampler_destroy(struct RPS_Sampler *sampler)
Cleans the samplers.
Code common to client and service sampler.
struct GNUNET_TIME_Relative max_round_interval
Maximum time a round takes.
Closure to _get_n_rand_peers_ready_cb()
struct RPS_Sampler * sampler
Sampler.
static struct GNUNET_RPS_Request_Handle * req_handle
Request handle.
Definition: gnunet-rps.c:41
unsigned int RPS_sampler_get_size(struct RPS_Sampler *sampler)
Get the size of the sampler.
Closure to _get_rand_peer_info()
struct RPS_Sampler * RPS_sampler_mod_init(size_t init_size, struct GNUNET_TIME_Relative max_round_interval)
Initialise a modified tuple of sampler elements.
void RPS_sampler_update(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Update every sampler element of this sampler with given peer.
static unsigned int num_peers
The identity of the host (wraps the signing key of the peer).
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.
uint32_t RPS_sampler_count_id(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Counts how many Samplers currently hold a given PeerID.
void RPS_sampler_request_cancel(struct RPS_SamplerRequestHandle *req_handle)
Cancle a request issued through RPS_sampler_n_rand_peers_ready_cb.
Sampler with its own array of SamplerElements.
void RPS_sampler_resize(struct RPS_Sampler *sampler, unsigned int new_size)
Grow or shrink the size of the sampler.
Time for relative time used by GNUnet, in microseconds.
struct RPS_Sampler * sampler
Sampler.