gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 05/05: Util: Introduced GNUNET_TIME_relative_multiply_double.


From: gnunet
Subject: [gnunet] 05/05: Util: Introduced GNUNET_TIME_relative_multiply_double.
Date: Fri, 15 Dec 2023 10:53:29 +0100

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

t3sserakt pushed a commit to branch master
in repository gnunet.

commit f387a7b920b926a37b8840d0783b496b430b3273
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Fri Dec 15 10:53:08 2023 +0100

    Util: Introduced GNUNET_TIME_relative_multiply_double.
---
 src/include/gnunet_time_lib.h | 11 +++++++++++
 src/lib/util/time.c           |  6 +++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h
index 308aadb53..88dafc62c 100644
--- a/src/include/gnunet_time_lib.h
+++ b/src/include/gnunet_time_lib.h
@@ -615,6 +615,17 @@ GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute 
start,
                                struct GNUNET_TIME_Relative duration);
 
 
+/**
+ * Multiply relative time by a given factor.
+ *
+ * @param rel some duration
+ * @param factor double to multiply with
+ * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor
+ */
+struct GNUNET_TIME_Relative
+GNUNET_TIME_relative_multiply_double (struct GNUNET_TIME_Relative rel,
+                                      double factor);
+
 /**
  * Multiply relative time by a given factor.
  *
diff --git a/src/lib/util/time.c b/src/lib/util/time.c
index 84957c6a8..1bc7baeaa 100644
--- a/src/lib/util/time.c
+++ b/src/lib/util/time.c
@@ -501,7 +501,7 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative 
rel,
 
 
 struct GNUNET_TIME_Relative
-relative_multiply_double (struct GNUNET_TIME_Relative rel,
+GNUNET_TIME_relative_multiply_double (struct GNUNET_TIME_Relative rel,
                           double factor)
 {
   struct GNUNET_TIME_Relative out;
@@ -833,7 +833,7 @@ GNUNET_TIME_randomized_backoff (struct GNUNET_TIME_Relative 
rt,
   double r = (rand () % 500) / 1000.0;
   struct GNUNET_TIME_Relative t;
 
-  t = relative_multiply_double (
+  t = GNUNET_TIME_relative_multiply_double (
     GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, rt),
     2 + r);
   return GNUNET_TIME_relative_min (threshold, t);
@@ -852,7 +852,7 @@ GNUNET_TIME_randomize (struct GNUNET_TIME_Relative r)
 {
   double d = ((rand () % 1001) + 500) / 1000.0;
 
-  return relative_multiply_double (r, d);
+  return GNUNET_TIME_relative_multiply_double (r, d);
 }
 
 

-- 
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]