diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-09-07 15:49:00 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-09-07 15:49:00 +0530 |
commit | 6f0c4869ffb5edba4c4e21c0ba746f590a60b80a (patch) | |
tree | 2272c52d4f7c774e7879b5df64844803a895ce98 /src/backend | |
parent | f6b5dd04e06198a023eb38945c963a9128065786 (diff) | |
download | merchant-6f0c4869ffb5edba4c4e21c0ba746f590a60b80a.tar.gz merchant-6f0c4869ffb5edba4c4e21c0ba746f590a60b80a.tar.bz2 merchant-6f0c4869ffb5edba4c4e21c0ba746f590a60b80a.zip |
dynamic /pay timeout
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-pay.c | 36 |
1 files 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 915f3056..38682a24 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -35,12 +35,6 @@ /** - * 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? */ #define MAX_RETRIES 5 @@ -365,6 +359,29 @@ 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. * * @param pc pay context to abort @@ -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; } |