gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 02/02: slightly beautify alg


From: gnunet
Subject: [gnunet] 02/02: slightly beautify alg
Date: Mon, 14 Mar 2022 01:50:18 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit aa033d45165394bde735dcd19495fd420f5cd963
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Mon Mar 14 01:50:09 2022 +0100

    slightly beautify alg
---
 src/dht/gnunet-service-dht_neighbours.c | 15 ++++++---------
 1 file 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;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]