aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_reserves.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_reserves.c')
-rw-r--r--src/backend/taler-merchant-httpd_reserves.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/backend/taler-merchant-httpd_reserves.c b/src/backend/taler-merchant-httpd_reserves.c
index 2853675f..15c03847 100644
--- a/src/backend/taler-merchant-httpd_reserves.c
+++ b/src/backend/taler-merchant-httpd_reserves.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2020 Taler Systems SA
+ (C) 2020, 2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -24,6 +24,14 @@
#include "taler-merchant-httpd_exchanges.h"
#include "taler-merchant-httpd_reserves.h"
+/**
+ * How long do we keep the long-poller open?
+ * Not very long here, as if the money has not
+ * yet arrived, there is a fair chance that it'll
+ * take much longer, and in that case we rather
+ * enter into the delay created by try_later().
+ */
+#define LONGPOLL_DELAY GNUNET_TIME_UNIT_MINUTES
/**
* Our representation of a reserve that we are (still) checking the status of.
@@ -145,6 +153,10 @@ free_reserve (struct Reserve *r)
static void
try_later (struct Reserve *r)
{
+ /* minimum delay is the #LONGPOLL_DELAY */
+ r->delay = GNUNET_TIME_relative_max (LONGPOLL_DELAY,
+ r->delay);
+ /* STD_BACKOFF has a maximum of 15 minutes */
r->delay = GNUNET_TIME_STD_BACKOFF (r->delay);
r->tt = GNUNET_SCHEDULER_add_delayed (r->delay,
&try_now,
@@ -249,6 +261,7 @@ find_cb (void *cls,
}
r->gh = TALER_EXCHANGE_reserves_get (eh,
&r->reserve_pub,
+ LONGPOLL_DELAY,
&reserve_cb,
r);
if (NULL == r->gh)
@@ -316,10 +329,6 @@ add_reserve (void *cls,
}
-/**
- * Load information about reserves and start querying reserve status.
- * Must be called after the database is available.
- */
void
TMH_RESERVES_init (void)
{
@@ -329,14 +338,6 @@ TMH_RESERVES_init (void)
}
-/**
- * Add a reserve to the list of reserves to check.
- *
- * @param instance_id which instance is the reserve for
- * @param exchange_url URL of the exchange with the reserve
- * @param reserve_pub public key of the reserve to check
- * @param expected_amount amount the merchant expects to see initially in the reserve
- */
void
TMH_RESERVES_check (const char *instance_id,
const char *exchange_url,
@@ -351,9 +352,6 @@ TMH_RESERVES_check (const char *instance_id,
}
-/**
- * Stop checking reserve status.
- */
void
TMH_RESERVES_done (void)
{