27#ifndef RPS_SAMPLER_COMMON_H
28#define RPS_SAMPLER_COMMON_H
54 uint32_t num_observed);
91 uint32_t num_observed);
241 double desired_probability);
255 double deficiency_factor);
static void notify_cb(void *cls, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg)
Function called when the transport service has received a backchannel message for this communicator (...
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
static struct GNUNET_RPS_Request_Handle * req_handle
Request handle.
sampler element implementation
static unsigned int num_peers
Number of peers.
API to create, modify and access statistics.
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.
void(* RPS_sampler_sinlge_info_ready_cb)(const struct GNUNET_PeerIdentity *ids, void *cls, double probability, uint32_t num_observed)
Callback that is called from _get_n_rand_peers() when the PeerIDs are ready.
void(* RPS_sampler_rand_peer_ready_cont)(void *cls, const struct GNUNET_PeerIdentity *id, double probability, uint32_t num_observed)
Callback that is called from _get_rand_peer() when the PeerID is ready.
void RPS_sampler_update(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Update every sampler element of this sampler with given peer.
void(* RPS_get_peers_type)(void *cls)
Type of function used to differentiate between modified and not modified Sampler.
void RPS_sampler_update_with_nw_size(struct RPS_Sampler *sampler, uint32_t num_peers)
Update the current estimate of the network size stored at the sampler.
void(* SamplerNotifyUpdateCB)(void *cls)
Callback called each time a new peer was put into the sampler.
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.
struct SamplerNotifyUpdateCTX * sampler_notify_on_update(struct RPS_Sampler *sampler, SamplerNotifyUpdateCB notify_cb, void *cls)
Add a callback that will be called when the next peer is inserted into the sampler.
struct RPS_SamplerRequestHandleSingleInfo * RPS_sampler_get_rand_peer_info(struct RPS_Sampler *sampler, RPS_sampler_sinlge_info_ready_cb cb, void *cls)
Get one random peer with additional information.
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 sampler.
unsigned int RPS_sampler_get_size(struct RPS_Sampler *sampler)
Get the size of the sampler.
void RPS_sampler_set_deficiency_factor(struct RPS_Sampler *sampler, double deficiency_factor)
Set the deficiency factor.
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 RPS_sampler_set_desired_probability(struct RPS_Sampler *sampler, double desired_probability)
Set the probability that is needed at least with what a sampler element has to have observed all elem...
void RPS_sampler_request_single_info_cancel(struct RPS_SamplerRequestHandleSingleInfo *req_single_info_handle)
Cancel a request issued through RPS_sampler_n_rand_peers_ready_cb.
uint32_t RPS_sampler_count_id(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Counts how many Samplers currently hold a given PeerID.
Some utils facilitating the view into the internals for the sampler needed for evaluation.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Time for relative time used by GNUnet, in microseconds.
Closure for sampler_mod_get_rand_peer() and sampler_get_rand_peer.
struct GetPeerCls * next
DLL.
struct RPS_SamplerRequestHandleSingleInfo * req_single_info_handle
The RPS_SamplerRequestHandleSingleInfo this single request belongs to.
struct SamplerNotifyUpdateCTX * notify_ctx
Context to the given callback.
struct GNUNET_PeerIdentity * id
The address of the id to be stored at.
RPS_sampler_rand_peer_ready_cont cont
The callback.
struct RPS_SamplerRequestHandle * req_handle
The RPS_SamplerRequestHandle this single request belongs to.
struct GNUNET_SCHEDULER_Task * get_peer_task
The task for this function.
void * cont_cls
The closure to the callback cont.
A sampler element sampling one PeerID at a time.
Closure to _get_rand_peer_info()
void * cls
Closure given to the callback.
struct RPS_Sampler * sampler
Sampler.
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 RPS_SamplerRequestHandle * req_handle_head
Head and tail for the DLL to store the RPS_SamplerRequestHandle.
struct RPS_SamplerRequestHandleSingleInfo * req_handle_single_tail
struct SamplerNotifyUpdateCTX * notify_ctx_head
RPS_get_peers_type get_peers
Stores the function to return peers.
struct RPS_SamplerElement ** sampler_elements
All sampler elements in one array.
struct GNUNET_TIME_Relative max_round_interval
Maximum time a round takes.
double deficiency_factor
A factor that catches the 'bias' of a random stream of peer ids.
struct RPS_SamplerRequestHandleSingleInfo * req_handle_single_head
Head and tail for the DLL to store the RPS_SamplerRequestHandleSingleInfo.
struct RPS_SamplerRequestHandle * req_handle_tail
uint32_t num_peers_estim
The estimated total number of peers in the network.
struct SamplerNotifyUpdateCTX * notify_ctx_tail
double desired_probability
The desired probability with which we want to have observed all peers.
unsigned int sampler_size
Number of sampler elements we hold.
void * cls
The according closure.