[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35030 - gnunet/src/rps
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35030 - gnunet/src/rps |
Date: |
Wed, 28 Jan 2015 17:39:03 +0100 |
Author: bartpolot
Date: 2015-01-28 17:39:02 +0100 (Wed, 28 Jan 2015)
New Revision: 35030
Modified:
gnunet/src/rps/gnunet-service-rps.c
gnunet/src/rps/gnunet-service-rps_sampler.c
gnunet/src/rps/gnunet-service-rps_sampler.h
Log:
- get size direcly from sampler
Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-01-28 16:39:02 UTC (rev 35029)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-01-28 16:39:02 UTC (rev 35030)
@@ -203,12 +203,6 @@
/**
- * The actual size of the sampler
- */
-static unsigned int sampler_size;
-//size_t sampler_size;
-
-/**
* The size of sampler we need to be able to satisfy the client's need of
* random peers.
*/
@@ -712,6 +706,7 @@
resize_wrapper ()
{
uint32_t bigger_size;
+ unsigned int sampler_size;
// TODO statistics
@@ -721,15 +716,14 @@
bigger_size = sampler_size_est_need;
// TODO respect the min, max
+ sampler_size = RPS_sampler_get_size ();
if (sampler_size > bigger_size * 4)
{ /* Shrinking */
- sampler_size = sampler_size / 2;
- RPS_sampler_resize (sampler_size);
+ RPS_sampler_resize (sampler_size / 2);
}
else if (sampler_size < bigger_size)
{ /* Growing */
- sampler_size = sampler_size * 2;
- RPS_sampler_resize (sampler_size);
+ RPS_sampler_resize (sampler_size * 2);
}
}
@@ -794,8 +788,8 @@
//double scale; // TODO this might go gloabal/config
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received a ns estimate - logest: %f, std_dev: %f (old_size: %f)\n",
- logestimate, std_dev, sampler_size);
+ "Received a ns estimate - logest: %f, std_dev: %f (old_size: %f)\n",
+ logestimate, std_dev, RPS_sampler_get_size());
//scale = .01;
estimate = GNUNET_NSE_log_estimate_to_n (logestimate);
// GNUNET_NSE_log_estimate_to_n (logestimate);
@@ -1402,7 +1396,7 @@
if (NULL != peer_ctx->send_channel
&& ch != peer_ctx->send_channel)
GNUNET_CADET_channel_destroy (peer_ctx->send_channel);
-
+
if (NULL != peer_ctx->recv_channel
&& ch != peer_ctx->recv_channel)
GNUNET_CADET_channel_destroy (peer_ctx->recv_channel);
@@ -1658,7 +1652,6 @@
RPS_sampler_init (sampler_size_est_need, max_round_interval,
insertCB, NULL, removeCB, NULL);
- sampler_size = sampler_size_est_need;
/* Initialise push and pull maps */
push_list = NULL;
Modified: gnunet/src/rps/gnunet-service-rps_sampler.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps_sampler.c 2015-01-28 16:39:02 UTC (rev
35029)
+++ gnunet/src/rps/gnunet-service-rps_sampler.c 2015-01-28 16:39:02 UTC (rev
35030)
@@ -82,7 +82,7 @@
* Time of last request.
*/
struct GNUNET_TIME_Absolute last_client_request;
-
+
/**
* Flag that indicates that we are not holding a valid PeerID right now.
*/
@@ -251,7 +251,7 @@
/**
* Callback to _get_rand_peer() used by _get_n_rand_peers().
*
- * Checks whether all n peers are available. If they are,
+ * Checks whether all n peers are available. If they are,
* give those back.
*/
void
@@ -274,7 +274,7 @@
"SAMPLER: returning %" PRIX32 " peers to the client\n",
n_peers_cls->num_peers);
n_peers_cls->callback (n_peers_cls->cls, n_peers_cls->ids,
n_peers_cls->num_peers);
-
+
GNUNET_free (n_peers_cls);
}
}
@@ -315,7 +315,7 @@
RPS_sampler_elem_create (void)
{
struct RPS_SamplerElement *s;
-
+
s = GNUNET_new (struct RPS_SamplerElement);
RPS_sampler_elem_reinit (s);
@@ -352,7 +352,7 @@
&other_hash);
if ( EMPTY == s_elem->is_empty )
- {
+ {
LOG (GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Got PeerID %s; Simply accepting
(was empty previously).\n",
GNUNET_i2s(other));
s_elem->peer_id = *other;
@@ -400,7 +400,18 @@
s_elem->is_empty = NOT_EMPTY;
}
+/**
+ * Get the size of the sampler.
+ *
+ * @return the size of the sampler
+ */
+unsigned int
+RPS_sampler_get_size ()
+{
+ return sampler->sampler_size;
+}
+
/**
* Grow or shrink the size of the sampler.
*
@@ -464,7 +475,7 @@
return;
}
- GNUNET_assert(sampler->sampler_size == new_size);
+ GNUNET_assert (sampler->sampler_size == new_size);
LOG (GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Finished growing/shrinking.\n"); //
remove
}
@@ -473,7 +484,7 @@
* Initialise a tuple of sampler elements.
*
* @param init_size the size the sampler is initialised with
- * @param ins_cb the callback that will be called on every PeerID that is
+ * @param ins_cb the callback that will be called on every PeerID that is
* newly inserted into a sampler element
* @param ins_cls the closure given to #ins_cb
* @param rem_cb the callback that will be called on every PeerID that is
@@ -766,7 +777,7 @@
count = 0;
for ( i = 0 ; i < sampler->sampler_size ; i++ )
{
- if ( 0 == GNUNET_CRYPTO_cmp_peer_identity
(&sampler->sampler_elements[i]->peer_id, id)
+ if ( 0 == GNUNET_CRYPTO_cmp_peer_identity
(&sampler->sampler_elements[i]->peer_id, id)
&& EMPTY != sampler->sampler_elements[i]->is_empty)
count++;
}
@@ -786,7 +797,7 @@
GNUNET_SCHEDULER_cancel (task);
GNUNET_CONTAINER_multihashmap_remove (get_peer_tasks, key, value);
-
+
return GNUNET_YES;
}
Modified: gnunet/src/rps/gnunet-service-rps_sampler.h
===================================================================
--- gnunet/src/rps/gnunet-service-rps_sampler.h 2015-01-28 16:39:02 UTC (rev
35029)
+++ gnunet/src/rps/gnunet-service-rps_sampler.h 2015-01-28 16:39:02 UTC (rev
35030)
@@ -65,7 +65,15 @@
*/
//struct RPS_Sampler;
+/**
+ * Get the size of the sampler.
+ *
+ * @return the size of the sampler
+ */
+unsigned int
+RPS_sampler_get_size ();
+
/**
* Grow or shrink the size of the sampler.
*
@@ -80,7 +88,7 @@
*
* @param init_size the size the sampler is initialised with
* @param id with which all newly created sampler elements are initialised
- * @param ins_cb the callback that will be called on every PeerID that is
+ * @param ins_cb the callback that will be called on every PeerID that is
* newly inserted into a sampler element
* @param ins_cls the closure given to #ins_cb
* @param rem_cb the callback that will be called on every PeerID that is
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35030 - gnunet/src/rps,
gnunet <=