sampler implementation More...
#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... | |
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_get_rand_peer (void *cls) |
Get one random peer out of the sampled peers. More... | |
struct RPS_Sampler * | RPS_sampler_init (size_t init_size, struct GNUNET_TIME_Relative max_round_interval) |
Initialise a 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... | |
sampler implementation
Definition in file gnunet-service-rps_sampler.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "rps-sampler", __VA_ARGS__) |
Definition at line 40 of file gnunet-service-rps_sampler.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 gnunet-service-rps_sampler.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 gnunet-service-rps_sampler.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. Only used internally
; Choose the r_index of the peer we want to return at random from the interval of the gossip list
Definition at line 228 of file gnunet-service-rps_sampler.c.
References GetPeerCls::cont, GetPeerCls::cont_cls, EMPTY, GetPeerCls::get_peer_task, GNUNET_CONTAINER_DLL_remove, GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u64(), GNUNET_free, RPS_SamplerRequestHandle::gpc_head, RPS_SamplerRequestHandle::gpc_tail, GetPeerCls::id, RPS_SamplerElement::is_empty, GetPeerCls::notify_ctx, RPS_SamplerElement::num_peers, RPS_SamplerElement::peer_id, GetPeerCls::req_handle, RPS_SamplerRequestHandle::sampler, RPS_Sampler::sampler_elements, sampler_get_rand_peer(), sampler_notify_on_update(), and RPS_Sampler::sampler_size.
Referenced by RPS_sampler_init(), and sampler_get_rand_peer().
struct RPS_Sampler * RPS_sampler_init | ( | size_t | init_size, |
struct GNUNET_TIME_Relative | max_round_interval | ||
) |
Initialise a tuple of sampler elements.
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().
|
static |
**
The minimal size for the extended sampler elements.
Definition at line 170 of file gnunet-service-rps_sampler.c.
Referenced by RPS_sampler_init().
|
static |
The maximal size the extended sampler elements should grow to.
Definition at line 175 of file gnunet-service-rps_sampler.c.
Referenced by buffer_append(), buffer_init(), and RPS_sampler_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 185 of file gnunet-service-rps_sampler.c.
Referenced by RPS_sampler_init().