gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: add timeout_ms support (except


From: gnunet
Subject: [taler-anastasis] branch master updated: add timeout_ms support (except for in redux logic)
Date: Sat, 13 Mar 2021 10:53:31 +0100

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 9893706  add timeout_ms support (except for in redux logic)
9893706 is described below

commit 98937061283ff4b90bbd561f58f02a158ba82960
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Mar 13 10:53:29 2021 +0100

    add timeout_ms support (except for in redux logic)
---
 src/include/anastasis.h                     |  4 +++
 src/include/anastasis_service.h             |  6 ++++
 src/lib/anastasis_backup.c                  |  4 +++
 src/reducer/anastasis_api_backup_redux.c    |  2 ++
 src/restclient/anastasis_api_policy_store.c | 34 +++++++++++++++------
 src/restclient/anastasis_api_truth_store.c  | 46 +++++++++++++++++------------
 src/testing/testing_api_cmd_policy_store.c  |  1 +
 src/testing/testing_api_cmd_truth_store.c   |  1 +
 src/testing/testing_cmd_secret_share.c      |  1 +
 src/testing/testing_cmd_truth_upload.c      |  1 +
 10 files changed, 72 insertions(+), 28 deletions(-)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 75ddfdf..c7b356b 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -580,6 +580,7 @@ typedef void
  * @param truth_data_size size of the data
  * @param payment_requested true if the client wants to pay more for the 
account now
  * @param paid_order_id payment identifier of last payment
+ * @param pay_timeout how long to wait for payment
  * @param tc opens the truth callback which contains the status of the upload
  * @param tc_cls closure for the callback
  */
@@ -595,6 +596,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                         size_t truth_data_size,
                         bool payment_requested,
                         const struct ANASTASIS_PaymentSecretP *paid_order_id,
+                        struct GNUNET_TIME_Relative pay_timeout,
                         ANASTASIS_TruthCallback tc,
                         void *tc_cls);
 
@@ -785,6 +787,7 @@ struct ANASTASIS_PaymentDetails
  * @param pds_len length of @a pds array
  * @param payment_requested the client insists on paying for the policy store, 
even if not
  *                 yet needed
+ * @param pay_timeout how long to wait for payment
  * @param spc payment callback is opened to pay the upload
  * @param spc_cls closure for the payment callback
  * @param src callback for the upload process
@@ -800,6 +803,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                         const struct ANASTASIS_PaymentDetails *pds,
                         unsigned int pds_len,
                         bool payment_requested,
+                        struct GNUNET_TIME_Relative pay_timeout,
                         ANASTASIS_ShareResultCallback src,
                         void *src_cls,
                         const void *core_secret,
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 8ecd142..2d9bd90 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -374,6 +374,8 @@ typedef void
  * @param recovery_data_size number of bytes in @a recovery_data
  * @param payment_requested true if the client wants to pay more for the 
account now
  * @param paid_order_id payment identifier of last payment
+ * @param payment_timeout how long to wait for the payment, use
+ *           #GNUNET_TIME_UNIT_ZERO to let the server pick
  * @param cb callback processing the response from /policy
  * @param cb_cls closure for cb
  * @return handle for the operation
@@ -387,6 +389,7 @@ ANASTASIS_policy_store (
   size_t recovery_data_size,
   bool payment_requested,
   const struct ANASTASIS_PaymentSecretP *payment_secret,
+  struct GNUNET_TIME_Relative payment_timeout,
   ANASTASIS_PolicyStoreCallback cb,
   void *cb_cls);
 
@@ -633,6 +636,8 @@ typedef void
  * @param encrypted_truth contains the @a type-specific authorization data
  * @param payment_requested true if we want to pay, even if not yet required
  * @param paid_order_id provides order ID of a previous payment for this 
truth, or NULL
+ * @param payment_timeout how long to wait for the payment, use
+ *           #GNUNET_TIME_UNIT_ZERO to let the server pick
  * @param cb callback processing the response from /truth
  * @param cb_cls closure for cb
  * @return handle for the operation
@@ -649,6 +654,7 @@ ANASTASIS_truth_store (
   const void *encrypted_truth,
   bool payment_requested,
   const struct ANASTASIS_PaymentSecretP *paid_order_id,
+  struct GNUNET_TIME_Relative payment_timeout,
   ANASTASIS_TruthStoreCallback cb,
   void *cb_cls);
 
diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index 4189452..e6eb272 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -248,6 +248,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                         size_t truth_data_size,
                         bool payment_requested,
                         const struct ANASTASIS_PaymentSecretP *paid_order_id,
+                        struct GNUNET_TIME_Relative pay_timeout,
                         ANASTASIS_TruthCallback tc,
                         void *tc_cls)
 {
@@ -329,6 +330,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                                    encrypted_truth,
                                    payment_requested,
                                    paid_order_id,
+                                   pay_timeout,
                                    &truth_store_callback,
                                    tu);
   GNUNET_free (encrypted_truth);
@@ -691,6 +693,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                         const struct ANASTASIS_PaymentDetails *pds,
                         unsigned int pds_len,
                         bool payment_requested,
