aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-11-26 15:07:34 +0000
committerNathan S. Evans <evans@in.tum.de>2010-11-26 15:07:34 +0000
commitba52efc2cea97fa337aa850f3cb23ecde0443a3b (patch)
treea40b0c1b12827bd8e4957745a90054b97732845b
parent873243c9b318c74471dae58184afd8d66df17d44 (diff)
downloadgnunet-ba52efc2cea97fa337aa850f3cb23ecde0443a3b.tar.gz
gnunet-ba52efc2cea97fa337aa850f3cb23ecde0443a3b.zip
use remainder from forward_count
-rw-r--r--src/dht/gnunet-service-dht.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index acadd58b5..fff683a7d 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -2845,17 +2845,20 @@ get_forward_count (unsigned int hop_count, size_t target_replication)
2845 } 2845 }
2846 2846
2847 random_value = 0; 2847 random_value = 0;
2848 /* FIXME: we use diameter as the expected number of hops, but with randomized routing we will likely route to more! */ 2848 forward_count = 1;
2849 target_value = target_replication / (diameter + ((float)target_replication * hop_count)); 2849 target_value = target_replication / (diameter + ((float)target_replication * hop_count));
2850 if (target_value > 1) 2850 if (target_value > 1)
2851 return (unsigned int)target_value; 2851 {
2852 /* Set forward count to floor of target_value */
2853 forward_count = (unsigned int)target_value;
2854 /* Subtract forward_count (floor) from target_value (yields value between 0 and 1) */
2855 target_value = target_value - forward_count;
2856 }
2852 else 2857 else
2853 random_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int)-1); 2858 random_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int)-1);
2854 2859
2855 if (random_value < (target_value * (unsigned int)-1)) 2860 if (random_value < (target_value * (unsigned int)-1))
2856 forward_count = 2; 2861 forward_count += 1;
2857 else
2858 forward_count = 1;
2859 2862
2860 return forward_count; 2863 return forward_count;
2861} 2864}