summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2015-01-28 16:56:47 +0000
committerBart Polot <bart@net.in.tum.de>2015-01-28 16:56:47 +0000
commitf211dbecd475ad630e54b29e2bd054c139aa1273 (patch)
tree414ff9e5452d477cd00a6a2cd0998001192e0489 /src
parent9a73ec66434eb1bb579dda36cb7a1c4c6fd10b8b (diff)
- never resize to 0
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c4
-rw-r--r--src/rps/gnunet-service-rps_sampler.c29
-rw-r--r--src/rps/gnunet-service-rps_sampler.h9
3 files changed, 38 insertions, 4 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 4a0027d72..e3e2c02c0 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -790,11 +790,11 @@ nse_callback (void *cls, struct GNUNET_TIME_Absolute timestamp,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received a ns estimate - logest: %f, std_dev: %f (old_size: %u)\n",
- logestimate, std_dev, RPS_sampler_get_size());
+ logestimate, std_dev, RPS_sampler_get_size ());
//scale = .01;
estimate = GNUNET_NSE_log_estimate_to_n (logestimate);
// GNUNET_NSE_log_estimate_to_n (logestimate);
- estimate = pow (estimate, 1./3);
+ estimate = pow (estimate, 1.0 / 3);
// TODO add if std_dev is a number
// estimate += (std_dev * scale);
if (0 < ceil (estimate))
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c
index 01d8aa748..419110440 100644
--- a/src/rps/gnunet-service-rps_sampler.c
+++ b/src/rps/gnunet-service-rps_sampler.c
@@ -417,8 +417,8 @@ RPS_sampler_get_size ()
*
* @param new_size the new size of the sampler
*/
- void
-RPS_sampler_resize (unsigned int new_size)
+static void
+sampler_resize (unsigned int new_size)
{
unsigned int old_size;
uint32_t i;
@@ -481,6 +481,31 @@ RPS_sampler_resize (unsigned int new_size)
/**
+ * Grow or shrink the size of the sampler.
+ *
+ * @param new_size the new size of the sampler
+ */
+void
+RPS_sampler_resize (unsigned int new_size)
+{
+ GNUNET_assert (0 < new_size);
+ sampler_resize (new_size);
+}
+
+
+/**
+ * Empty the sampler.
+ *
+ * @param new_size the new size of the sampler
+ */
+void
+RPS_sampler_empty ()
+{
+ sampler_resize (0);
+}
+
+
+/**
* Initialise a tuple of sampler elements.
*
* @param init_size the size the sampler is initialised with
diff --git a/src/rps/gnunet-service-rps_sampler.h b/src/rps/gnunet-service-rps_sampler.h
index 4949ef9c6..d0ac11d0d 100644
--- a/src/rps/gnunet-service-rps_sampler.h
+++ b/src/rps/gnunet-service-rps_sampler.h
@@ -84,6 +84,15 @@ RPS_sampler_resize (unsigned int new_size);
/**
+ * Empty the sampler.
+ *
+ * @param new_size the new size of the sampler
+ */
+void
+RPS_sampler_empty ();
+
+
+/**
* Initialise a tuple of samplers.
*
* @param init_size the size the sampler is initialised with