exchange

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

commit bdadf33588cdf11ab356a757ecead57d2a4a7962
parent 3ccbc5df54541169ee5e3f2b88d01928e713c741
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 29 Dec 2024 22:28:34 +0100

properly report rowid for wire fee issues

Diffstat:
Msrc/auditor/taler-helper-auditor-aggregation.c | 12+++++++-----
Msrc/auditor/taler-helper-auditor-reserves.c | 4+++-
Msrc/exchange/taler-exchange-aggregator.c | 2++
Msrc/exchange/taler-exchange-closer.c | 2++
Msrc/exchange/taler-exchange-httpd_transfers_get.c | 2++
Msrc/exchangedb/pg_get_wire_fee.c | 23++++++++++++++---------
Msrc/exchangedb/pg_get_wire_fee.h | 17++++++++++-------
Msrc/exchangedb/pg_insert_wire_fee.c | 2++
Msrc/exchangedb/test_exchangedb.c | 3+++
Msrc/include/taler_exchangedb_plugin.h | 2++
10 files changed, 47 insertions(+), 22 deletions(-)

diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c @@ -815,9 +815,9 @@ wire_transfer_information_cb ( } } /* Obtain coin's transaction history */ - /* FIXME: could use 'start' mechanism to only fetch transactions - we did not yet process, instead of going over them - again and again.*/ + /* FIXME-Optimization: could use 'start' mechanism to only fetch + transactions we did not yet process, instead of going over them again and + again.*/ { struct TALER_Amount balance; @@ -1055,6 +1055,7 @@ get_wire_fee (struct AggregationContext *ac, struct WireFeeInfo *pos; struct TALER_MasterSignatureP master_sig; enum GNUNET_DB_QueryStatus qs; + uint64_t rowid; /* Check if fee is already loaded in cache */ for (pos = ac->fee_head; NULL != pos; pos = pos->next) @@ -1078,6 +1079,7 @@ get_wire_fee (struct AggregationContext *ac, TALER_ARL_edb->get_wire_fee (TALER_ARL_edb->cls, method, timestamp, + &rowid, &wfi->start_date, &wfi->end_date, &wfi->fees, @@ -1130,7 +1132,7 @@ get_wire_fee (struct AggregationContext *ac, wfi->start_date)) { struct TALER_AUDITORDB_FeeTimeInconsistency ftib = { - .problem_row_id = 0, /* FIXME: fetch above! */ + .problem_row_id = rowid, .diagnostic = (char *) "start date before previous end date", .time = wfi->start_date.abs_time, .type = (char *) method @@ -1152,7 +1154,7 @@ get_wire_fee (struct AggregationContext *ac, wfi->end_date)) { struct TALER_AUDITORDB_FeeTimeInconsistency ftia = { - .problem_row_id = 0, /* FIXME: fetch above! */ + .problem_row_id = rowid, .diagnostic = (char *) "end date date after next start date", .time = wfi->end_date.abs_time, .type = (char *) method diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c @@ -863,6 +863,7 @@ get_closing_fee (const struct TALER_FullPayto receiver_account, struct GNUNET_TIME_Timestamp end_date; struct TALER_WireFeeSet fees; char *method; + uint64_t rowid; method = TALER_payto_get_method (receiver_account.full_payto); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -872,6 +873,7 @@ get_closing_fee (const struct TALER_FullPayto receiver_account, TALER_ARL_edb->get_wire_fee (TALER_ARL_edb->cls, method, atime, + &rowid, &start_date, &end_date, &fees, @@ -884,7 +886,7 @@ get_closing_fee (const struct TALER_FullPayto receiver_account, method, GNUNET_TIME_timestamp2s (atime)); report_row_inconsistency ("closing-fee", - atime.abs_time.abs_value_us, + rowid, diag); GNUNET_free (diag); GNUNET_free (method); diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c @@ -1015,10 +1015,12 @@ do_aggregate (struct AggregationUnit *au) struct GNUNET_TIME_Timestamp start_date; struct GNUNET_TIME_Timestamp end_date; struct TALER_MasterSignatureP master_sig; + uint64_t rowid; qs = db_plugin->get_wire_fee (db_plugin->cls, au->wa->method, au->execution_time, + &rowid, &start_date, &end_date, &au->fees, diff --git a/src/exchange/taler-exchange-closer.c b/src/exchange/taler-exchange-closer.c @@ -253,10 +253,12 @@ expired_reserve_cb (void *cls, struct GNUNET_TIME_Timestamp end_date; struct TALER_MasterSignatureP master_sig; enum GNUNET_DB_QueryStatus qs; + uint64_t rowid; qs = db_plugin->get_wire_fee (db_plugin->cls, wa->method, expiration_date, + &rowid, &start_date, &end_date, &fees, diff --git a/src/exchange/taler-exchange-httpd_transfers_get.c b/src/exchange/taler-exchange-httpd_transfers_get.c @@ -542,6 +542,7 @@ get_transfer_deposits (void *cls, } { char *wire_method; + uint64_t rowid; wire_method = TALER_payto_get_method (ctx->payto_uri.full_payto); if (NULL == wire_method) @@ -556,6 +557,7 @@ get_transfer_deposits (void *cls, qs = TEH_plugin->get_wire_fee (TEH_plugin->cls, wire_method, ctx->exec_time, + &rowid, &wire_fee_start_date, &wire_fee_end_date, &ctx->fees, diff --git a/src/exchangedb/pg_get_wire_fee.c b/src/exchangedb/pg_get_wire_fee.c @@ -26,13 +26,15 @@ #include "pg_helper.h" enum GNUNET_DB_QueryStatus -TEH_PG_get_wire_fee (void *cls, - const char *type, - struct GNUNET_TIME_Timestamp date, - struct GNUNET_TIME_Timestamp *start_date, - struct GNUNET_TIME_Timestamp *end_date, - struct TALER_WireFeeSet *fees, - struct TALER_MasterSignatureP *master_sig) +TEH_PG_get_wire_fee ( + void *cls, + const char *type, + struct GNUNET_TIME_Timestamp date, + uint64_t *rowid, + struct GNUNET_TIME_Timestamp *start_date, + struct GNUNET_TIME_Timestamp *end_date, + struct TALER_WireFeeSet *fees, + struct TALER_MasterSignatureP *master_sig) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -41,6 +43,8 @@ TEH_PG_get_wire_fee (void *cls, GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("wire_fee_serial", + rowid), GNUNET_PQ_result_spec_timestamp ("start_date", start_date), GNUNET_PQ_result_spec_timestamp ("end_date", @@ -56,8 +60,9 @@ TEH_PG_get_wire_fee (void *cls, PREPARE (pg, "get_wire_fee", - "SELECT " - " start_date" + "SELECT" + " wire_fee_serial" + ",start_date" ",end_date" ",wire_fee" ",closing_fee" diff --git a/src/exchangedb/pg_get_wire_fee.h b/src/exchangedb/pg_get_wire_fee.h @@ -31,6 +31,7 @@ * @param cls closure * @param type type of wire transfer the fee applies for * @param date for which date do we want the fee? + * @param[out] rowid set to row in the database with the wire fee * @param[out] start_date when does the fee go into effect * @param[out] end_date when does the fee end being valid * @param[out] fees how high are the wire fees @@ -38,12 +39,14 @@ * @return status of the transaction */ enum GNUNET_DB_QueryStatus -TEH_PG_get_wire_fee (void *cls, - const char *type, - struct GNUNET_TIME_Timestamp date, - struct GNUNET_TIME_Timestamp *start_date, - struct GNUNET_TIME_Timestamp *end_date, - struct TALER_WireFeeSet *fees, - struct TALER_MasterSignatureP *master_sig); +TEH_PG_get_wire_fee ( + void *cls, + const char *type, + struct GNUNET_TIME_Timestamp date, + uint64_t *rowid, + struct GNUNET_TIME_Timestamp *start_date, + struct GNUNET_TIME_Timestamp *end_date, + struct TALER_WireFeeSet *fees, + struct TALER_MasterSignatureP *master_sig); #endif diff --git a/src/exchangedb/pg_insert_wire_fee.c b/src/exchangedb/pg_insert_wire_fee.c @@ -52,10 +52,12 @@ TEH_PG_insert_wire_fee (void *cls, struct GNUNET_TIME_Timestamp sd; struct GNUNET_TIME_Timestamp ed; enum GNUNET_DB_QueryStatus qs; + uint64_t rowid; qs = TEH_PG_get_wire_fee (pg, type, start_date, + &rowid, &sd, &ed, &wx, diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c @@ -810,6 +810,7 @@ test_wire_fees (void) struct GNUNET_TIME_Timestamp ed; struct TALER_WireFeeSet fees2; struct TALER_MasterSignatureP ms; + uint64_t rowid; start_date = GNUNET_TIME_timestamp_get (); end_date = GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES); @@ -850,6 +851,7 @@ test_wire_fees (void) plugin->get_wire_fee (plugin->cls, "wire-method", end_date, + &rowid, &sd, &ed, &fees2, @@ -862,6 +864,7 @@ test_wire_fees (void) plugin->get_wire_fee (plugin->cls, "wire-method", start_date, + &rowid, &sd, &ed, &fees2, diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h @@ -5067,6 +5067,7 @@ struct TALER_EXCHANGEDB_Plugin * @param cls closure * @param type type of wire transfer the fee applies for * @param date for which date do we want the fee? + * @param[out] rowid set to row in the database with the wire fee * @param[out] start_date when does the fee go into effect * @param[out] end_date when does the fee end being valid * @param[out] fees how high are the wire fees @@ -5078,6 +5079,7 @@ struct TALER_EXCHANGEDB_Plugin void *cls, const char *type, struct GNUNET_TIME_Timestamp date, + uint64_t *rowid, struct GNUNET_TIME_Timestamp *start_date, struct GNUNET_TIME_Timestamp *end_date, struct TALER_WireFeeSet *fees,