40 #define LOG(kind, ...) GNUNET_log_from (kind, "rps-sampler", __VA_ARGS__) 251 client_get_index = 0;
308 double prob_observed_n;
309 uint32_t num_observed;
323 client_get_index = (client_get_index + 1) % sampler->
sampler_size;
332 "Sampler_mod element empty, rescheduling.\n");
355 "Last client request on this sampler was less than max round interval ago -- scheduling for later\n");
373 "This s_elem saw less than two peers -- scheduling for later\n");
434 gpc->
cont (gpc->
cont_cls, gpc->
id, prob_observed_n, num_observed);
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
uint32_t num_peers
How many times a PeerID was put in this sampler.
void(* RPS_get_peers_type)(void *cls)
Type of function used to differentiate between modified and not modified Sampler. ...
uint64_t rel_value_us
The actual value.
RPS_sampler_rand_peer_ready_cont cont
The callback.
struct SamplerNotifyUpdateCTX * prev
Previous element in DLL.
A sampler element sampling one PeerID at a time.
static size_t min_size
Global sampler variable.
Some utils faciliating the view into the internals for the sampler needed for evaluation.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct RPS_SamplerRequestHandleSingleInfo * prev
sampler element implementation
Code common to client and service sampler.
struct GNUNET_TIME_Absolute last_client_request
Time of last request.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
example IPC messages between RPS API and GNS service
struct RPS_SamplerRequestHandleSingleInfo * next
DLL.
void(* SamplerNotifyUpdateCB)(void *cls)
Callback called each time a new peer was put into the sampler.
void RPS_sampler_elem_reinit(struct RPS_SamplerElement *sampler_elem)
Reinitialise a previously initialised sampler element.
struct RPS_SamplerRequestHandle * req_handle
The RPS_SamplerRequestHandle this single request belongs to.
struct GNUNET_TIME_Relative max_round_interval
Maximum time a round takes.
struct GetPeerCls * gpc_tail
uint64_t abs_value_us
The actual value.
static size_t max_size
The maximal size the extended sampler elements should grow to.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
Closure to _get_n_rand_peers_ready_cb()
struct SamplerNotifyUpdateCTX * notify_ctx
Context to the given callback.
struct SamplerNotifyUpdateCTX * next
Next element in DLL.
static uint32_t client_get_index
The size the extended sampler elements currently have.
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.
struct RPS_Sampler * sampler
Sampler.
static struct GNUNET_CONTAINER_MultiPeerMap * ids
GNUNET_PeerIdentity -> CadetPeer.
enum RPS_SamplerEmpty is_empty
Flag that indicates that we are not holding a valid PeerID right now.
struct GNUNET_PeerIdentity peer_id
The PeerID this sampler currently samples.
SamplerNotifyUpdateCB notify_cb
The Callback to call on updates.
void * cls
The according closure.
Closure to _get_rand_peer_info()
static void sampler_mod_get_rand_peer(void *cls)
Get one random peer out of the sampled peers.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
void * cls
Closure given to the callback.
void RPS_sampler_resize(struct RPS_Sampler *sampler, unsigned int new_size)
Grow or shrink the size of the sampler.
struct GetPeerCls * gpc_head
Head and tail for the DLL to store the tasks for single requests.
static unsigned int num_peers
struct GNUNET_PeerIdentity * id
Pointer to the id.
uint32_t cur_num_peers
Number of peers we currently have.
struct RPS_SamplerRequestHandleSingleInfo * req_single_info_handle
The RPS_SamplerRequestHandleSingleInfo this single request belongs to.
void * cont_cls
The closure to the callback cont.
The identity of the host (wraps the signing key of the peer).
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.
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.
Closure for sampler_mod_get_rand_peer() and sampler_get_rand_peer.
unsigned int sampler_size
Number of sampler elements we hold.
struct GetPeerCls * gpc_tail
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
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.
RPS_get_peers_type get_peers
Stores the function to return peers.
struct RPS_SamplerElement ** sampler_elements
All sampler elements in one array.
Sampler with its own array of SamplerElements.
struct GNUNET_PeerIdentity * id
The address of the id to be stored at.
struct GNUNET_SCHEDULER_Task * get_peer_task
The task for this function.
RPS_sampler_sinlge_info_ready_cb callback
Callback to be called when all ids are available.
struct GetPeerCls * gpc_head
Head and tail for the DLL to store the tasks for single requests.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
struct RPS_Sampler * sampler
Sampler.