exchange

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

commit d939c1a03f0518c61143c2cca51f5b40cdba069c
parent f999ecca338e5a41909547c4b50436753ec9dceb
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue,  4 Nov 2025 13:23:31 +0100

fix select_pending_deposits for #9316

Diffstat:
Msrc/auditordb/pg_select_pending_deposits.c | 44++++++++++++++++++++++++++++++++++++++++----
Msrc/auditordb/pg_select_pending_deposits.h | 6++++++
Msrc/include/taler/taler_auditordb_plugin.h | 14++++++++++++--
3 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/src/auditordb/pg_select_pending_deposits.c b/src/auditordb/pg_select_pending_deposits.c @@ -73,11 +73,15 @@ wire_missing_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { + uint64_t row_id; uint64_t batch_deposit_serial_id; struct TALER_Amount total_amount; struct TALER_FullPaytoHashP wire_target_h_payto; struct GNUNET_TIME_Timestamp deadline; + bool suppressed; struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("row_id", + &row_id), GNUNET_PQ_result_spec_uint64 ("batch_deposit_serial_id", &batch_deposit_serial_id), TALER_PQ_RESULT_SPEC_AMOUNT ("total_amount", @@ -86,6 +90,8 @@ wire_missing_cb (void *cls, &wire_target_h_payto), GNUNET_PQ_result_spec_timestamp ("deadline", &deadline), + GNUNET_PQ_result_spec_bool ("suppressed", + &suppressed), GNUNET_PQ_result_spec_end }; @@ -99,10 +105,12 @@ wire_missing_cb (void *cls, return; } eic->cb (eic->cb_cls, + row_id, batch_deposit_serial_id, &total_amount, &wire_target_h_payto, - deadline); + deadline, + suppressed); } eic->qs = num_results; } @@ -112,12 +120,19 @@ enum GNUNET_DB_QueryStatus TAH_PG_select_pending_deposits ( void *cls, struct GNUNET_TIME_Absolute deadline, + int64_t limit, + uint64_t offset, + bool return_suppressed, TALER_AUDITORDB_WireMissingCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; + uint64_t ulimit = (limit < 0) ? -limit : limit; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_absolute_time (&deadline), + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_uint64 (&ulimit), + GNUNET_PQ_query_param_bool (return_suppressed), GNUNET_PQ_query_param_end }; struct WireMissingContext eic = { @@ -128,14 +143,35 @@ TAH_PG_select_pending_deposits ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_select_pending_deposits", + "auditor_select_pending_deposits_asc", "SELECT" - " batch_deposit_serial_id" + " row_id" ",total_amount" ",wire_target_h_payto" + ",batch_deposit_serial_id" ",deadline" + ",suppressed" " FROM auditor_pending_deposits" - " WHERE deadline<$1;"); + " WHERE deadline<$1" + " AND (row_id > $2)" + " AND ($4 OR NOT suppressed)" + " ORDER BY row_id ASC" + " LIMIT $3;"); + PREPARE (pg, + "auditor_select_pending_deposits_desc", + "SELECT" + " row_id" + ",total_amount" + ",wire_target_h_payto" + ",batch_deposit_serial_id" + ",deadline" + ",suppressed" + " FROM auditor_pending_deposits" + " WHERE deadline<$1" + " AND (row_id < $2)" + " AND ($4 OR NOT suppressed)" + " ORDER BY row_id DESC" + " LIMIT $3;"); qs = GNUNET_PQ_eval_prepared_multi_select ( pg->conn, "auditor_select_pending_deposits", diff --git a/src/auditordb/pg_select_pending_deposits.h b/src/auditordb/pg_select_pending_deposits.h @@ -32,6 +32,9 @@ * * @param cls closure * @param deadline only return up to this deadline + * @param limit number of rows to return, negative to iterate backwards + * @param offset starting offset, exclusive + * @param return_suppressed true to also return suppressed events * @param cb function to call on each entry * @param cb_cls closure for @a cb * @return transaction status code @@ -40,6 +43,9 @@ enum GNUNET_DB_QueryStatus TAH_PG_select_pending_deposits ( void *cls, struct GNUNET_TIME_Absolute deadline, + int64_t limit, + uint64_t offset, + bool return_suppressed, TALER_AUDITORDB_WireMissingCallback cb, void *cb_cls); diff --git a/src/include/taler/taler_auditordb_plugin.h b/src/include/taler/taler_auditordb_plugin.h @@ -806,18 +806,22 @@ typedef enum GNUNET_GenericReturnValue * and have not yet seen a wire transfer. * * @param cls closure - * @param batch_deposit_serial_id where in the table are we + * @param row_id row ID of the alert in the auditor database + * @param batch_deposit_serial_id where in the exchange table are we * @param total_amount value of all missing deposits, including fees * @param wire_target_h_payto hash of the recipient account's payto URI * @param deadline what was the earliest requested wire transfer deadline + * @param suppressed true if this report was suppressed */ typedef void (*TALER_AUDITORDB_WireMissingCallback) ( void *cls, + uint64_t row_id, uint64_t batch_deposit_serial_id, const struct TALER_Amount *total_amount, const struct TALER_FullPaytoHashP *wire_target_h_payto, - struct GNUNET_TIME_Timestamp deadline); + struct GNUNET_TIME_Timestamp deadline, + bool suppressed); /** @@ -1985,6 +1989,9 @@ struct TALER_AUDITORDB_Plugin * seen the required wire transfer. * * @param deadline only return up to this deadline + * @param limit number of rows to return, negative to iterate backwards + * @param offset starting offset, exclusive + * @param return_suppressed true to also return suppressed events * @param cb function to call on each entry * @param cb_cls closure for @a cb * @return transaction status code @@ -1993,6 +2000,9 @@ struct TALER_AUDITORDB_Plugin (*select_pending_deposits)( void *cls, struct GNUNET_TIME_Absolute deadline, + int64_t limit, + uint64_t offset, + bool return_suppressed, TALER_AUDITORDB_WireMissingCallback cb, void *cb_cls);