gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: -fix expiration calculation for


From: gnunet
Subject: [taler-anastasis] branch master updated: -fix expiration calculation for free services
Date: Mon, 26 Jul 2021 18:32:06 +0200

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 3ba9a77  -fix expiration calculation for free services
3ba9a77 is described below

commit 3ba9a7714839eb1416c4e97b6015f0ef8dbf588f
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Mon Jul 26 18:32:04 2021 +0200

    -fix expiration calculation for free services
---
 src/reducer/anastasis_api_backup_redux.c | 39 +++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/reducer/anastasis_api_backup_redux.c 
b/src/reducer/anastasis_api_backup_redux.c
index bffbff9..cea1360 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -26,6 +26,14 @@
 #include "anastasis_api_redux.h"
 #include <taler/taler_merchant_service.h>
 
+/**
+ * How long do Anastasis providers store data if the service
+ * is free? Must match #ANASTASIS_MAX_YEARS_STORAGE from
+ * anastasis-httpd.h.
+ */
+#define ANASTASIS_FREE_STORAGE GNUNET_TIME_relative_multiply ( \
+    GNUNET_TIME_UNIT_YEARS, 5)
+
 /**
  * CPU limiter: do not evaluate more than 16k
  * possible policy combinations to find the "best"
@@ -2273,6 +2281,7 @@ update_expiration_cost (json_t *state,
   struct Costs *costs = NULL;
   unsigned int years;
   json_t *providers;
+  bool is_free = true;
 
   providers = json_object_get (state,
                                "authentication_providers");
@@ -2423,18 +2432,6 @@ update_expiration_cost (json_t *state,
                        0);
   }
 
-  /* update 'expiration' in state */
-  {
-    json_t *eo;
-
-    (void) GNUNET_TIME_round_abs (&expiration);
-    eo = GNUNET_JSON_from_time_abs (expiration);
-    GNUNET_assert (0 ==
-                   json_object_set_new (state,
-                                        "expiration",
-                                        eo));
-  }
-
   /* convert 'costs' into state */
   {
     json_t *arr;
@@ -2456,6 +2453,7 @@ update_expiration_cost (json_t *state,
         GNUNET_assert (0 ==
                        json_array_append_new (arr,
                                               ao));
+        is_free = false;
       }
       GNUNET_free (costs);
       costs = nxt;
@@ -2465,6 +2463,22 @@ update_expiration_cost (json_t *state,
                                         "upload_fees",
                                         arr));
   }
+
+  if (is_free)
+    expiration = GNUNET_TIME_relative_to_absolute (ANASTASIS_FREE_STORAGE);
+  /* update 'expiration' in state */
+  {
+    json_t *eo;
+
+    (void) GNUNET_TIME_round_abs (&expiration);
+    eo = GNUNET_JSON_from_time_abs (expiration);
+    GNUNET_assert (0 ==
+                   json_object_set_new (state,
+                                        "expiration",
+                                        eo));
+  }
+
+
   return GNUNET_OK;
 }
 
@@ -2519,7 +2533,6 @@ done_policy_review (json_t *state,
     }
     if (0 == exp.abs_value_us)
       exp = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS);
-
     if (GNUNET_OK !=
         update_expiration_cost (state,
                                 exp))

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