summaryrefslogtreecommitdiff
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)
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,
uint32_t random_value;
uint32_t forward_count;
float target_value;
+ float rm1;
- if (0 == target_replication)
- target_replication = 1; /* 0 is verboten */
- if (target_replication > GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL)
- target_replication = GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL;
if (hop_count > GDS_NSE_get () * 4.0)
{
/* forcefully terminate */
@@ -910,15 +907,15 @@ get_forward_count (uint16_t hop_count,
/* Once we have reached our ideal number of hops, only forward to 1 peer */
return 1;
}
- /* bound by system-wide maximum */
+ /* bound by system-wide maximum and minimum */
+ if (0 == target_replication)
+ target_replication = 1; /* 0 is verboten */
target_replication =
GNUNET_MIN (GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL,
target_replication);
+ rm1 = target_replication - 1.0;
target_value =
- 1 + (target_replication - 1.0) / (GDS_NSE_get ()
- + ((float) (target_replication - 1.0)
- * hop_count));
-
+ 1 + (rm1) / (GDS_NSE_get () + (rm1 * hop_count));
/* Set forward count to floor of target_value */
forward_count = (uint32_t) target_value;