gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] 01/04: RPS api: Clean code and logging


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 01/04: RPS api: Clean code and logging
Date: Thu, 11 Oct 2018 14:48:52 +0200

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a commit to branch master
in repository gnunet.

commit 0cdd1af62ca1f17fdca31be6e28ad24dcf3293b1
Author: Julius Bünger <address@hidden>
AuthorDate: Thu Oct 11 14:09:36 2018 +0200

    RPS api: Clean code and logging
---
 src/rps/rps_api.c | 64 ++++++++++++++++++-------------------------------------
 1 file changed, 21 insertions(+), 43 deletions(-)

diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 7d0674aff..47c4f019d 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -267,6 +267,9 @@ collect_peers_cb (void *cls,
 {
   struct GNUNET_RPS_Request_Handle *rh = cls;
 
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Service sent %" PRIu64 " peers from stream\n",
+       num_peers);
   for (uint64_t i = 0; i < num_peers; i++)
   {
     RPS_sampler_update (rh->sampler, &peers[i]);
@@ -274,44 +277,6 @@ collect_peers_cb (void *cls,
 }
 
 
-/**
- * @brief Create new request handle
- *
- * @param rps_handle Handle to the service
- * @param num_requests Number of requests
- * @param ready_cb Callback
- * @param cls Closure
- *
- * @return The newly created request handle
- */
-static struct GNUNET_RPS_Request_Handle *
-new_request_handle (struct GNUNET_RPS_Handle *rps_handle,
-                    uint64_t num_requests,
-                    GNUNET_RPS_NotifyReadyCB ready_cb,
-                    void *cls)
-{
-  struct GNUNET_RPS_Request_Handle *rh;
-
-  rh = GNUNET_new (struct GNUNET_RPS_Request_Handle);
-  rh->rps_handle = rps_handle;
-  rh->num_requests = num_requests;
-  rh->sampler = RPS_sampler_mod_init (num_requests,
-                                      GNUNET_TIME_UNIT_SECONDS); // TODO 
remove this time-stuff
-  rh->sampler_rh = RPS_sampler_get_n_rand_peers (rh->sampler,
-                                                 num_requests,
-                                                 peers_ready_cb,
-                                                 rh);
-  rh->srh = GNUNET_RPS_stream_request (rps_handle,
-                                       0, /* infinite updates */
-                                       collect_peers_cb,
-                                       rh); /* cls */
-  rh->ready_cb = ready_cb;
-  rh->ready_cb_cls = cls;
-
-  return rh;
-}
-
-
 /* Get internals for debugging/profiling purposes */
 
 /**
@@ -690,11 +655,24 @@ GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle 
*rps_handle,
 {
   struct GNUNET_RPS_Request_Handle *rh;
 
-  rh = new_request_handle (rps_handle,
-                           num_req_peers,
-                           ready_cb,
-                           cls);
-
+  LOG (GNUNET_ERROR_TYPE_INFO,
+       "Client requested %" PRIu32 " peers\n",
+       num_req_peers);
+  rh = GNUNET_new (struct GNUNET_RPS_Request_Handle);
+  rh->rps_handle = rps_handle;
+  rh->num_requests = num_req_peers;
+  rh->sampler = RPS_sampler_mod_init (num_req_peers,
+                                      GNUNET_TIME_UNIT_SECONDS); // TODO 
remove this time-stuff
+  rh->sampler_rh = RPS_sampler_get_n_rand_peers (rh->sampler,
+                                                 num_req_peers,
+                                                 peers_ready_cb,
+                                                 rh);
+  rh->srh = GNUNET_RPS_stream_request (rps_handle,
+                                       0, /* infinite updates */
+                                       collect_peers_cb,
+                                       rh); /* cls */
+  rh->ready_cb = ready_cb;
+  rh->ready_cb_cls = cls;
 
   return rh;
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]