#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "rps.h"
#include "rps-sampler_common.h"
#include "gnunet-service-rps_sampler.h"
#include "gnunet-service-rps_sampler_elem.h"
#include <math.h>
#include <inttypes.h>
#include "rps-test_util.h"
Go to the source code of this file.
Data Structures | |
struct | SamplerNotifyUpdateCTX |
Context for a callback. More... | |
struct | RPS_SamplerRequestHandle |
Closure to _get_n_rand_peers_ready_cb() More... | |
struct | RPS_SamplerRequestHandleSingleInfo |
Closure to _get_rand_peer_info() More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "rps-sampler", __VA_ARGS__) |
Typedefs | |
typedef void(* | SamplerNotifyUpdateCB) (void *cls) |
Callback called each time a new peer was put into the sampler. More... | |
typedef void(* | RPS_get_peers_type) (void *cls) |
Type of function used to differentiate between modified and not modified Sampler. More... | |
Functions | |
static void | sampler_mod_get_rand_peer (void *cls) |
Get one random peer out of the sampled peers. 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... | |
Variables | |
static size_t | min_size |
** More... | |
static size_t | max_size |
The maximal size the extended sampler elements should grow to. More... | |
static uint32_t | client_get_index |
The size the extended sampler elements currently have. More... | |
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "rps-sampler", __VA_ARGS__) |
Definition at line 40 of file rps-sampler_client.c.
typedef void(* SamplerNotifyUpdateCB) (void *cls) |
Callback called each time a new peer was put into the sampler.
cls | A possibly given closure |
Definition at line 63 of file rps-sampler_client.c.
typedef void(* RPS_get_peers_type) (void *cls) |
Type of function used to differentiate between modified and not modified Sampler.
Definition at line 99 of file rps-sampler_client.c.
|
static |
Get one random peer out of the sampled peers.
We might want to reinitialise this sampler after giving the corrsponding peer to the client.
This reinitialises the queried sampler element.
Definition at line 302 of file rps-sampler_client.c.
References GNUNET_TIME_Absolute::abs_value_us, client_get_index, GetPeerCls::cont, GetPeerCls::cont_cls, EMPTY, GetPeerCls::get_peer_task, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_UNIT_FOREVER_ABS, RPS_SamplerRequestHandle::gpc_head, RPS_SamplerRequestHandleSingleInfo::gpc_head, RPS_SamplerRequestHandle::gpc_tail, RPS_SamplerRequestHandleSingleInfo::gpc_tail, GetPeerCls::id, RPS_SamplerElement::is_empty, RPS_SamplerElement::last_client_request, LOG, RPS_Sampler::max_round_interval, GetPeerCls::notify_ctx, RPS_SamplerElement::num_peers, RPS_SamplerElement::peer_id, GNUNET_TIME_Relative::rel_value_us, GetPeerCls::req_handle, GetPeerCls::req_single_info_handle, RPS_sampler_elem_reinit(), RPS_SamplerRequestHandle::sampler, RPS_SamplerRequestHandleSingleInfo::sampler, RPS_Sampler::sampler_elements, sampler_mod_get_rand_peer(), sampler_notify_on_update(), and RPS_Sampler::sampler_size.
Referenced by RPS_sampler_mod_init(), and sampler_mod_get_rand_peer().
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().
|
static |
**
The minimal size for the extended sampler elements.
Definition at line 210 of file rps-sampler_client.c.
Referenced by RPS_sampler_mod_init().
|
static |
The maximal size the extended sampler elements should grow to.
Definition at line 215 of file rps-sampler_client.c.
Referenced by RPS_sampler_mod_init().
|
static |
The size the extended sampler elements currently have.
Inedex to the sampler element that is the next to be returned
Definition at line 225 of file rps-sampler_client.c.
Referenced by RPS_sampler_mod_init(), and sampler_mod_get_rand_peer().