From 69f439525cabfd0b65d5875e49d306588587cb23 Mon Sep 17 00:00:00 2001 From: Julius Bünger Date: Thu, 20 Sep 2018 01:04:17 +0200 Subject: Be a little bit more consistent in style --- src/rps/gnunet-service-rps.c | 20 ++++++++++---------- src/rps/gnunet-service-rps_sampler.c | 22 +++++++++++----------- src/rps/gnunet-service-rps_sampler.h | 8 +++++--- src/rps/rps_api.c | 16 +++++++++++----- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index ec6c651d9..40f576d3e 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c @@ -2347,9 +2347,9 @@ clients_notify_stream_peer (uint64_t num_peers, * Put random peer from sampler into the view as history update. */ static void -hist_update (void *cls, - struct GNUNET_PeerIdentity *ids, - uint32_t num_peers) +hist_update (const struct GNUNET_PeerIdentity *ids, + uint32_t num_peers, + void *cls) { unsigned int i; (void) cls; @@ -2852,9 +2852,9 @@ nse_callback (void *cls, * Sends those to the requesting client. */ static void -client_respond (void *cls, - struct GNUNET_PeerIdentity *peer_ids, - uint32_t num_peers) +client_respond (const struct GNUNET_PeerIdentity *peer_ids, + uint32_t num_peers, + void *cls) { struct ReplyCls *reply_cls = cls; uint32_t i; @@ -2937,9 +2937,9 @@ handle_client_request (void *cls, reply_cls->id = ntohl (msg->id); reply_cls->cli_ctx = cli_ctx; reply_cls->req_handle = RPS_sampler_get_n_rand_peers (client_sampler, + num_peers, client_respond, - reply_cls, - num_peers); + reply_cls); GNUNET_assert (NULL != cli_ctx); GNUNET_CONTAINER_DLL_insert (cli_ctx->rep_cls_head, @@ -3894,9 +3894,9 @@ do_round (void *cls) /* Update view with peers from history */ RPS_sampler_get_n_rand_peers (prot_sampler, + final_size - second_border, hist_update, - NULL, - final_size - second_border); + NULL); // TODO change the peer_flags accordingly for (i = 0; i < View_size (); i++) diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c index fdd500aa1..0de15bbc0 100644 --- a/src/rps/gnunet-service-rps_sampler.c +++ b/src/rps/gnunet-service-rps_sampler.c @@ -272,7 +272,7 @@ check_n_peers_ready (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "returning %" PRIX32 " peers to the client\n", req_handle->num_peers); - req_handle->callback (req_handle->cls, req_handle->ids, req_handle->num_peers); + req_handle->callback (req_handle->ids, req_handle->num_peers, req_handle->cls); RPS_sampler_request_cancel (req_handle); } @@ -647,14 +647,14 @@ sampler_mod_get_rand_peer (void *cls) } /* More reasons to wait could be added here */ - GNUNET_STATISTICS_set (stats, - "# client sampler element input", - s_elem->num_peers, - GNUNET_NO); - GNUNET_STATISTICS_set (stats, - "# client sampler element change", - s_elem->num_change, - GNUNET_NO); +// GNUNET_STATISTICS_set (stats, +// "# client sampler element input", +// s_elem->num_peers, +// GNUNET_NO); +// GNUNET_STATISTICS_set (stats, +// "# client sampler element change", +// s_elem->num_change, +// GNUNET_NO); RPS_sampler_elem_reinit (s_elem); s_elem->last_client_request = GNUNET_TIME_absolute_get (); @@ -683,9 +683,9 @@ sampler_mod_get_rand_peer (void *cls) */ 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, - uint32_t num_peers) + void *cls) { uint32_t i; struct RPS_SamplerRequestHandle *req_handle; diff --git a/src/rps/gnunet-service-rps_sampler.h b/src/rps/gnunet-service-rps_sampler.h index c44844f96..6b386596f 100644 --- a/src/rps/gnunet-service-rps_sampler.h +++ b/src/rps/gnunet-service-rps_sampler.h @@ -46,8 +46,9 @@ struct RPS_SamplerRequestHandle; * to be freed */ typedef void -(*RPS_sampler_n_rand_peers_ready_cb) (void *cls, - struct GNUNET_PeerIdentity *ids, uint32_t num_peers); +(*RPS_sampler_n_rand_peers_ready_cb) (const struct GNUNET_PeerIdentity *ids, + uint32_t num_peers, + void *cls); /** @@ -135,8 +136,9 @@ RPS_sampler_reinitialise_by_value (struct RPS_Sampler *sampler, */ 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, uint32_t num_peers); + void *cls); /** * Cancle a request issued through #RPS_sampler_n_rand_peers_ready_cb. diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c index 00f817468..7afe21d3a 100644 --- a/src/rps/rps_api.c +++ b/src/rps/rps_api.c @@ -78,7 +78,7 @@ struct GNUNET_RPS_Handle /** - * Handler to single requests from the client. + * Handler for a single request from a client. */ struct GNUNET_RPS_Request_Handle { @@ -95,7 +95,12 @@ struct GNUNET_RPS_Request_Handle /** * The number of requested peers. */ - uint32_t num_peers; + uint32_t num_requests; + + /** + * @brief The Sampler for the client request + */ + struct RPS_Sampler *sampler; /** * The callback to be called when we receive an answer. @@ -131,6 +136,7 @@ struct cb_cls_pack struct GNUNET_CLIENT_Connection *service_conn; }; + /** * @brief Send a request to the service. * @@ -170,7 +176,7 @@ resend_requests_iterator (void *cls, uint32_t key, void *value) const struct GNUNET_RPS_Request_Handle *req_handle = value; (void) key; - send_request (h, req_handle->id, req_handle->num_peers); + send_request (h, req_handle->id, req_handle->num_requests); return GNUNET_YES; /* continue iterating */ } @@ -248,7 +254,7 @@ handle_reply (void *cls, GNUNET_CONTAINER_multihashmap32_contains (h->req_handlers, id)); rh = GNUNET_CONTAINER_multihashmap32_get (h->req_handlers, id); GNUNET_assert (NULL != rh); - GNUNET_assert (rh->num_peers == ntohl (msg->num_peers)); + GNUNET_assert (rh->num_requests == ntohl (msg->num_peers)); GNUNET_CONTAINER_multihashmap32_remove_all (h->req_handlers, id); rh->ready_cb (rh->ready_cb_cls, ntohl (msg->num_peers), @@ -422,7 +428,7 @@ handle_stream_input (void *cls, peers = (struct GNUNET_PeerIdentity *) &msg[1]; GNUNET_assert (NULL != h); GNUNET_assert (NULL != h->stream_input_cb); - h->stream_input_cb (h->stream_input_cb, ntohl (msg->num_peers), peers); + h->stream_input_cb (h->stream_input_cls, ntohl (msg->num_peers), peers); } -- cgit v1.2.3