aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-14 01:50:09 +0100
committerChristian Grothoff <grothoff@gnunet.org>2022-03-14 01:50:09 +0100
commitaa033d45165394bde735dcd19495fd420f5cd963 (patch)
tree101e8e8b21e1707f3dda02a31ad59a338c804a37 /src
parentd5285fadbc5a55960c62ebded84623ab8c0b9ea3 (diff)
downloadgnunet-aa033d45165394bde735dcd19495fd420f5cd963.tar.gz
gnunet-aa033d45165394bde735dcd19495fd420f5cd963.zip
slightly beautify alg
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index ea1f454bd..2f9cbab84 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -891,11 +891,8 @@ get_forward_count (uint16_t hop_count,
891 uint32_t random_value; 891 uint32_t random_value;
892 uint32_t forward_count; 892 uint32_t forward_count;
893 float target_value; 893 float target_value;
894 float rm1;
894 895
895 if (0 == target_replication)
896 target_replication = 1; /* 0 is verboten */
897 if (target_replication > GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL)
898 target_replication = GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL;
899 if (hop_count > GDS_NSE_get () * 4.0) 896 if (hop_count > GDS_NSE_get () * 4.0)
900 { 897 {
901 /* forcefully terminate */ 898 /* forcefully terminate */
@@ -910,15 +907,15 @@ get_forward_count (uint16_t hop_count,
910 /* Once we have reached our ideal number of hops, only forward to 1 peer */ 907 /* Once we have reached our ideal number of hops, only forward to 1 peer */
911 return 1; 908 return 1;
912 } 909 }
913 /* bound by system-wide maximum */ 910 /* bound by system-wide maximum and minimum */
911 if (0 == target_replication)
912 target_replication = 1; /* 0 is verboten */
914 target_replication = 913 target_replication =
915 GNUNET_MIN (GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL, 914 GNUNET_MIN (GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL,
916 target_replication); 915 target_replication);
916 rm1 = target_replication - 1.0;
917 target_value = 917 target_value =
918 1 + (target_replication - 1.0) / (GDS_NSE_get () 918 1 + (rm1) / (GDS_NSE_get () + (rm1 * hop_count));
919 + ((float) (target_replication - 1.0)
920 * hop_count));
921
922 919
923 /* Set forward count to floor of target_value */ 920 /* Set forward count to floor of target_value */
924 forward_count = (uint32_t) target_value; 921 forward_count = (uint32_t) target_value;