diff options
author | Bart Polot <bart@net.in.tum.de> | 2015-01-28 16:56:47 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2015-01-28 16:56:47 +0000 |
commit | f211dbecd475ad630e54b29e2bd054c139aa1273 (patch) | |
tree | 414ff9e5452d477cd00a6a2cd0998001192e0489 /src | |
parent | 9a73ec66434eb1bb579dda36cb7a1c4c6fd10b8b (diff) | |
download | gnunet-f211dbecd475ad630e54b29e2bd054c139aa1273.tar.gz gnunet-f211dbecd475ad630e54b29e2bd054c139aa1273.zip |
- never resize to 0
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 4 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps_sampler.c | 29 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps_sampler.h | 9 |
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 | 420 | static void |
421 | RPS_sampler_resize (unsigned int new_size) | 421 | sampler_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 | */ | ||
488 | void | ||
489 | RPS_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 | */ | ||
501 | void | ||
502 | RPS_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 | */ | ||
91 | void | ||
92 | RPS_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 |