summaryrefslogtreecommitdiff
path: root/src/stasis/plugin_anastasis_postgres.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stasis/plugin_anastasis_postgres.c')
-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;
}