client sampler implementation More...
Go to the source code of this file.
Functions | |
unsigned int | RPS_sampler_get_size (struct RPS_Sampler *sampler) |
Get the size of the sampler. More... | |
void | RPS_sampler_resize (struct RPS_Sampler *sampler, unsigned int new_size) |
Grow or shrink the size of the sampler. More... | |
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. More... | |
void | RPS_sampler_update (struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id) |
Update every sampler element of this sampler with given peer. More... | |
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. More... | |
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. More... | |
void | RPS_sampler_request_cancel (struct RPS_SamplerRequestHandle *req_handle) |
Cancel a request issued through RPS_sampler_n_rand_peers_ready_cb. More... | |
uint32_t | RPS_sampler_count_id (struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id) |
Counts how many Samplers currently hold a given PeerID. More... | |
void | RPS_sampler_destroy (struct RPS_Sampler *sampler) |
Cleans the samplers. More... | |
client sampler implementation
Definition in file rps-sampler_client.h.
unsigned int RPS_sampler_get_size | ( | struct RPS_Sampler * | sampler | ) |
Get the size of the sampler.
sampler | the sampler to return the size of. |
Definition at line 238 of file rps-sampler_common.c.
void RPS_sampler_resize | ( | struct RPS_Sampler * | sampler, |
unsigned int | new_size | ||
) |
Grow or shrink the size of the sampler.
sampler | the sampler to resize. |
new_size | the new size of the sampler (not 0) |
sampler | the sampler to resize. |
new_size | the new size of the sampler |
Definition at line 423 of file rps-sampler_common.c.
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.
init_size | the size the sampler is initialised with |
max_round_interval | maximum time a round takes |
Definition at line 236 of file rps-sampler_client.c.
References client_get_index, RPS_Sampler::get_peers, GNUNET_new, RPS_Sampler::max_round_interval, max_size, min_size, RPS_sampler_resize(), and sampler_mod_get_rand_peer().
Referenced by GNUNET_RPS_request_peer_info(), and GNUNET_RPS_request_peers().
void RPS_sampler_update | ( | struct RPS_Sampler * | sampler, |
const struct GNUNET_PeerIdentity * | id | ||
) |
Update every sampler element of this sampler with given peer.
sampler | the sampler to update. |
id | the PeerID that is put in the sampler |
Definition at line 285 of file rps-sampler_common.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.
Used to get rid of a PeerID.
sampler | the sampler to reinitialise a sampler in. |
id | the id of the samplers to update. |
Used to get rid of a PeerID.
FIXME: This should also consider currently pending requests (Pending requests already collect peerids. As long as not all requested IDs have been collected, they are kept. Ideally, the id
should be removed from all pending requests. This seems quite complicated.)
sampler | the sampler to reinitialise a sampler element in. |
id | the id of the sampler elements to update. |
Definition at line 312 of file rps-sampler_common.c.
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.
We might want to reinitialise this sampler after giving the corrsponding peer to the client. Random with or without consumption?
sampler | the sampler to get peers from. |
cb | callback that will be called once the ids are ready. |
cls | closure given to cb |
num_peers | the number of peers requested |
We might want to reinitialise this sampler after giving the corrsponding peer to the client. Random with or without consumption?
sampler | the sampler to get peers from. |
cb | callback that will be called once the ids are ready. |
cls | closure given to cb |
for_client | GNUNET_YES if result is used for client, GNUNET_NO if used internally |
num_peers | the number of peers requested |
Definition at line 549 of file rps-sampler_common.c.
void RPS_sampler_request_cancel | ( | struct RPS_SamplerRequestHandle * | req_handle | ) |
Cancel a request issued through RPS_sampler_n_rand_peers_ready_cb.
req_handle | the handle to the request |
Definition at line 647 of file rps-sampler_common.c.
uint32_t RPS_sampler_count_id | ( | struct RPS_Sampler * | sampler, |
const struct GNUNET_PeerIdentity * | id | ||
) |
Counts how many Samplers currently hold a given PeerID.
sampler | the sampler to count ids in. |
id | the PeerID to count. |
Definition at line 338 of file rps-sampler_common.c.
void RPS_sampler_destroy | ( | struct RPS_Sampler * | sampler | ) |
Cleans the samplers.
sampler | the sampler to destroy. |
Cleans the samplers.
Definition at line 726 of file rps-sampler_common.c.