exchange

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

commit f999ecca338e5a41909547c4b50436753ec9dceb
parent c41ae69ba1dcc7f649d5dc14e43ff2b0f1e54dd7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue,  4 Nov 2025 12:47:15 +0100

implement DB query for #9436

Diffstat:
Msrc/auditordb/0002-auditor_early_aggregation.sql | 11+++++++++++
Msrc/auditordb/0002-auditor_pending_deposits.sql | 14++++++++++++++
Msrc/auditordb/Makefile.am | 1+
Msrc/auditordb/plugin_auditordb_postgres.c | 3+++
Msrc/include/taler/taler_auditordb_plugin.h | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/src/auditordb/0002-auditor_early_aggregation.sql b/src/auditordb/0002-auditor_early_aggregation.sql @@ -25,3 +25,14 @@ CREATE TABLE IF NOT EXISTS auditor_early_aggregations COMMENT ON TABLE auditor_early_aggregations IS 'Reports when aggregations/transfers are encountered before their justifications (can be harmless, if the justifications appear shortly afterwards).'; + +COMMENT ON COLUMN auditor_early_aggregations.row_id + IS 'Unique identifier of the report in the auditor database'; +COMMENT ON COLUMN auditor_early_aggregations.batch_deposit_serial_id + IS 'FIXME'; +COMMENT ON COLUMN auditor_early_aggregations.tracking_serial_id + IS 'FIXME'; +COMMENT ON COLUMN auditor_early_aggregations.amount + IS 'Total transaction amount impacted'; +COMMENT ON COLUMN auditor_early_aggregations.suppressed + IS 'True if the report was suppressed by an administrator'; diff --git a/src/auditordb/0002-auditor_pending_deposits.sql b/src/auditordb/0002-auditor_pending_deposits.sql @@ -23,3 +23,17 @@ CREATE TABLE IF NOT EXISTS auditor_pending_deposits deadline BIGINT NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); + +COMMENT ON TABLE auditor_pending_deposits + IS 'Reports when deposits are delayed (can be harmless, if the aggregation and wire transfer are made shortly afterwards)'; + +COMMENT ON COLUMN auditor_pending_deposits.row_id + IS 'Unique identifier of the report in the auditor database'; +COMMENT ON COLUMN auditor_pending_deposits.batch_deposit_serial_id + IS 'Serial ID of the deposit operation in the exchange database'; +COMMENT ON COLUMN auditor_pending_deposits.wire_target_h_payto + IS 'Hash of the bank account into which the deposit should have been made'; +COMMENT ON COLUMN auditor_pending_deposits.total_amount + IS 'Total transaction amount impacted'; +COMMENT ON COLUMN auditor_pending_deposits.suppressed + IS 'True if the report was suppressed by an administrator'; diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am @@ -131,6 +131,7 @@ libtaler_plugin_auditordb_postgres_la_SOURCES = \ pg_insert_wire_format_inconsistency.c pg_insert_wire_format_inconsistency.h \ pg_insert_wire_out_inconsistency.c pg_insert_wire_out_inconsistency.h \ pg_lookup_reserve_in_inconsistency.c pg_lookup_reserve_in_inconsistency.h \ + pg_select_early_aggregations.h pg_select_early_aggregations.c \ pg_select_historic_denom_revenue.c pg_select_historic_denom_revenue.h \ pg_select_historic_reserve_revenue.c pg_select_historic_reserve_revenue.h \ pg_select_pending_deposits.c pg_select_pending_deposits.h \ diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c @@ -67,6 +67,7 @@ #include "pg_get_coin_inconsistency.h" #include "pg_get_row_inconsistency.h" #include "pg_update_balance.h" +#include "pg_select_early_aggregations.h" #include "pg_insert_coin_inconsistency.h" #include "pg_insert_row_inconsistency.h" @@ -706,6 +707,8 @@ libtaler_plugin_auditordb_postgres_init (void *cls) = &TAH_PG_select_reserve_in_inconsistency; plugin->delete_reserve_in_inconsistency = &TAH_PG_delete_reserve_in_inconsistency; + plugin->select_early_aggregations + = &TAH_PG_select_early_aggregations; plugin->insert_reserve_balance_summary_wrong_inconsistency = &TAH_PG_insert_reserve_balance_summary_wrong_inconsistency; diff --git a/src/include/taler/taler_auditordb_plugin.h b/src/include/taler/taler_auditordb_plugin.h @@ -916,6 +916,50 @@ typedef enum GNUNET_GenericReturnValue /** + * Information about an early aggregation event. + */ +struct TALER_AUDITORDB_EarlyAggregation +{ + /** + * Row of the event in the auditor database. + */ + uint64_t row_id; + + /** + * Row of the batch deposit in the exchange database. + */ + uint64_t batch_deposit_serial_id; + + /** + * FIXME + */ + uint64_t tracking_serial_id; + + /** + * Total amount involved. + */ + struct TALER_Amount total; + + /** + * True if this report was previously suppressed. + */ + bool suppressed; +}; + + +/** + * Function to call with information about early aggregations. + * + * @param cls closure + * @param ea event data + * @return #GNUNET_OK to continue to iterate + */ +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_EarlyAggregationsCallback)( + void *cls, + const struct TALER_AUDITORDB_EarlyAggregation *ea); + +/** * @brief The plugin API, returned from the plugin's "init" function. * The argument given to "init" is simply a configuration handle. * @@ -1562,6 +1606,27 @@ struct TALER_AUDITORDB_Plugin TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb, void *cb_cls); + /** + * Returns all aggregations that were found that were done + * too early. + * + * @param cls closure + * @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 with results + * @param cb_cls closure for @a cb + * @return transaction status + */ + enum GNUNET_DB_QueryStatus + (*select_early_aggregations)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_EarlyAggregationsCallback cb, + void *cb_cls); + enum GNUNET_DB_QueryStatus (*delete_reserve_not_closed_inconsistency)( @@ -2132,6 +2197,8 @@ struct TALER_AUDITORDB_Plugin * Return information about an exchange's historic revenue from reserves. * * @param cls the @e cls of this struct with the plugin-specific state + * @param limit number of rows to return, negative to iterate backwards + * @param offset starting offset, exclusive * @param cb function to call with results * @param cb_cls closure for @a cb * @return transaction status code