aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-10-21 15:26:47 +0000
committerNathan S. Evans <evans@in.tum.de>2010-10-21 15:26:47 +0000
commit8a367889d48cf2c2afee4a8679249871ff4dd2ca (patch)
tree0f01478103ac42ecbf745a4265c5ad94cdabb745
parent7c1bbf7504c50b6e3465b9d05b5cc319f8c634db (diff)
downloadgnunet-8a367889d48cf2c2afee4a8679249871ff4dd2ca.tar.gz
gnunet-8a367889d48cf2c2afee4a8679249871ff4dd2ca.zip
oops
-rw-r--r--src/dht/gnunet-service-dht.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 220763529..5df8c33e3 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -2887,6 +2887,7 @@ converge_distance (const GNUNET_HashCode *target,
2887 unsigned long long ret; 2887 unsigned long long ret;
2888 unsigned int other_matching_bits; 2888 unsigned int other_matching_bits;
2889 double base_converge_modifier = .1; 2889 double base_converge_modifier = .1;
2890 double temp_modifier;
2890 double calc_value; 2891 double calc_value;
2891 double exponent; 2892 double exponent;
2892 int curr_max_hops; 2893 int curr_max_hops;
@@ -2897,14 +2898,14 @@ converge_distance (const GNUNET_HashCode *target,
2897 curr_max_hops = (estimate_diameter() + 1) * 2; 2898 curr_max_hops = (estimate_diameter() + 1) * 2;
2898 2899
2899 if (converge_modifier > 0) 2900 if (converge_modifier > 0)
2900 converge_modifier = converge_modifier * base_converge_modifier; 2901 temp_modifier = converge_modifier * base_converge_modifier;
2901 else 2902 else
2902 { 2903 {
2903 converge_modifier = base_converge_modifier; 2904 temp_modifier = base_converge_modifier;
2904 base_converge_modifier = 0.0; 2905 base_converge_modifier = 0.0;
2905 } 2906 }
2906 2907
2907 GNUNET_assert(converge_modifier > 0); 2908 GNUNET_assert(temp_modifier > 0);
2908 2909
2909 other_matching_bits = GNUNET_CRYPTO_hash_matching_bits(target, &peer->id.hashPubKey); 2910 other_matching_bits = GNUNET_CRYPTO_hash_matching_bits(target, &peer->id.hashPubKey);
2910 2911
@@ -2913,20 +2914,20 @@ converge_distance (const GNUNET_HashCode *target,
2913 case DHT_CONVERGE_RANDOM: 2914 case DHT_CONVERGE_RANDOM:
2914 return 1; /* Always return 1, choose equally among all peers */ 2915 return 1; /* Always return 1, choose equally among all peers */
2915 case DHT_CONVERGE_LINEAR: 2916 case DHT_CONVERGE_LINEAR:
2916 calc_value = hops * curr_max_hops * converge_modifier; 2917 calc_value = hops * curr_max_hops * temp_modifier;
2917 break; 2918 break;
2918 case DHT_CONVERGE_SQUARE: 2919 case DHT_CONVERGE_SQUARE:
2919 /** 2920 /**
2920 * Simple square based curve. 2921 * Simple square based curve.
2921 */ 2922 */
2922 calc_value = (sqrt(hops) / sqrt(curr_max_hops)) * (curr_max_hops / (curr_max_hops * converge_modifier)); 2923 calc_value = (sqrt(hops) / sqrt(curr_max_hops)) * (curr_max_hops / (curr_max_hops * temp_modifier));
2923 break; 2924 break;
2924 case DHT_CONVERGE_EXPONENTIAL: 2925 case DHT_CONVERGE_EXPONENTIAL:
2925 /** 2926 /**
2926 * Simple exponential curve. 2927 * Simple exponential curve.
2927 */ 2928 */
2928 if (base_converge_modifier > 0) 2929 if (base_converge_modifier > 0)
2929 calc_value = (converge_modifier * hops * hops) / curr_max_hops; 2930 calc_value = (temp_modifier * hops * hops) / curr_max_hops;
2930 else 2931 else
2931 calc_value = (hops * hops) / curr_max_hops; 2932 calc_value = (hops * hops) / curr_max_hops;
2932 break; 2933 break;
@@ -3230,7 +3231,7 @@ select_peer (const GNUNET_HashCode * target,
3230 /* Now actually choose a peer */ 3231 /* Now actually choose a peer */
3231 selected = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, total_distance); 3232 selected = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, total_distance);
3232 3233
3233 /* Put the sorted closest peers into the possible bins first, in case of overflow. */ 3234 /* Go over closest sorted peers. */
3234 for (i = 0; i < offset; i++) 3235 for (i = 0; i < offset; i++)
3235 { 3236 {
3236 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bloom, &sorted_closest[i]->id.hashPubKey)) 3237 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bloom, &sorted_closest[i]->id.hashPubKey))