[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: add task to continue to poll ban
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: add task to continue to poll bank for debits without local DB trigger |
Date: |
Fri, 23 Aug 2024 15:14:57 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 0099726de add task to continue to poll bank for debits without local
DB trigger
0099726de is described below
commit 0099726de51b648cdffec014671ebbfb88ba331f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Aug 23 15:14:54 2024 +0200
add task to continue to poll bank for debits without local DB trigger
---
src/auditor/taler-helper-auditor-wire-debit.c | 114 +++++++++++++++++++++-----
1 file changed, 92 insertions(+), 22 deletions(-)
diff --git a/src/auditor/taler-helper-auditor-wire-debit.c
b/src/auditor/taler-helper-auditor-wire-debit.c
index 462be716e..34044d1d9 100644
--- a/src/auditor/taler-helper-auditor-wire-debit.c
+++ b/src/auditor/taler-helper-auditor-wire-debit.c
@@ -67,8 +67,9 @@
/**
* How long do we long-poll for bank wire transfers?
*/
-#define LONG_POLL_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, \
- 1)
+#define MAX_LONGPOLL_DELAY GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_HOURS \
+ , \
+ 1)
/**
@@ -103,6 +104,17 @@ struct WireAccount
*/
struct TALER_BANK_DebitHistoryHandle *dhh;
+ /**
+ * Task to trigger @e dhh long-polling.
+ */
+ struct GNUNET_SCHEDULER_Task *dhh_task;
+
+ /**
+ * Time when we expect the current @e dhh long-poll
+ * to finish and we thus could begin another one.
+ */
+ struct GNUNET_TIME_Absolute dhh_next;
+
/**
* Progress point for this account.
*/
@@ -384,6 +396,11 @@ do_shutdown (void *cls)
}
while (NULL != (wa = wa_head))
{
+ if (NULL != wa->dhh_task)
+ {
+ GNUNET_SCHEDULER_cancel (wa->dhh_task);
+ wa->dhh_task = NULL;
+ }
if (NULL != wa->dhh)
{
TALER_BANK_debit_history_cancel (wa->dhh);
@@ -985,9 +1002,10 @@ wire_out_cb (
if (NULL == roi)
{
/* Wire transfer was not made (yet) at all (but would have been
- justified), so the entire amount is missing / still to be done.
- This is moderately harmless, it might just be that the aggregator
- has not yet fully caught up with the transfers it should do. */
+ justified), so the entire amount is missing / still to be done. This
+ is moderately harmless, it might just be that the
+ taler-exchange-transfer tool or bank has not yet fully caught up with
+ the transfers it should do. */
struct TALER_AUDITORDB_WireOutInconsistency woi = {
.row_id = rowid,
.destination_account = (char *) payto_uri,
@@ -1175,6 +1193,47 @@ check_exchange_wire_out (struct WireAccount *wa)
* @param cls `struct WireAccount` with current wire account to process
* @param dhr HTTP response details
*/
+static void
+history_debit_cb (
+ void *cls,
+ const struct TALER_BANK_DebitHistoryResponse *dhr);
+
+
+/**
+ * Task scheduled to begin long-polling on the
+ * bank transfer.
+ *
+ * @param cls a `struct WireAccount *`
+ */
+static void
+dh_long_poll (void *cls)
+{
+ struct WireAccount *wa = cls;
+
+ wa->dhh_task = NULL;
+ wa->dhh_next
+ = GNUNET_TIME_relative_to_absolute (MAX_LONGPOLL_DELAY);
+ GNUNET_assert (NULL == wa->dhh);
+ wa->dhh = TALER_BANK_debit_history (
+ ctx,
+ wa->ai->auth,
+ wa->wire_off_out,
+ MAX_PER_TRANSACTION,
+ MAX_LONGPOLL_DELAY,
+ &history_debit_cb,
+ wa);
+ if (NULL == wa->dhh)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to start long-polling for bank transaction history for
`%s'\n",
+ wa->ai->section_name);
+ global_ret = EXIT_FAILURE;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+}
+
+
static void
history_debit_cb (
void *cls,
@@ -1185,6 +1244,13 @@ history_debit_cb (
size_t slen;
wa->dhh = NULL;
+ if (MHD_HTTP_OK == dhr->http_status)
+ wa->dhh_next = GNUNET_TIME_UNIT_ZERO_ABS;
+ GNUNET_assert (NULL == wa->dhh_task);
+ wa->dhh_task
+ = GNUNET_SCHEDULER_add_at (wa->dhh_next,
+ &dh_long_poll,
+ wa);
switch (dhr->http_status)
{
case MHD_HTTP_OK:
@@ -1264,6 +1330,7 @@ history_debit_cb (
commit (GNUNET_DB_STATUS_HARD_ERROR);
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
+ return;
}
@@ -1283,24 +1350,27 @@ process_debits (struct WireAccount *wa)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking bank DEBIT records of account `%s'\n",
wa->ai->section_name);
- GNUNET_assert (NULL == wa->dhh);
- wa->dhh = TALER_BANK_debit_history (
- ctx,
- wa->ai->auth,
- wa->wire_off_out,
- MAX_PER_TRANSACTION,
- GNUNET_TIME_UNIT_ZERO,
- &history_debit_cb,
- wa);
- if (NULL == wa->dhh)
+ if ( (NULL == wa->dhh) &&
+ (NULL == wa->dhh_task) )
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to obtain bank transaction history for `%s'\n",
- wa->ai->section_name);
- commit (GNUNET_DB_STATUS_HARD_ERROR);
- global_ret = EXIT_FAILURE;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ wa->dhh = TALER_BANK_debit_history (
+ ctx,
+ wa->ai->auth,
+ wa->wire_off_out,
+ MAX_PER_TRANSACTION,
+ GNUNET_TIME_UNIT_ZERO,
+ &history_debit_cb,
+ wa);
+ if (NULL == wa->dhh)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to obtain bank transaction history for `%s'\n",
+ wa->ai->section_name);
+ commit (GNUNET_DB_STATUS_HARD_ERROR);
+ global_ret = EXIT_FAILURE;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: add task to continue to poll bank for debits without local DB trigger,
gnunet <=