[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: add logic to resume wire transf
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: add logic to resume wire transfer checks from last checkpoint |
Date: |
Sun, 15 Aug 2021 19:01:19 +0200 |
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 3b90e43 add logic to resume wire transfer checks from last checkpoint
3b90e43 is described below
commit 3b90e437e26013f5570d6c216b832c7bcd740712
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Aug 15 19:01:17 2021 +0200
add logic to resume wire transfer checks from last checkpoint
---
.../anastasis-helper-authorization-iban.c | 19 ++++++++-
src/include/anastasis_database_plugin.h | 19 +++++++++
src/stasis/plugin_anastasis_postgres.c | 47 ++++++++++++++++++++++
3 files changed, 84 insertions(+), 1 deletion(-)
diff --git a/src/authorization/anastasis-helper-authorization-iban.c
b/src/authorization/anastasis-helper-authorization-iban.c
index b66d181..946b008 100644
--- a/src/authorization/anastasis-helper-authorization-iban.c
+++ b/src/authorization/anastasis-helper-authorization-iban.c
@@ -22,7 +22,6 @@
* - blocked on #6992
* - needs XXX_bank_service to access new facade once #6992 is implemented
* - needs to load authentication information
- * - needs to load 'last known' transaction from DB
* - needs to add DB triggers to notify main service of inbound activity
*/
#include "platform.h"
@@ -45,6 +44,11 @@
*/
static struct BANK_AccountInfo *auth;
+/**
+ * Bank account payto://-URI this process is monitoring.
+ */
+static struct credit_account_uri;
+
/**
* Active request for history.
*/
@@ -282,7 +286,20 @@ run (void *cls,
return;
}
// FIXME: initialize 'auth' from cfg!
+ {
+ enum GNUNET_DB_QueryStatus qs;
+ qs = db_plugin->get_last_auth_iban_payment_row (db_plugin->cls,
+ credit_account_uri,
+ &latest_row_off);
+ if (qs < 0)
+ {
+ GNUNET_break (0);
+ ANASTASIS_DB_plugin_unload (db_plugin);
+ db_plugin = NULL;
+ return;
+ }
+ }
GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
cls);
ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
diff --git a/src/include/anastasis_database_plugin.h
b/src/include/anastasis_database_plugin.h
index ae414dc..7ad47ca 100644
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@ -778,6 +778,25 @@ struct ANASTASIS_DatabasePlugin
void *cb_cls);
+ /**
+ * Function to check the last known IBAN payment.
+ *
+ * @param cls closure
+ * @param credit_account which credit account to check
+ * @param[out] last_row set to the last known row
+ * @return transaction status,
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if @a cb
+ * returned 'true' once
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if no
+ * wire transfers existed for which @a cb returned true
+ */
+ enum GNUNET_DB_QueryStatus
+ (*get_last_auth_iban_payment_row)(
+ void *cls,
+ const char *credit_account,
+ uint64_t *last_row);
+
+
/**
* Function called to remove all expired codes from the database.
*
diff --git a/src/stasis/plugin_anastasis_postgres.c
b/src/stasis/plugin_anastasis_postgres.c
index 1544367..9d206c7 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -1289,6 +1289,43 @@ postgres_test_auth_iban_payment (
}
+/**
+ * Function to check the last known IBAN payment.
+ *
+ * @param cls closure
+ * @param credit_account which credit account to check
+ * @param[out] last_row set to the last known row
+ * @return transaction status,
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if @a cb
+ * returned 'true' once
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if no
+ * wire transfers existed for which @a cb returned true
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_get_last_auth_iban_payment_row (
+ void *cls,
+ const char *credit_account,
+ uint64_t *last_row)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (credit_account),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_uint64 ("wire_reference",
+ last_row),
+ GNUNET_PQ_result_spec_end
+ };
+
+ check_connection (pg);
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+
"get_last_auth_iban_payment",
+ params,
+ rs);
+}
+
+
/**
* Check payment identifier. Used to check if a payment identifier given by
* the user is valid (existing and paid).
@@ -2530,6 +2567,14 @@ libanastasis_plugin_db_postgres_init (void *cls)
" ORDER BY creation_date DESC"
" LIMIT 1);",
3),
+ GNUNET_PQ_make_prepare ("get_last_auth_iban_payment",
+ "SELECT "
+ " wire_reference"
+ " FROM anastasis_auth_iban_in"
+ " WHERE credit_account_details=$1"
+ " ORDER BY wire_reference DESC"
+ " LIMIT 1;",
+ 1),
GNUNET_PQ_make_prepare ("gc_challengecodes",
"DELETE FROM anastasis_challengecode "
"WHERE "
@@ -2604,6 +2649,8 @@ libanastasis_plugin_db_postgres_init (void *cls)
plugin->update_challenge_payment = &postgres_update_challenge_payment;
plugin->record_auth_iban_payment = &postgres_record_auth_iban_payment;
plugin->test_auth_iban_payment = &postgres_test_auth_iban_payment;
+ plugin->get_last_auth_iban_payment_row
+ = &postgres_get_last_auth_iban_payment_row;
return plugin;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: add logic to resume wire transfer checks from last checkpoint,
gnunet <=