gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: dynamic /pay timeout


From: gnunet
Subject: [taler-merchant] branch master updated: dynamic /pay timeout
Date: Mon, 07 Sep 2020 12:19:08 +0200

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

dold pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 6f0c486  dynamic /pay timeout
6f0c486 is described below

commit 6f0c4869ffb5edba4c4e21c0ba746f590a60b80a
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Mon Sep 7 15:49:00 2020 +0530

    dynamic /pay timeout
---
 .../taler-merchant-httpd_post-orders-ID-pay.c      | 36 ++++++++++++++++------
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c 
b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index 915f305..38682a2 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -34,12 +34,6 @@
 #include "taler-merchant-httpd_private-get-orders.h"
 
 
-/**
- * How long to wait before giving up processing with the exchange?
- */
-#define PAY_TIMEOUT (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \
-                                                    30))
-
 /**
  * How often do we retry the (complex!) database transaction?
  */
@@ -364,6 +358,29 @@ static struct PayContext *pc_head;
 static struct PayContext *pc_tail;
 
 
+/**
+ * Compute the timeout for a /pay request based on the number of coins
+ * involved.
+ *
+ * @param num_coins number of coins
+ * @returns timeout for the /pay request
+ */
+static struct GNUNET_TIME_Relative
+get_pay_timeout (unsigned int num_coins)
+{
+  struct GNUNET_TIME_Relative t;
+  struct GNUNET_TIME_Relative sec5;
+
+  sec5 = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+                                        5);
+  t = GNUNET_TIME_relative_add (sec5,
+                                GNUNET_TIME_relative_multiply (sec5,
+                                                               num_coins / 
20));
+
+  return t;
+}
+
+
 /**
  * Abort all pending /deposit operations.
  *
@@ -1867,9 +1884,10 @@ TMH_post_orders_ID_pay (const struct TMH_RequestHandler 
*rh,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Suspending pay handling while working with the exchange\n");
   GNUNET_assert (NULL == pc->timeout_task);
-  pc->timeout_task = GNUNET_SCHEDULER_add_delayed (PAY_TIMEOUT,
-                                                   &handle_pay_timeout,
-                                                   pc);
+  pc->timeout_task =
+      GNUNET_SCHEDULER_add_delayed (get_pay_timeout (pc->coins_cnt),
+                                    &handle_pay_timeout,
+                                    pc);
   begin_transaction (pc);
   return MHD_YES;
 }

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