diff options
Diffstat (limited to 'src/rps/rps-sampler_common.h')
-rw-r--r-- | src/rps/rps-sampler_common.h | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/src/rps/rps-sampler_common.h b/src/rps/rps-sampler_common.h index 321efaf1e..4a45c0193 100644 --- a/src/rps/rps-sampler_common.h +++ b/src/rps/rps-sampler_common.h | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file rps/rps-sampler_common.h | 22 | * @file rps/rps-sampler_common.h |
@@ -69,7 +69,7 @@ typedef void | |||
69 | * @param ids the PeerIDs that were returned | 69 | * @param ids the PeerIDs that were returned |
70 | * to be freed | 70 | * to be freed |
71 | */ | 71 | */ |
72 | typedef void | 72 | typedef void |
73 | (*RPS_sampler_n_rand_peers_ready_cb) (const struct GNUNET_PeerIdentity *ids, | 73 | (*RPS_sampler_n_rand_peers_ready_cb) (const struct GNUNET_PeerIdentity *ids, |
74 | uint32_t num_peers, | 74 | uint32_t num_peers, |
75 | void *cls); | 75 | void *cls); |
@@ -84,7 +84,7 @@ typedef void | |||
84 | * @param ids the PeerIDs that were returned | 84 | * @param ids the PeerIDs that were returned |
85 | * to be freed | 85 | * to be freed |
86 | */ | 86 | */ |
87 | typedef void | 87 | typedef void |
88 | (*RPS_sampler_sinlge_info_ready_cb) (const struct GNUNET_PeerIdentity *ids, | 88 | (*RPS_sampler_sinlge_info_ready_cb) (const struct GNUNET_PeerIdentity *ids, |
89 | void *cls, | 89 | void *cls, |
90 | double probability, | 90 | double probability, |
@@ -103,8 +103,7 @@ typedef void | |||
103 | /** | 103 | /** |
104 | * Closure for #sampler_mod_get_rand_peer() and #sampler_get_rand_peer | 104 | * Closure for #sampler_mod_get_rand_peer() and #sampler_get_rand_peer |
105 | */ | 105 | */ |
106 | struct GetPeerCls | 106 | struct GetPeerCls { |
107 | { | ||
108 | /** | 107 | /** |
109 | * DLL | 108 | * DLL |
110 | */ | 109 | */ |
@@ -151,8 +150,7 @@ struct GetPeerCls | |||
151 | /** | 150 | /** |
152 | * Sampler with its own array of SamplerElements | 151 | * Sampler with its own array of SamplerElements |
153 | */ | 152 | */ |
154 | struct RPS_Sampler | 153 | struct RPS_Sampler { |
155 | { | ||
156 | /** | 154 | /** |
157 | * Number of sampler elements we hold. | 155 | * Number of sampler elements we hold. |
158 | */ | 156 | */ |
@@ -222,8 +220,8 @@ struct RPS_Sampler | |||
222 | * @param num_peers The estimated value | 220 | * @param num_peers The estimated value |
223 | */ | 221 | */ |
224 | void | 222 | void |
225 | RPS_sampler_update_with_nw_size (struct RPS_Sampler *sampler, | 223 | RPS_sampler_update_with_nw_size(struct RPS_Sampler *sampler, |
226 | uint32_t num_peers); | 224 | uint32_t num_peers); |
227 | 225 | ||
228 | 226 | ||
229 | /** | 227 | /** |
@@ -237,8 +235,8 @@ RPS_sampler_update_with_nw_size (struct RPS_Sampler *sampler, | |||
237 | * @param desired_probability | 235 | * @param desired_probability |
238 | */ | 236 | */ |
239 | void | 237 | void |
240 | RPS_sampler_set_desired_probability (struct RPS_Sampler *sampler, | 238 | RPS_sampler_set_desired_probability(struct RPS_Sampler *sampler, |
241 | double desired_probability); | 239 | double desired_probability); |
242 | 240 | ||
243 | 241 | ||
244 | /** | 242 | /** |
@@ -251,8 +249,8 @@ RPS_sampler_set_desired_probability (struct RPS_Sampler *sampler, | |||
251 | * @param desired_probability | 249 | * @param desired_probability |
252 | */ | 250 | */ |
253 | void | 251 | void |
254 | RPS_sampler_set_deficiency_factor (struct RPS_Sampler *sampler, | 252 | RPS_sampler_set_deficiency_factor(struct RPS_Sampler *sampler, |
255 | double deficiency_factor); | 253 | double deficiency_factor); |
256 | 254 | ||
257 | 255 | ||
258 | /** | 256 | /** |
@@ -266,9 +264,9 @@ RPS_sampler_set_deficiency_factor (struct RPS_Sampler *sampler, | |||
266 | * @return The context containing callback and closure | 264 | * @return The context containing callback and closure |
267 | */ | 265 | */ |
268 | struct SamplerNotifyUpdateCTX * | 266 | struct SamplerNotifyUpdateCTX * |
269 | sampler_notify_on_update (struct RPS_Sampler *sampler, | 267 | sampler_notify_on_update(struct RPS_Sampler *sampler, |
270 | SamplerNotifyUpdateCB notify_cb, | 268 | SamplerNotifyUpdateCB notify_cb, |
271 | void *cls); | 269 | void *cls); |
272 | 270 | ||
273 | 271 | ||
274 | /** | 272 | /** |
@@ -277,9 +275,9 @@ sampler_notify_on_update (struct RPS_Sampler *sampler, | |||
277 | * @param sampler the sampler to update. | 275 | * @param sampler the sampler to update. |
278 | * @param id the PeerID that is put in the sampler | 276 | * @param id the PeerID that is put in the sampler |
279 | */ | 277 | */ |
280 | void | 278 | void |
281 | RPS_sampler_update (struct RPS_Sampler *sampler, | 279 | RPS_sampler_update(struct RPS_Sampler *sampler, |
282 | const struct GNUNET_PeerIdentity *id); | 280 | const struct GNUNET_PeerIdentity *id); |
283 | 281 | ||
284 | 282 | ||
285 | /** | 283 | /** |
@@ -290,9 +288,9 @@ RPS_sampler_update (struct RPS_Sampler *sampler, | |||
290 | * @param sampler the sampler to reinitialise a sampler element in. | 288 | * @param sampler the sampler to reinitialise a sampler element in. |
291 | * @param id the id of the sampler elements to update. | 289 | * @param id the id of the sampler elements to update. |
292 | */ | 290 | */ |
293 | void | 291 | void |
294 | RPS_sampler_reinitialise_by_value (struct RPS_Sampler *sampler, | 292 | RPS_sampler_reinitialise_by_value(struct RPS_Sampler *sampler, |
295 | const struct GNUNET_PeerIdentity *id); | 293 | const struct GNUNET_PeerIdentity *id); |
296 | 294 | ||
297 | 295 | ||
298 | /** | 296 | /** |
@@ -302,7 +300,7 @@ RPS_sampler_reinitialise_by_value (struct RPS_Sampler *sampler, | |||
302 | * @return the size of the sampler | 300 | * @return the size of the sampler |
303 | */ | 301 | */ |
304 | unsigned int | 302 | unsigned int |
305 | RPS_sampler_get_size (struct RPS_Sampler *sampler); | 303 | RPS_sampler_get_size(struct RPS_Sampler *sampler); |
306 | 304 | ||
307 | 305 | ||
308 | /** | 306 | /** |
@@ -312,7 +310,7 @@ RPS_sampler_get_size (struct RPS_Sampler *sampler); | |||
312 | * @param new_size the new size of the sampler | 310 | * @param new_size the new size of the sampler |
313 | */ | 311 | */ |
314 | void | 312 | void |
315 | RPS_sampler_resize (struct RPS_Sampler *sampler, unsigned int new_size); | 313 | RPS_sampler_resize(struct RPS_Sampler *sampler, unsigned int new_size); |
316 | 314 | ||
317 | 315 | ||
318 | /** | 316 | /** |
@@ -330,10 +328,10 @@ RPS_sampler_resize (struct RPS_Sampler *sampler, unsigned int new_size); | |||
330 | * @param num_peers the number of peers requested | 328 | * @param num_peers the number of peers requested |
331 | */ | 329 | */ |
332 | struct RPS_SamplerRequestHandle * | 330 | struct RPS_SamplerRequestHandle * |
333 | RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler, | 331 | RPS_sampler_get_n_rand_peers(struct RPS_Sampler *sampler, |
334 | uint32_t num_peers, | 332 | uint32_t num_peers, |
335 | RPS_sampler_n_rand_peers_ready_cb cb, | 333 | RPS_sampler_n_rand_peers_ready_cb cb, |
336 | void *cls); | 334 | void *cls); |
337 | 335 | ||
338 | 336 | ||
339 | /** | 337 | /** |
@@ -344,9 +342,9 @@ RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler, | |||
344 | * @param cls closure given to @a cb | 342 | * @param cls closure given to @a cb |
345 | */ | 343 | */ |
346 | struct RPS_SamplerRequestHandleSingleInfo * | 344 | struct RPS_SamplerRequestHandleSingleInfo * |
347 | RPS_sampler_get_rand_peer_info (struct RPS_Sampler *sampler, | 345 | RPS_sampler_get_rand_peer_info(struct RPS_Sampler *sampler, |
348 | RPS_sampler_sinlge_info_ready_cb cb, | 346 | RPS_sampler_sinlge_info_ready_cb cb, |
349 | void *cls); | 347 | void *cls); |
350 | 348 | ||
351 | 349 | ||
352 | /** | 350 | /** |
@@ -357,9 +355,9 @@ RPS_sampler_get_rand_peer_info (struct RPS_Sampler *sampler, | |||
357 | * | 355 | * |
358 | * @return the number of occurrences of id. | 356 | * @return the number of occurrences of id. |
359 | */ | 357 | */ |
360 | uint32_t | 358 | uint32_t |
361 | RPS_sampler_count_id (struct RPS_Sampler *sampler, | 359 | RPS_sampler_count_id(struct RPS_Sampler *sampler, |
362 | const struct GNUNET_PeerIdentity *id); | 360 | const struct GNUNET_PeerIdentity *id); |
363 | 361 | ||
364 | 362 | ||
365 | /** | 363 | /** |
@@ -368,7 +366,7 @@ RPS_sampler_count_id (struct RPS_Sampler *sampler, | |||
368 | * @param req_handle the handle to the request | 366 | * @param req_handle the handle to the request |
369 | */ | 367 | */ |
370 | void | 368 | void |
371 | RPS_sampler_request_cancel (struct RPS_SamplerRequestHandle *req_handle); | 369 | RPS_sampler_request_cancel(struct RPS_SamplerRequestHandle *req_handle); |
372 | 370 | ||
373 | 371 | ||
374 | /** | 372 | /** |
@@ -377,15 +375,15 @@ RPS_sampler_request_cancel (struct RPS_SamplerRequestHandle *req_handle); | |||
377 | * @param req_handle the handle to the request | 375 | * @param req_handle the handle to the request |
378 | */ | 376 | */ |
379 | void | 377 | void |
380 | RPS_sampler_request_single_info_cancel ( | 378 | RPS_sampler_request_single_info_cancel( |
381 | struct RPS_SamplerRequestHandleSingleInfo *req_single_info_handle); | 379 | struct RPS_SamplerRequestHandleSingleInfo *req_single_info_handle); |
382 | 380 | ||
383 | 381 | ||
384 | /** | 382 | /** |
385 | * Cleans the sampler. | 383 | * Cleans the sampler. |
386 | */ | 384 | */ |
387 | void | 385 | void |
388 | RPS_sampler_destroy (struct RPS_Sampler *sampler); | 386 | RPS_sampler_destroy(struct RPS_Sampler *sampler); |
389 | 387 | ||
390 | #endif /* RPS_SAMPLER_COMMON_H */ | 388 | #endif /* RPS_SAMPLER_COMMON_H */ |
391 | /* end of rps-sampler_common.h */ | 389 | /* end of rps-sampler_common.h */ |