exchange

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

commit 6bdf1bc968124a32c932b75579ab6078ea6898cc
parent 689589e325d288ef6447bbc749b05bfa95ea7116
Author: Florian Dold <florian@dold.me>
Date:   Mon, 11 Nov 2024 14:36:08 +0100

tolerate automated aml outcomes with same decision timestamp

Diffstat:
Msrc/exchange/taler-exchange-httpd_common_kyc.c | 14+++++---------
Msrc/exchange/taler-exchange-httpd_kyc-info.c | 15+++++----------
Msrc/exchangedb/exchange_do_insert_aml_decision.sql | 2+-
Msrc/exchangedb/exchange_do_insert_successor_measure.sql | 2+-
Msrc/exchangedb/pg_lookup_aml_history.c | 2+-
Msrc/exchangedb/pg_lookup_rules_by_access_token.c | 3++-
6 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_common_kyc.c b/src/exchange/taler-exchange-httpd_common_kyc.c @@ -1643,15 +1643,11 @@ legitimization_check_run ( NULL); goto cleanup; } - if (GNUNET_TIME_timestamp_cmp (last_date, - >=, - decision_time)) - { - legi_fail (lch, - TALER_EC_EXCHANGE_AML_DECISION_MORE_RECENT_PRESENT, - "later decision exists"); - goto cleanup; - } + /* We tolerate conflicting decision times for automatic decisions. */ + GNUNET_break ( + GNUNET_TIME_timestamp_cmp (last_date, + >=, + decision_time)); /* Back to default rules. */ TALER_KYCLOGIC_rules_free (lrs); lrs = NULL; diff --git a/src/exchange/taler-exchange-httpd_kyc-info.c b/src/exchange/taler-exchange-httpd_kyc-info.c @@ -719,16 +719,11 @@ TEH_handler_kyc_info ( NULL); goto cleanup; } - if (GNUNET_TIME_timestamp_cmp (last_date, - >=, - decision_time)) - { - res = TALER_MHD_reply_with_ec ( - rc->connection, - TALER_EC_EXCHANGE_AML_DECISION_MORE_RECENT_PRESENT, - "later decision exists"); - goto cleanup; - } + /* We tolerate conflicting decision times for automatic decisions. */ + GNUNET_break ( + GNUNET_TIME_timestamp_cmp (last_date, + >=, + decision_time)); /* Back to default rules. */ TALER_KYCLOGIC_rules_free (lrs); lrs = NULL; diff --git a/src/exchangedb/exchange_do_insert_aml_decision.sql b/src/exchangedb/exchange_do_insert_aml_decision.sql @@ -64,7 +64,7 @@ SELECT decision_time FROM legitimization_outcomes WHERE h_payto=in_h_normalized_payto AND is_active - ORDER BY decision_time DESC; + ORDER BY decision_time DESC, outcome_serial_id DESC; IF FOUND THEN diff --git a/src/exchangedb/exchange_do_insert_successor_measure.sql b/src/exchangedb/exchange_do_insert_successor_measure.sql @@ -41,7 +41,7 @@ SELECT decision_time FROM legitimization_outcomes WHERE h_payto=in_h_normalized_payto AND is_active - ORDER BY decision_time DESC; + ORDER BY decision_time DESC, outcome_serial_id DESC; IF FOUND THEN diff --git a/src/exchangedb/pg_lookup_aml_history.c b/src/exchangedb/pg_lookup_aml_history.c @@ -154,7 +154,7 @@ TEH_PG_lookup_aml_history ( " JOIN legitimization_outcomes lo" " USING (outcome_serial_id)" " WHERE ah.h_payto=$1" - " ORDER BY decision_time DESC;"); + " ORDER BY decision_time DESC, outcome_serial_id DESC;"); qs = GNUNET_PQ_eval_prepared_multi_select ( pg->conn, "lookup_aml_history", diff --git a/src/exchangedb/pg_lookup_rules_by_access_token.c b/src/exchangedb/pg_lookup_rules_by_access_token.c @@ -59,7 +59,8 @@ TEH_PG_lookup_rules_by_access_token ( " WHERE h_payto=$1" " AND expiration_time>$2" " AND is_active" - " ORDER BY expiration_time DESC" + " ORDER BY expiration_time DESC," + " outcome_serial_id DESC" " LIMIT 1;"); now = GNUNET_TIME_absolute_get (); return GNUNET_PQ_eval_prepared_singleton_select (