+                        struct GNUNET_TIME_Relative pay_timeout,
                         ANASTASIS_ShareResultCallback src,
                         void *src_cls,
                         const void *core_secret,
@@ -948,6 +951,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
       (! GNUNET_is_zero (&pss->payment_secret))
       ? &pss->payment_secret
       : NULL,
+      pay_timeout,
       &policy_store_cb,
       pss);
     GNUNET_free (recovery_data);
diff --git a/src/reducer/anastasis_api_backup_redux.c 
b/src/reducer/anastasis_api_backup_redux.c
index f84ea38..cd3206c 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -1733,6 +1733,7 @@ share_secret (struct UploadContext *uc)
                                      pds,
                                      pds_len,
                                      false,  /* FIXME-#6759: support forced 
payments */
+                                     GNUNET_TIME_UNIT_ZERO, /* FIXME: support 
long polling!*/
                                      &secret_share_result_cb,
                                      uc,
                                      core_secret,
@@ -2122,6 +2123,7 @@ check_truth_upload (struct UploadContext *uc,
                                       (NULL != payment_request)
                                           ? &tue->ps
                                           : NULL,
+                                      GNUNET_TIME_UNIT_ZERO, /* FIXME: support 
long polling!*/
                                       &truth_upload_cb,
                                       tue);
     if (NULL == tue->tu)
