* 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;
* 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;
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,
/* 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++)
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);
}
}
/* 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 ();
*/
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;
* 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);
/**
*/
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.
/**
- * Handler to single requests from the client.
+ * Handler for a single request from a client.
*/
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.
struct GNUNET_CLIENT_Connection *service_conn;
};
+
/**
* @brief Send a request to the service.
*
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 */
}
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),
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);
}