aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps-sampler_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/rps-sampler_common.h')
-rw-r--r--src/rps/rps-sampler_common.h56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/rps/rps-sampler_common.h b/src/rps/rps-sampler_common.h
index 1abe43720..321efaf1e 100644
--- a/src/rps/rps-sampler_common.h
+++ b/src/rps/rps-sampler_common.h
@@ -44,10 +44,14 @@
44 * 44 *
45 * @param cls the closure given alongside this function. 45 * @param cls the closure given alongside this function.
46 * @param id the PeerID that was returned 46 * @param id the PeerID that was returned
47 * @param probability The probability with which this sampler has seen all ids
48 * @param num_observed How many ids this sampler has observed
47 */ 49 */
48typedef void 50typedef void
49(*RPS_sampler_rand_peer_ready_cont) (void *cls, 51(*RPS_sampler_rand_peer_ready_cont) (void *cls,
50 const struct GNUNET_PeerIdentity *id); 52 const struct GNUNET_PeerIdentity *id,
53 double probability,
54 uint32_t num_observed);
51 55
52 56
53/** 57/**
@@ -72,6 +76,22 @@ typedef void
72 76
73 77
74/** 78/**
79 * Callback that is called from _get_n_rand_peers() when the PeerIDs are ready.
80 *
81 * @param cls the closure given alongside this function.
82 * @param probability Probability with which all IDs have been observed
83 * @param num_observed Number of observed IDs
84 * @param ids the PeerIDs that were returned
85 * to be freed
86 */
87 typedef void
88(*RPS_sampler_sinlge_info_ready_cb) (const struct GNUNET_PeerIdentity *ids,
89 void *cls,
90 double probability,
91 uint32_t num_observed);
92
93
94/**
75 * @brief Callback called each time a new peer was put into the sampler 95 * @brief Callback called each time a new peer was put into the sampler
76 * 96 *
77 * @param cls A possibly given closure 97 * @param cls A possibly given closure
@@ -97,6 +117,11 @@ struct GetPeerCls
97 struct RPS_SamplerRequestHandle *req_handle; 117 struct RPS_SamplerRequestHandle *req_handle;
98 118
99 /** 119 /**
120 * The #RPS_SamplerRequestHandleSingleInfo this single request belongs to.
121 */
122 struct RPS_SamplerRequestHandleSingleInfo *req_single_info_handle;
123
124 /**
100 * The task for this function. 125 * The task for this function.
101 */ 126 */
102 struct GNUNET_SCHEDULER_Task *get_peer_task; 127 struct GNUNET_SCHEDULER_Task *get_peer_task;
@@ -177,6 +202,12 @@ struct RPS_Sampler
177 struct RPS_SamplerRequestHandle *req_handle_head; 202 struct RPS_SamplerRequestHandle *req_handle_head;
178 struct RPS_SamplerRequestHandle *req_handle_tail; 203 struct RPS_SamplerRequestHandle *req_handle_tail;
179 204
205 /**
206 * Head and tail for the DLL to store the #RPS_SamplerRequestHandleSingleInfo
207 */
208 struct RPS_SamplerRequestHandleSingleInfo *req_handle_single_head;
209 struct RPS_SamplerRequestHandleSingleInfo *req_handle_single_tail;
210
180 struct SamplerNotifyUpdateCTX *notify_ctx_head; 211 struct SamplerNotifyUpdateCTX *notify_ctx_head;
181 struct SamplerNotifyUpdateCTX *notify_ctx_tail; 212 struct SamplerNotifyUpdateCTX *notify_ctx_tail;
182}; 213};
@@ -306,6 +337,19 @@ RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler,
306 337
307 338
308/** 339/**
340 * Get one random peer with additional information.
341 *
342 * @param sampler the sampler to get peers from.
343 * @param cb callback that will be called once the ids are ready.
344 * @param cls closure given to @a cb
345 */
346struct RPS_SamplerRequestHandleSingleInfo *
347RPS_sampler_get_rand_peer_info (struct RPS_Sampler *sampler,
348 RPS_sampler_sinlge_info_ready_cb cb,
349 void *cls);
350
351
352/**
309 * Counts how many Samplers currently hold a given PeerID. 353 * Counts how many Samplers currently hold a given PeerID.
310 * 354 *
311 * @param sampler the sampler to count ids in. 355 * @param sampler the sampler to count ids in.
@@ -328,6 +372,16 @@ RPS_sampler_request_cancel (struct RPS_SamplerRequestHandle *req_handle);
328 372
329 373
330/** 374/**
375 * Cancle a request issued through #RPS_sampler_n_rand_peers_ready_cb.
376 *
377 * @param req_handle the handle to the request
378 */
379void
380RPS_sampler_request_single_info_cancel (
381 struct RPS_SamplerRequestHandleSingleInfo *req_single_info_handle);
382
383
384/**
331 * Cleans the sampler. 385 * Cleans the sampler.
332 */ 386 */
333 void 387 void