diff --git a/src/restclient/anastasis_api_policy_store.c 
b/src/restclient/anastasis_api_policy_store.c
index 5a0a048..0ce2e8d 100644
--- a/src/restclient/anastasis_api_policy_store.c
+++ b/src/restclient/anastasis_api_policy_store.c
@@ -265,11 +265,13 @@ ANASTASIS_policy_store (
   size_t recovery_data_size,
   bool payment_requested,
   const struct ANASTASIS_PaymentSecretP *payment_secret,
+  struct GNUNET_TIME_Relative payment_timeout,
   ANASTASIS_PolicyStoreCallback cb,
   void *cb_cls)
 {
   struct ANASTASIS_PolicyStoreOperation *pso;
   struct ANASTASIS_AccountSignatureP account_sig;
+  unsigned long long tms;
   CURL *eh;
   struct curl_slist *job_headers;
   struct ANASTASIS_UploadSignaturePS usp = {
@@ -277,6 +279,8 @@ ANASTASIS_policy_store (
     .purpose.size = htonl (sizeof (usp))
   };
 
+  tms = (unsigned long long) (payment_timeout.rel_value_us
+                              / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
   GNUNET_CRYPTO_hash (recovery_data,
                       recovery_data_size,
                       &usp.new_recovery_data_hash);
@@ -360,7 +364,12 @@ ANASTASIS_policy_store (
     char *acc_pub_str;
     char *path;
     struct ANASTASIS_CRYPTO_AccountPublicKeyP pub;
+    char timeout_ms[32];
 
+    GNUNET_snprintf (timeout_ms,
+                     sizeof (timeout_ms),
+                     "%llu",
+                     tms);
     GNUNET_CRYPTO_eddsa_key_get_public (&anastasis_priv->priv,
                                         &pub.pub);
     acc_pub_str = GNUNET_STRINGS_data_to_string_alloc (&pub,
@@ -369,21 +378,28 @@ ANASTASIS_policy_store (
                      "policy/%s",
                      acc_pub_str);
     GNUNET_free (acc_pub_str);
-    pso->url = (GNUNET_YES == payment_requested)
-               ? TALER_url_join (backend_url,
-                                 path,
-                                 "pay",
-                                 "y",
-                                 NULL)
-               : TALER_url_join (backend_url,
-                                 path,
-                                 NULL);
+    pso->url = TALER_url_join (backend_url,
+                               path,
+                               "pay",
+                               (payment_requested)
+                               ? "y"
+                               : NULL,
+                               "timeout_ms",
+                               (0 != payment_timeout.rel_value_us)
+                               ? timeout_ms
+                               : NULL,
+                               NULL);
     GNUNET_free (path);
   }
   pso->ctx = ctx;
   pso->cb = cb;
   pso->cb_cls = cb_cls;
   eh = ANASTASIS_curl_easy_get_ (pso->url);
+  if (0 != tms)
+    GNUNET_assert (CURLE_OK ==
+                   curl_easy_setopt (eh,
+                                     CURLOPT_TIMEOUT_MS,
+                                     (long) tms));
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_POSTFIELDS,
diff --git a/src/restclient/anastasis_api_truth_store.c 
b/src/restclient/anastasis_api_truth_store.c
index 3405555..e465678 100644
--- a/src/restclient/anastasis_api_truth_store.c
+++ b/src/restclient/anastasis_api_truth_store.c
@@ -250,20 +250,29 @@ ANASTASIS_truth_store (
   const void *encrypted_truth,
   bool payment_requested,
   const struct ANASTASIS_PaymentSecretP *paid_order_id,
+  struct GNUNET_TIME_Relative payment_timeout,
   ANASTASIS_TruthStoreCallback cb,
   void *cb_cls)
 {
   struct ANASTASIS_TruthStoreOperation *tso;
   CURL *eh;
   char *json_str;
+  unsigned long long tms;
 
   /* Finished setting up headers */
+  tms = (unsigned long long) (payment_timeout.rel_value_us
+                              / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
   tso = GNUNET_new (struct ANASTASIS_TruthStoreOperation);
   {
     char *uuid_str;
     char *poi_str;
     char *path;
+    char timeout_ms[32];
 
+    GNUNET_snprintf (timeout_ms,
+                     sizeof (timeout_ms),
+                     "%llu",
+                     tms);
     uuid_str = GNUNET_STRINGS_data_to_string_alloc (uuid,
                                                     sizeof (*uuid));
     if (NULL != paid_order_id)
@@ -274,24 +283,19 @@ ANASTASIS_truth_store (
     GNUNET_asprintf (&path,
                      "truth/%s",
                      uuid_str);
-    tso->url =
-      payment_requested
-      ? TALER_url_join (backend_url,
-                        path,
-                        "pay",
-                        "y",
-                        (NULL != paid_order_id)
-                                   ? "paying"
-                                   : NULL,
-                        poi_str,
-                        NULL)
-      : TALER_url_join (backend_url,
-                        path,
-                        (NULL != paid_order_id)
-                                   ? "paying"
-                                   : NULL,
-                        poi_str,
-                        NULL);
+    tso->url = TALER_url_join (backend_url,
+                               path,
+                               "pay",
+                               (payment_requested) ? "y" : NULL,
+                               "paying",
+                               (NULL != paid_order_id)
+                               ? poi_str
+                               : NULL,
+                               "timeout_ms",
+                               (0 != payment_timeout.rel_value_us)
+                               ? timeout_ms
+                               : NULL,
+                               NULL);
     GNUNET_free (path);
     GNUNET_free (poi_str);
     GNUNET_free (uuid_str);
@@ -325,7 +329,11 @@ ANASTASIS_truth_store (
   tso->cb = cb;
   tso->cb_cls = cb_cls;
   eh = ANASTASIS_curl_easy_get_ (tso->url);
-
+  if (0 != tms)
+    GNUNET_assert (CURLE_OK ==
+                   curl_easy_setopt (eh,
+                                     CURLOPT_TIMEOUT_MS,
+                                     (long) tms));
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_POSTFIELDS,
diff --git a/src/testing/testing_api_cmd_policy_store.c 
b/src/testing/testing_api_cmd_policy_store.c
index 79704b8..5ef0fbb 100644
--- a/src/testing/testing_api_cmd_policy_store.c
+++ b/src/testing/testing_api_cmd_policy_store.c
@@ -287,6 +287,7 @@ policy_store_run (void *cls,
     pss->recovery_data_size,
     (0 != (ANASTASIS_TESTING_PSO_REQUEST_PAYMENT & pss->psopt)),
     pss->payment_secret_set ? &pss->payment_secret_request : NULL,
+    GNUNET_TIME_UNIT_ZERO,
     &policy_store_cb,
     pss);
   if (NULL == pss->pso)
diff --git a/src/testing/testing_api_cmd_truth_store.c 
b/src/testing/testing_api_cmd_truth_store.c
index 121619a..efacc3f 100644
--- a/src/testing/testing_api_cmd_truth_store.c
+++ b/src/testing/testing_api_cmd_truth_store.c
@@ -304,6 +304,7 @@ truth_store_run (void *cls,
       (0 != (ANASTASIS_TESTING_TSO_REFERENCE_ORDER_ID & tss->tsopt))
       ? &tss->payment_secret_request
       : NULL,
+      GNUNET_TIME_UNIT_ZERO,
       &truth_store_cb,
       tss);
     GNUNET_free (encrypted_truth);
diff --git a/src/testing/testing_cmd_secret_share.c 
b/src/testing/testing_cmd_secret_share.c
index 5c58695..4a99072 100644
--- a/src/testing/testing_cmd_secret_share.c
+++ b/src/testing/testing_cmd_secret_share.c
@@ -285,6 +285,7 @@ secret_share_run (void *cls,
                                      (0 == pds_len) ? NULL : &pds,
                                      pds_len,
                                      false,
+                                     GNUNET_TIME_UNIT_ZERO,
                                      &secret_share_result_cb,
                                      sss,
                                      sss->core_secret,
diff --git a/src/testing/testing_cmd_truth_upload.c 
b/src/testing/testing_cmd_truth_upload.c
index f1d5de5..ce34a51 100644
--- a/src/testing/testing_cmd_truth_upload.c
+++ b/src/testing/testing_cmd_truth_upload.c
@@ -235,6 +235,7 @@ truth_upload_run (void *cls,
                                      tus->truth_data_size,
                                      false, /* force payment */
                                      ps,
+                                     GNUNET_TIME_UNIT_ZERO,
                                      &truth_upload_cb,
                                      tus);
   if (NULL == tus->tuo)

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