Macros | |
#define | GNUNET_RPS_VERSION 0x00000000 |
Version of the rps API. More... | |
Typedefs | |
typedef void(* | GNUNET_RPS_NotifyReadyCB) (void *cls, uint64_t num_peers, const struct GNUNET_PeerIdentity *peers) |
Callback called when requested random peers are available. More... | |
typedef void(* | GNUNET_RPS_NotifyReadySingleInfoCB) (void *cls, const struct GNUNET_PeerIdentity *peer, double probability, uint32_t num_observed) |
Callback called when requested random peer with additional information is available. More... | |
Functions | |
struct GNUNET_RPS_Handle * | GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Connect to the rps service. More... | |
void | GNUNET_RPS_sub_start (struct GNUNET_RPS_Handle *h, const char *shared_value) |
Start a sub with the given shared value. More... | |
void | GNUNET_RPS_sub_stop (struct GNUNET_RPS_Handle *h, const char *shared_value) |
Stop a sub with the given shared value. More... | |
struct GNUNET_RPS_Request_Handle * | GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle *h, uint32_t n, GNUNET_RPS_NotifyReadyCB ready_cb, void *cls) |
Request n random peers. More... | |
struct GNUNET_RPS_Request_Handle_Single_Info * | GNUNET_RPS_request_peer_info (struct GNUNET_RPS_Handle *rps_handle, GNUNET_RPS_NotifyReadySingleInfoCB ready_cb, void *cls) |
Request one random peer, getting additional information. More... | |
void | GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint32_t n, const struct GNUNET_PeerIdentity *ids) |
Seed rps service with peerIDs. More... | |
void | GNUNET_RPS_request_cancel (struct GNUNET_RPS_Request_Handle *rh) |
Cancel an issued request. More... | |
void | GNUNET_RPS_request_single_info_cancel (struct GNUNET_RPS_Request_Handle_Single_Info *rhs) |
Cancel an issued single info request. More... | |
void | GNUNET_RPS_view_request (struct GNUNET_RPS_Handle *rps_handle, uint32_t num_updates, GNUNET_RPS_NotifyReadyCB view_update_cb, void *cls) |
Request updates of view. More... | |
struct GNUNET_RPS_StreamRequestHandle * | GNUNET_RPS_stream_request (struct GNUNET_RPS_Handle *rps_handle, GNUNET_RPS_NotifyReadyCB stream_input_cb, void *cls) |
Request biased stream of peers that are being put into the sampler. More... | |
void | GNUNET_RPS_stream_cancel (struct GNUNET_RPS_StreamRequestHandle *srh) |
Cancel a specific request for updates from the biased peer stream. More... | |
void | GNUNET_RPS_disconnect (struct GNUNET_RPS_Handle *h) |
Disconnect from the rps service. More... | |
Random Peer Sampling.
#define GNUNET_RPS_VERSION 0x00000000 |
Version of the rps API.
Definition at line 48 of file gnunet_rps_service.h.
typedef void(* GNUNET_RPS_NotifyReadyCB) (void *cls, uint64_t num_peers, const struct GNUNET_PeerIdentity *peers) |
Callback called when requested random peers are available.
cls | the closure given with the request |
num_peers | the number of peers returned |
peers | array with num_peers PeerIDs |
Definition at line 67 of file gnunet_rps_service.h.
typedef void(* GNUNET_RPS_NotifyReadySingleInfoCB) (void *cls, const struct GNUNET_PeerIdentity *peer, double probability, uint32_t num_observed) |
Callback called when requested random peer with additional information is available.
cls | the closure given with the request |
peer | The Peer ID |
probability | The probability with which all elements have been observed |
num_observed | Number of IDs this sampler has observed |
Definition at line 82 of file gnunet_rps_service.h.
struct GNUNET_RPS_Handle * GNUNET_RPS_connect | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg | ) |
Connect to the rps service.
cfg | configuration to use |
cfg | configuration to use |
Definition at line 843 of file rps_api.c.
References cfg, GNUNET_ARM_Handle::cfg, GNUNET_CONFIGURATION_get_value_float(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_config_missing(), GNUNET_new, GNUNET_OK, h, LOG, GNUNET_ARM_Handle::mq, and reconnect().
Referenced by run().
void GNUNET_RPS_sub_start | ( | struct GNUNET_RPS_Handle * | h, |
const char * | shared_value | ||
) |
Start a sub with the given shared value.
h | Handle to rps |
shared_value | The shared value that defines the members of the sub (-group) |
h | Handle to rps |
shared_value | The shared value that defines the members of the sub (-gorup) |
Definition at line 904 of file rps_api.c.
References GNUNET_assert, GNUNET_MESSAGE_TYPE_RPS_CS_SUB_START, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TIME_relative_hton(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, h, hash_from_share_val(), GNUNET_ARM_Handle::mq, and msg.
void GNUNET_RPS_sub_stop | ( | struct GNUNET_RPS_Handle * | h, |
const char * | shared_value | ||
) |
Stop a sub with the given shared value.
h | Handle to rps |
shared_value | The shared value that defines the members of the sub (-group) |
h | Handle to rps |
shared_value | The shared value that defines the members of the sub (-gorup) |
Definition at line 927 of file rps_api.c.
References GNUNET_MESSAGE_TYPE_RPS_CS_SUB_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), h, hash_from_share_val(), GNUNET_ARM_Handle::mq, and msg.
struct GNUNET_RPS_Request_Handle * GNUNET_RPS_request_peers | ( | struct GNUNET_RPS_Handle * | rps_handle, |
uint32_t | num_req_peers, | ||
GNUNET_RPS_NotifyReadyCB | ready_cb, | ||
void * | cls | ||
) |
Request n random peers.
This does exactly the same as GNUNET_RPS_request_peers_single_call but needs a GNUNET_RPS_Handle. This exists only for other parts of GNUnet that expect having to (dis)connect from/to a service.
h | handle to the rps service |
n | number of random peers to return |
ready_cb | the callback to be called when the peers are available |
cls | a closure that will be given to the callback |
rps_handle | handle to the rps service |
num_req_peers | number of peers we want to receive |
ready_cb | the callback called when the peers are available |
cls | closure given to the callback |
Definition at line 950 of file rps_api.c.
References collect_peers_cb(), GNUNET_RPS_Handle::deficiency_factor, GNUNET_RPS_Handle::desired_probability, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_INFO, GNUNET_new, GNUNET_RPS_stream_request(), GNUNET_TIME_UNIT_SECONDS, LOG, GNUNET_RPS_Request_Handle::num_requests, peers_ready_cb(), GNUNET_RPS_Request_Handle::ready_cb, GNUNET_RPS_Request_Handle::ready_cb_cls, GNUNET_RPS_Handle::rh_head, GNUNET_RPS_Handle::rh_tail, rps_handle, GNUNET_RPS_Request_Handle::rps_handle, RPS_sampler_get_n_rand_peers(), RPS_sampler_mod_init(), RPS_sampler_set_deficiency_factor(), RPS_sampler_set_desired_probability(), GNUNET_RPS_Request_Handle::sampler, GNUNET_RPS_Request_Handle::sampler_rh, and GNUNET_RPS_Request_Handle::srh.
Referenced by run().
struct GNUNET_RPS_Request_Handle_Single_Info * GNUNET_RPS_request_peer_info | ( | struct GNUNET_RPS_Handle * | rps_handle, |
GNUNET_RPS_NotifyReadySingleInfoCB | ready_cb, | ||
void * | cls | ||
) |
Request one random peer, getting additional information.
rps_handle | handle to the rps service |
ready_cb | the callback called when the peers are available |
cls | closure given to the callback |
Definition at line 995 of file rps_api.c.
References collect_peers_info_cb(), GNUNET_RPS_Handle::deficiency_factor, GNUNET_RPS_Handle::desired_probability, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_INFO, GNUNET_new, GNUNET_RPS_stream_request(), GNUNET_TIME_UNIT_SECONDS, LOG, peer_info_ready_cb(), GNUNET_RPS_Request_Handle_Single_Info::ready_cb, GNUNET_RPS_Request_Handle_Single_Info::ready_cb_cls, GNUNET_RPS_Handle::rhs_head, GNUNET_RPS_Handle::rhs_tail, rps_handle, GNUNET_RPS_Request_Handle_Single_Info::rps_handle, RPS_sampler_get_rand_peer_info(), RPS_sampler_mod_init(), RPS_sampler_set_deficiency_factor(), RPS_sampler_set_desired_probability(), GNUNET_RPS_Request_Handle_Single_Info::sampler, GNUNET_RPS_Request_Handle_Single_Info::sampler_rh, and GNUNET_RPS_Request_Handle_Single_Info::srh.
void GNUNET_RPS_seed_ids | ( | struct GNUNET_RPS_Handle * | h, |
uint32_t | n, | ||
const struct GNUNET_PeerIdentity * | ids | ||
) |
Seed rps service with peerIDs.
h | handle to the rps service |
n | number of peers to seed |
ids | the ids of the peers seeded |
Definition at line 1036 of file rps_api.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RPS_CS_SEED, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), h, LOG, GNUNET_ARM_Handle::mq, and msg.
Referenced by run().
void GNUNET_RPS_request_cancel | ( | struct GNUNET_RPS_Request_Handle * | rh | ) |
Cancel an issued request.
rh | handle of the pending request to be canceled |
rh | request handle of request to cancel |
Definition at line 1200 of file rps_api.c.
References cancel_stream(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_RPS_stream_cancel(), h, GNUNET_RPS_StreamRequestHandle::rps_handle, GNUNET_RPS_Request_Handle::rps_handle, RPS_sampler_destroy(), RPS_sampler_request_cancel(), GNUNET_RPS_Request_Handle::sampler, GNUNET_RPS_Request_Handle::sampler_rh, and GNUNET_RPS_Request_Handle::srh.
Referenced by do_shutdown(), GNUNET_RPS_disconnect(), and peers_ready_cb().
void GNUNET_RPS_request_single_info_cancel | ( | struct GNUNET_RPS_Request_Handle_Single_Info * | rhs | ) |
Cancel an issued single info request.
rhs | request handle of request to cancel |
Definition at line 1231 of file rps_api.c.
References cancel_stream(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_RPS_stream_cancel(), h, GNUNET_RPS_StreamRequestHandle::rps_handle, GNUNET_RPS_Request_Handle_Single_Info::rps_handle, RPS_sampler_destroy(), RPS_sampler_request_single_info_cancel(), GNUNET_RPS_Request_Handle_Single_Info::sampler, GNUNET_RPS_Request_Handle_Single_Info::sampler_rh, and GNUNET_RPS_Request_Handle_Single_Info::srh.
Referenced by GNUNET_RPS_disconnect(), and peer_info_ready_cb().
void GNUNET_RPS_view_request | ( | struct GNUNET_RPS_Handle * | rps_handle, |
uint32_t | num_updates, | ||
GNUNET_RPS_NotifyReadyCB | view_update_cb, | ||
void * | cls | ||
) |
Request updates of view.
rps_handle | handle to the rps service |
num_req_peers | number of peers we want to receive (0 for infinite updates) |
cls | a closure that will be given to the callback |
ready_cb | the callback called when the peers are available |
Definition at line 461 of file rps_api.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REQUEST, GNUNET_MQ_msg, GNUNET_MQ_send(), LOG, GNUNET_RPS_Handle::mq, msg, GNUNET_RPS_CS_DEBUG_ViewRequest::num_updates, rps_handle, GNUNET_RPS_Handle::view_update_cb, and GNUNET_RPS_Handle::view_update_cls.
Referenced by run().
struct GNUNET_RPS_StreamRequestHandle * GNUNET_RPS_stream_request | ( | struct GNUNET_RPS_Handle * | rps_handle, |
GNUNET_RPS_NotifyReadyCB | stream_input_cb, | ||
void * | cls | ||
) |
Request biased stream of peers that are being put into the sampler.
rps_handle | handle to the rps service |
cls | a closure that will be given to the callback |
ready_cb | the callback called when the peers are available |
Definition at line 503 of file rps_api.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REQUEST, GNUNET_MQ_msg, GNUNET_MQ_send(), LOG, GNUNET_RPS_Handle::mq, msg, new_stream_request(), and rps_handle.
Referenced by GNUNET_RPS_request_peer_info(), GNUNET_RPS_request_peers(), and run().
void GNUNET_RPS_stream_cancel | ( | struct GNUNET_RPS_StreamRequestHandle * | srh | ) |
Cancel a specific request for updates from the biased peer stream.
srh | The request handle to cancel |
Definition at line 598 of file rps_api.c.
References cancel_stream(), remove_stream_request(), rps_handle, GNUNET_RPS_StreamRequestHandle::rps_handle, and GNUNET_RPS_Handle::stream_requests_head.
Referenced by GNUNET_RPS_disconnect(), GNUNET_RPS_request_cancel(), and GNUNET_RPS_request_single_info_cancel().
void GNUNET_RPS_disconnect | ( | struct GNUNET_RPS_Handle * | h | ) |
Disconnect from the rps service.
h | the handle to the rps service |
Definition at line 1263 of file rps_api.c.
References GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_NSE_disconnect(), GNUNET_RPS_request_cancel(), GNUNET_RPS_request_single_info_cancel(), GNUNET_RPS_stream_cancel(), GNUNET_RPS_view_request_cancel(), h, LOG, GNUNET_ARM_Handle::mq, GNUNET_RPS_StreamRequestHandle::next, and srh_callback_peers.
Referenced by do_shutdown().