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_init (size_t init_size, struct GNUNET_TIME_Relative max_round_interval) |
Initialise a tuple of samplers. 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... | |
sampler implementation
Definition in file gnunet-service-rps_sampler.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.
References RPS_Sampler::sampler_size.
Referenced by adapt_sizes(), and resize_wrapper().
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.
References GNUNET_assert, and sampler_resize().
Referenced by resize_wrapper(), RPS_sampler_init(), and RPS_sampler_mod_init().
struct RPS_Sampler * RPS_sampler_init | ( | size_t | init_size, |
struct GNUNET_TIME_Relative | max_round_interval | ||
) |
Initialise a tuple of samplers.
init_size | the size the sampler is initialised with |
max_round_interval | maximum time a round takes |
Initialise a tuple of samplers.
init_size | the size the sampler is initialised with |
max_round_interval | maximum time a round takes |
Definition at line 196 of file gnunet-service-rps_sampler.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_get_rand_peer().
Referenced by new_sub().
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.
References notify_update(), RPS_sampler_elem_next(), RPS_Sampler::sampler_elements, and RPS_Sampler::sampler_size.
Referenced by collect_peers_cb(), collect_peers_info_cb(), and insert_in_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.
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 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.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcmp, LOG, RPS_SamplerElement::peer_id, RPS_sampler_elem_reinit(), RPS_Sampler::sampler_elements, and RPS_Sampler::sampler_size.
Referenced by remove_peer().
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 |
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.
References check_n_peers_ready(), GetPeerCls::cont, GetPeerCls::cont_cls, GetPeerCls::get_peer_task, RPS_Sampler::get_peers, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_new_array, GNUNET_SCHEDULER_add_now(), GetPeerCls::id, LOG, num_peers, req_handle, GetPeerCls::req_handle, RPS_Sampler::req_handle_head, RPS_Sampler::req_handle_tail, GetPeerCls::req_single_info_handle, GNUNET_RPS_Request_Handle::sampler, and RPS_Sampler::sampler_size.
Referenced by do_round(), and GNUNET_RPS_request_peers().
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.
References GetPeerCls::get_peer_task, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GetPeerCls::notify_ctx, RPS_Sampler::notify_ctx_head, RPS_Sampler::notify_ctx_tail, req_handle, RPS_Sampler::req_handle_head, RPS_Sampler::req_handle_tail, and GNUNET_RPS_Request_Handle::sampler.
Referenced by GNUNET_RPS_request_cancel().
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.
References EMPTY, GNUNET_memcmp, RPS_SamplerElement::is_empty, RPS_SamplerElement::peer_id, RPS_Sampler::sampler_elements, and RPS_Sampler::sampler_size.
Referenced by check_sending_channel_needed(), clean_peer(), and insert_in_sampler().
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.
References GNUNET_ERROR_TYPE_WARNING, GNUNET_free, LOG, RPS_Sampler::req_handle_head, RPS_sampler_request_cancel(), and sampler_empty().
Referenced by destroy_sub(), GNUNET_RPS_request_cancel(), and GNUNET_RPS_request_single_info_cancel().