summaryrefslogtreecommitdiff
path: root/src/stasis
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-15 19:01:17 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-15 19:01:17 +0200
commit3b90e437e26013f5570d6c216b832c7bcd740712 (patch)
tree13ab0dddb4e13c49b86b4526208f05dddfa10e95 /src/stasis
parent622eba29d8675ce12640cf513350891246fd90c8 (diff)
downloadanastasis-3b90e437e26013f5570d6c216b832c7bcd740712.tar.gz
anastasis-3b90e437e26013f5570d6c216b832c7bcd740712.tar.bz2
anastasis-3b90e437e26013f5570d6c216b832c7bcd740712.zip
add logic to resume wire transfer checks from last checkpoint
Diffstat (limited to 'src/stasis')
-rw-r--r--src/stasis/plugin_anastasis_postgres.c47
1 files changed, 47 insertions, 0 deletions
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
@@ -1290,6 +1290,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;
}