exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 2c3c5044fd428ffacfb3ae282bd6d851f1cc02a6
parent 98e199c512800cc970a420b9519f225e639dc98e
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun,  8 Dec 2024 16:18:45 +0100

store AML program failure even if AML program was not triggered via legi process but via expiration

Diffstat:
Msrc/exchangedb/exchangedb_aml.c | 2+-
Msrc/exchangedb/pg_insert_aml_program_failure.c | 36+++++++++++++++---------------------
Msrc/exchangedb/procedures.sql.in | 1+
Msrc/include/taler_exchangedb_lib.h | 5++++-
4 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/src/exchangedb/exchangedb_aml.c b/src/exchangedb/exchangedb_aml.c @@ -254,7 +254,7 @@ aml_result_callback ( /* Update database update based on result */ qs = TALER_EXCHANGEDB_persist_aml_program_result ( ru->plugin, - 0, // FIXME: process row NEEDED! - #9303 may give us something here!? + 0LLU, /* 0: no existing legitimization process, creates new row */ &ru->account, apr); switch (qs) diff --git a/src/exchangedb/pg_insert_aml_program_failure.c b/src/exchangedb/pg_insert_aml_program_failure.c @@ -37,40 +37,34 @@ TEH_PG_insert_aml_program_failure ( { struct PostgresClosure *pg = cls; uint32_t ec32 = (uint32_t) ec; + struct TALER_KycCompletedEventP rep = { + .header.size = htons (sizeof (rep)), + .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), + .h_payto = *h_payto + }; + struct GNUNET_TIME_Timestamp now + = GNUNET_TIME_timestamp_get (); + char *kyc_completed_notify_s + = GNUNET_PQ_get_event_notify_channel (&rep.header); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&process_row), GNUNET_PQ_query_param_auto_from_type (h_payto), GNUNET_PQ_query_param_uint32 (&ec32), + GNUNET_PQ_query_param_timestamp (&now), GNUNET_PQ_query_param_string (error_message), + GNUNET_PQ_query_param_string (kyc_completed_notify_s), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; PREPARE (pg, "insert_aml_program_failure", - "UPDATE legitimization_processes" - " SET" - " finished=TRUE" - " ,error_code=$3" - " ,error_message=$4" - " WHERE h_payto=$2" - " AND legitimization_process_serial_id=$1;"); + "SELECT out_update" + " FROM exchange_do_insert_aml_program_failure" + " ($1, $2, $3, $4);"); qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, "insert_aml_program_failure", params); - if (qs > 0) - { - /* FIXME: might want to do this eventually in the same transaction... */ - struct TALER_KycCompletedEventP rep = { - .header.size = htons (sizeof (rep)), - .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), - .h_payto = *h_payto - }; - - TEH_PG_event_notify (pg, - &rep.header, - NULL, - 0); - } + GNUNET_free (kyc_completed_notify_s); return qs; } diff --git a/src/exchangedb/procedures.sql.in b/src/exchangedb/procedures.sql.in @@ -57,5 +57,6 @@ SET search_path TO exchange; #include "exchange_do_insert_active_legitimization_measure.sql" #include "exchange_do_select_aggregations_above_serial.sql" #include "exchange_do_persist_kyc_attributes.sql" +#include "exchange_do_insert_aml_program_failure.sql" COMMIT; diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h @@ -365,7 +365,10 @@ TALER_EXCHANGEDB_update_rules_cancel ( * into the database via @a plugin. * * @param plugin database API handle - * @param process_row row identifying the AML process that was run + * @param process_row row identifying the legitimization process that was run, + * 0 if there was no legi process (for example, due to rule + * expiration triggering something) and we should simply + * create a new row * @param account_id hash of account the result is about * @param apr AML program result to persist */