aboutsummaryrefslogtreecommitdiff
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)
downloadgnunet-f211dbecd475ad630e54b29e2bd054c139aa1273.tar.gz
gnunet-f211dbecd475ad630e54b29e2bd054c139aa1273.zip
- 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,
790 790
791 LOG (GNUNET_ERROR_TYPE_DEBUG, 791 LOG (GNUNET_ERROR_TYPE_DEBUG,
792 "Received a ns estimate - logest: %f, std_dev: %f (old_size: %u)\n", 792 "Received a ns estimate - logest: %f, std_dev: %f (old_size: %u)\n",
793 logestimate, std_dev, RPS_sampler_get_size()); 793 logestimate, std_dev, RPS_sampler_get_size ());
794 //scale = .01; 794 //scale = .01;
795 estimate = GNUNET_NSE_log_estimate_to_n (logestimate); 795 estimate = GNUNET_NSE_log_estimate_to_n (logestimate);
796 // GNUNET_NSE_log_estimate_to_n (logestimate); 796 // GNUNET_NSE_log_estimate_to_n (logestimate);
797 estimate = pow (estimate, 1./3); 797 estimate = pow (estimate, 1.0 / 3);
798 // TODO add if std_dev is a number 798 // TODO add if std_dev is a number
799 // estimate += (std_dev * scale); 799 // estimate += (std_dev * scale);
800 if (0 < ceil (estimate)) 800 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 ()
417 * 417 *
418 * @param new_size the new size of the sampler 418 * @param new_size the new size of the sampler
419 */ 419 */
420 void 420static void
421RPS_sampler_resize (unsigned int new_size) 421sampler_resize (unsigned int new_size)
422{ 422{
423 unsigned int old_size; 423 unsigned int old_size;
424 uint32_t i; 424 uint32_t i;
@@ -481,6 +481,31 @@ RPS_sampler_resize (unsigned int new_size)
481 481
482 482
483/** 483/**
484 * Grow or shrink the size of the sampler.
485 *
486 * @param new_size the new size of the sampler
487 */
488void
489RPS_sampler_resize (unsigned int new_size)
490{
491 GNUNET_assert (0 < new_size);
492 sampler_resize (new_size);
493}
494
495
496/**
497 * Empty the sampler.
498 *
499 * @param new_size the new size of the sampler
500 */
501void
502RPS_sampler_empty ()
503{
504 sampler_resize (0);
505}
506
507
508/**
484 * Initialise a tuple of sampler elements. 509 * Initialise a tuple of sampler elements.
485 * 510 *
486 * @param init_size the size the sampler is initialised with 511 * @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);
84 84
85 85
86/** 86/**
87 * Empty the sampler.
88 *
89 * @param new_size the new size of the sampler
90 */
91void
92RPS_sampler_empty ();
93
94
95/**
87 * Initialise a tuple of samplers. 96 * Initialise a tuple of samplers.
88 * 97 *
89 * @param init_size the size the sampler is initialised with 98 * @param init_size the size the sampler is initialised with