aboutsummaryrefslogtreecommitdiff
path: root/src/auditordb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-02-07 23:51:33 +0100
committerChristian Grothoff <christian@grothoff.org>2024-02-07 23:56:07 +0100
commit97f3e30c3d4081a6765c914c94b6cbf3a75110f3 (patch)
tree5ff0d97240d39ab987564154d9d9a3f4a88eebf5 /src/auditordb
parentc6b14a97c57528cbcf5e23e20707e8ec50b7faec (diff)
parente0d46f96859b33b3f04791028e30bce4f0173567 (diff)
fixing merge conflict
Diffstat (limited to 'src/auditordb')
-rw-r--r--src/auditordb/.gitignore4
-rw-r--r--src/auditordb/0002-auditor_balances.sql5
-rw-r--r--src/auditordb/0002-auditor_progress.sql2
-rw-r--r--src/auditordb/Makefile.am132
-rw-r--r--src/auditordb/auditor-0001.sql581
-rw-r--r--src/auditordb/auditor_do_get_auditor_progress.sql38
-rw-r--r--src/auditordb/auditor_do_get_balance.sql47
-rw-r--r--src/auditordb/pg_del_denomination_balance.c (renamed from src/auditordb/pg_delete_exchange.c)24
-rw-r--r--src/auditordb/pg_del_denomination_balance.h (renamed from src/auditordb/pg_get_balance_summary.h)21
-rw-r--r--src/auditordb/pg_del_reserve_info.c11
-rw-r--r--src/auditordb/pg_del_reserve_info.h4
-rw-r--r--src/auditordb/pg_delete_deposit_confirmations.c27
-rw-r--r--src/auditordb/pg_delete_deposit_confirmations.h20
-rw-r--r--src/auditordb/pg_delete_exchange.h43
-rw-r--r--src/auditordb/pg_delete_pending_deposit.c5
-rw-r--r--src/auditordb/pg_delete_pending_deposit.h2
-rw-r--r--src/auditordb/pg_delete_purse_info.c7
-rw-r--r--src/auditordb/pg_delete_purse_info.h4
-rw-r--r--src/auditordb/pg_get_auditor_progress.c178
-rw-r--r--src/auditordb/pg_get_auditor_progress.h (renamed from src/auditordb/pg_get_auditor_progress_deposit_confirmation.h)23
-rw-r--r--src/auditordb/pg_get_auditor_progress_aggregation.c56
-rw-r--r--src/auditordb/pg_get_auditor_progress_aggregation.h43
-rw-r--r--src/auditordb/pg_get_auditor_progress_coin.c77
-rw-r--r--src/auditordb/pg_get_auditor_progress_coin.h43
-rw-r--r--src/auditordb/pg_get_auditor_progress_deposit_confirmation.c54
-rw-r--r--src/auditordb/pg_get_auditor_progress_purse.c68
-rw-r--r--src/auditordb/pg_get_auditor_progress_reserve.c77
-rw-r--r--src/auditordb/pg_get_auditor_progress_reserve.h43
-rw-r--r--src/auditordb/pg_get_balance.c183
-rw-r--r--src/auditordb/pg_get_balance.h (renamed from src/auditordb/pg_get_purse_summary.h)25
-rw-r--r--src/auditordb/pg_get_balance_summary.c80
-rw-r--r--src/auditordb/pg_get_deposit_confirmations.c19
-rw-r--r--src/auditordb/pg_get_deposit_confirmations.h2
-rw-r--r--src/auditordb/pg_get_predicted_balance.c59
-rw-r--r--src/auditordb/pg_get_predicted_balance.h44
-rw-r--r--src/auditordb/pg_get_purse_info.c5
-rw-r--r--src/auditordb/pg_get_purse_info.h2
-rw-r--r--src/auditordb/pg_get_purse_summary.c58
-rw-r--r--src/auditordb/pg_get_reserve_info.c8
-rw-r--r--src/auditordb/pg_get_reserve_info.h2
-rw-r--r--src/auditordb/pg_get_reserve_summary.c81
-rw-r--r--src/auditordb/pg_get_reserve_summary.h43
-rw-r--r--src/auditordb/pg_get_wire_auditor_account_progress.c68
-rw-r--r--src/auditordb/pg_get_wire_auditor_account_progress.h48
-rw-r--r--src/auditordb/pg_get_wire_auditor_progress.c62
-rw-r--r--src/auditordb/pg_get_wire_auditor_progress.h44
-rw-r--r--src/auditordb/pg_get_wire_fee_summary.c6
-rw-r--r--src/auditordb/pg_get_wire_fee_summary.h2
-rw-r--r--src/auditordb/pg_insert_auditor_progress.c97
-rw-r--r--src/auditordb/pg_insert_auditor_progress.h (renamed from src/auditordb/pg_insert_wire_auditor_progress.h)21
-rw-r--r--src/auditordb/pg_insert_auditor_progress_aggregation.c51
-rw-r--r--src/auditordb/pg_insert_auditor_progress_aggregation.h45
-rw-r--r--src/auditordb/pg_insert_auditor_progress_coin.c65
-rw-r--r--src/auditordb/pg_insert_auditor_progress_coin.h44
-rw-r--r--src/auditordb/pg_insert_auditor_progress_deposit_confirmation.c53
-rw-r--r--src/auditordb/pg_insert_auditor_progress_deposit_confirmation.h44
-rw-r--r--src/auditordb/pg_insert_auditor_progress_purse.c59
-rw-r--r--src/auditordb/pg_insert_auditor_progress_purse.h44
-rw-r--r--src/auditordb/pg_insert_auditor_progress_reserve.c65
-rw-r--r--src/auditordb/pg_insert_auditor_progress_reserve.h43
-rw-r--r--src/auditordb/pg_insert_balance.c97
-rw-r--r--src/auditordb/pg_insert_balance.h (renamed from src/auditordb/pg_get_auditor_progress_purse.h)27
-rw-r--r--src/auditordb/pg_insert_balance_summary.c76
-rw-r--r--src/auditordb/pg_insert_balance_summary.h44
-rw-r--r--src/auditordb/pg_insert_deposit_confirmation.c6
-rw-r--r--src/auditordb/pg_insert_exchange.c49
-rw-r--r--src/auditordb/pg_insert_exchange.h43
-rw-r--r--src/auditordb/pg_insert_exchange_signkey.c6
-rw-r--r--src/auditordb/pg_insert_historic_denom_revenue.c7
-rw-r--r--src/auditordb/pg_insert_historic_denom_revenue.h2
-rw-r--r--src/auditordb/pg_insert_historic_reserve_revenue.c7
-rw-r--r--src/auditordb/pg_insert_historic_reserve_revenue.h2
-rw-r--r--src/auditordb/pg_insert_pending_deposit.c7
-rw-r--r--src/auditordb/pg_insert_pending_deposit.h2
-rw-r--r--src/auditordb/pg_insert_predicted_result.c56
-rw-r--r--src/auditordb/pg_insert_predicted_result.h46
-rw-r--r--src/auditordb/pg_insert_purse_info.c5
-rw-r--r--src/auditordb/pg_insert_purse_info.h2
-rw-r--r--src/auditordb/pg_insert_purse_summary.c54
-rw-r--r--src/auditordb/pg_insert_purse_summary.h45
-rw-r--r--src/auditordb/pg_insert_reserve_info.c10
-rw-r--r--src/auditordb/pg_insert_reserve_info.h2
-rw-r--r--src/auditordb/pg_insert_reserve_summary.c75
-rw-r--r--src/auditordb/pg_insert_reserve_summary.h45
-rw-r--r--src/auditordb/pg_insert_wire_auditor_account_progress.c61
-rw-r--r--src/auditordb/pg_insert_wire_auditor_account_progress.h48
-rw-r--r--src/auditordb/pg_insert_wire_auditor_progress.c55
-rw-r--r--src/auditordb/pg_insert_wire_fee_summary.c52
-rw-r--r--src/auditordb/pg_insert_wire_fee_summary.h44
-rw-r--r--src/auditordb/pg_list_exchanges.c125
-rw-r--r--src/auditordb/pg_list_exchanges.h43
-rw-r--r--src/auditordb/pg_select_historic_denom_revenue.c5
-rw-r--r--src/auditordb/pg_select_historic_denom_revenue.h3
-rw-r--r--src/auditordb/pg_select_historic_reserve_revenue.c5
-rw-r--r--src/auditordb/pg_select_historic_reserve_revenue.h2
-rw-r--r--src/auditordb/pg_select_pending_deposits.c1
-rw-r--r--src/auditordb/pg_select_pending_deposits.h2
-rw-r--r--src/auditordb/pg_select_purse_expired.c5
-rw-r--r--src/auditordb/pg_select_purse_expired.h2
-rw-r--r--src/auditordb/pg_template.c2
-rw-r--r--src/auditordb/pg_template.h2
-rw-r--r--src/auditordb/pg_update_auditor_progress.c99
-rw-r--r--src/auditordb/pg_update_auditor_progress.h (renamed from src/auditordb/pg_update_wire_auditor_progress.h)21
-rw-r--r--src/auditordb/pg_update_auditor_progress_aggregation.c50
-rw-r--r--src/auditordb/pg_update_auditor_progress_aggregation.h44
-rw-r--r--src/auditordb/pg_update_auditor_progress_coin.c64
-rw-r--r--src/auditordb/pg_update_auditor_progress_coin.h44
-rw-r--r--src/auditordb/pg_update_auditor_progress_deposit_confirmation.c50
-rw-r--r--src/auditordb/pg_update_auditor_progress_deposit_confirmation.h45
-rw-r--r--src/auditordb/pg_update_auditor_progress_purse.c58
-rw-r--r--src/auditordb/pg_update_auditor_progress_purse.h44
-rw-r--r--src/auditordb/pg_update_auditor_progress_reserve.c64
-rw-r--r--src/auditordb/pg_update_auditor_progress_reserve.h43
-rw-r--r--src/auditordb/pg_update_balance.c100
-rw-r--r--src/auditordb/pg_update_balance.h (renamed from src/auditordb/pg_update_purse_summary.h)24
-rw-r--r--src/auditordb/pg_update_balance_summary.c75
-rw-r--r--src/auditordb/pg_update_balance_summary.h44
-rw-r--r--src/auditordb/pg_update_predicted_result.c55
-rw-r--r--src/auditordb/pg_update_predicted_result.h46
-rw-r--r--src/auditordb/pg_update_purse_info.c9
-rw-r--r--src/auditordb/pg_update_purse_info.h2
-rw-r--r--src/auditordb/pg_update_purse_summary.c53
-rw-r--r--src/auditordb/pg_update_reserve_info.c9
-rw-r--r--src/auditordb/pg_update_reserve_info.h2
-rw-r--r--src/auditordb/pg_update_reserve_summary.c69
-rw-r--r--src/auditordb/pg_update_reserve_summary.h45
-rw-r--r--src/auditordb/pg_update_wire_auditor_account_progress.c59
-rw-r--r--src/auditordb/pg_update_wire_auditor_account_progress.h49
-rw-r--r--src/auditordb/pg_update_wire_auditor_progress.c54
-rw-r--r--src/auditordb/pg_update_wire_fee_summary.c5
-rw-r--r--src/auditordb/pg_update_wire_fee_summary.h2
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c308
-rw-r--r--src/auditordb/procedures.sql.in24
-rw-r--r--src/auditordb/test_auditordb.c280
-rw-r--r--src/auditordb/test_auditordb_checkpoints.c386
135 files changed, 1871 insertions, 4738 deletions
diff --git a/src/auditordb/.gitignore b/src/auditordb/.gitignore
index 56c08312b..e1c7a648b 100644
--- a/src/auditordb/.gitignore
+++ b/src/auditordb/.gitignore
@@ -1 +1,5 @@
test-auditordb-postgres
+auditor-0002.sql
+procedures.sql
+test_auditordb_checkpoints_postgres
+test_auditordb-postgres
diff --git a/src/auditordb/0002-auditor_balances.sql b/src/auditordb/0002-auditor_balances.sql
index 5a25a0e2a..a52edbcd0 100644
--- a/src/auditordb/0002-auditor_balances.sql
+++ b/src/auditordb/0002-auditor_balances.sql
@@ -17,9 +17,8 @@
SET search_path TO auditor;
CREATE TABLE IF NOT EXISTS auditor_balances
(
- balance_key TEXT
- ,balance_value taler_amount
- ,PRIMARY KEY (balance_key)
+ balance_key TEXT PRIMARY KEY NOT NULL
+ ,balance_value taler_amount
);
COMMENT
ON TABLE auditor_balances
diff --git a/src/auditordb/0002-auditor_progress.sql b/src/auditordb/0002-auditor_progress.sql
index 40a9fbf7c..288a08ae9 100644
--- a/src/auditordb/0002-auditor_progress.sql
+++ b/src/auditordb/0002-auditor_progress.sql
@@ -15,7 +15,7 @@
--
CREATE TABLE IF NOT EXISTS auditor_progress
- (progress_key TEXT NOT NULL
+ (progress_key TEXT PRIMARY KEY NOT NULL
,progress_offset INT8 NOT NULL
);
COMMENT ON TABLE auditor_progress
diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am
index ea8c8fe98..3e7d83d09 100644
--- a/src/auditordb/Makefile.am
+++ b/src/auditordb/Makefile.am
@@ -13,23 +13,34 @@ pkgcfg_DATA = \
sqldir = $(prefix)/share/taler/sql/auditor/
+sqlinputs = \
+ 0002-*.sql \
+ auditor-0002.sql.in \
+ auditor_do_*.sql \
+ procedures.sql.in
+
sql_DATA = \
versioning.sql \
auditor-0001.sql \
+ auditor-0002.sql \
drop.sql \
- restart.sql
+ restart.sql \
+ procedures.sql
-sqlinputs = \
- 0002-*.sql \
- auditor-0002.sql.in
-# auditor_do_*.sql
-# procedures.sql.in
+CLEANFILES = \
+ auditor-0002.sql
+
+procedures.sql: procedures.sql.in auditor_do_*.sql
+ chmod +w $@ || true
+ gcc -E -P -undef - < procedures.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@
+ chmod ugo-w $@
auditor-0002.sql: auditor-0002.sql.in 0002-*.sql
chmod +w $@ || true
gcc -E -P -undef - < auditor-0002.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@
chmod ugo-w $@
+
EXTRA_DIST = \
auditordb-postgres.conf \
test-auditor-db-postgres.conf \
@@ -47,68 +58,38 @@ endif
libtaler_plugin_auditordb_postgres_la_SOURCES = \
plugin_auditordb_postgres.c pg_helper.h \
- pg_insert_auditor_progress_reserve.h pg_insert_auditor_progress_reserve.c \
- pg_update_auditor_progress_reserve.h pg_update_auditor_progress_reserve.c \
- pg_get_auditor_progress_reserve.h pg_get_auditor_progress_reserve.c \
- pg_insert_auditor_progress_purse.h pg_insert_auditor_progress_purse.c \
- pg_update_auditor_progress_purse.h pg_update_auditor_progress_purse.c \
- pg_get_auditor_progress_purse.h pg_get_auditor_progress_purse.c \
- pg_insert_auditor_progress_aggregation.h pg_insert_auditor_progress_aggregation.c \
- pg_update_auditor_progress_aggregation.h pg_update_auditor_progress_aggregation.c \
- pg_get_auditor_progress_aggregation.h pg_get_auditor_progress_aggregation.c \
- pg_insert_auditor_progress_deposit_confirmation.h pg_insert_auditor_progress_deposit_confirmation.c \
- pg_update_auditor_progress_deposit_confirmation.h pg_update_auditor_progress_deposit_confirmation.c \
- pg_get_auditor_progress_deposit_confirmation.h pg_get_auditor_progress_deposit_confirmation.c \
- pg_insert_auditor_progress_coin.h pg_insert_auditor_progress_coin.c \
- pg_update_auditor_progress_coin.h pg_update_auditor_progress_coin.c \
- pg_get_auditor_progress_coin.h pg_get_auditor_progress_coin.c \
- pg_insert_wire_auditor_account_progress.h pg_insert_wire_auditor_account_progress.c \
- pg_update_wire_auditor_account_progress.h pg_update_wire_auditor_account_progress.c \
- pg_get_wire_auditor_account_progress.h pg_get_wire_auditor_account_progress.c \
- pg_insert_wire_auditor_progress.h pg_insert_wire_auditor_progress.c \
- pg_update_wire_auditor_progress.h pg_update_wire_auditor_progress.c \
- pg_get_wire_auditor_progress.h pg_get_wire_auditor_progress.c \
- pg_insert_reserve_info.h pg_insert_reserve_info.c \
- pg_update_reserve_info.h pg_update_reserve_info.c \
- pg_del_reserve_info.h pg_del_reserve_info.c \
- pg_get_reserve_info.h pg_get_reserve_info.c \
- pg_insert_reserve_summary.h pg_insert_reserve_summary.c \
- pg_update_reserve_summary.h pg_update_reserve_summary.c \
- pg_select_pending_deposits.h pg_select_pending_deposits.c \
- pg_delete_pending_deposit.h pg_delete_pending_deposit.c \
- pg_insert_pending_deposit.h pg_insert_pending_deposit.c \
- pg_get_reserve_summary.h pg_get_reserve_summary.c \
- pg_insert_wire_fee_summary.h pg_insert_wire_fee_summary.c \
- pg_update_wire_fee_summary.h pg_update_wire_fee_summary.c \
- pg_get_wire_fee_summary.h pg_get_wire_fee_summary.c \
- pg_insert_denomination_balance.h pg_insert_denomination_balance.c \
- pg_update_denomination_balance.h pg_update_denomination_balance.c \
- pg_get_denomination_balance.h pg_get_denomination_balance.c \
- pg_insert_balance_summary.h pg_insert_balance_summary.c \
- pg_update_balance_summary.h pg_update_balance_summary.c \
- pg_get_balance_summary.h pg_get_balance_summary.c \
- pg_insert_historic_denom_revenue.h pg_insert_historic_denom_revenue.c \
- pg_select_historic_denom_revenue.h pg_select_historic_denom_revenue.c \
- pg_insert_historic_reserve_revenue.h pg_insert_historic_reserve_revenue.c \
- pg_select_historic_reserve_revenue.h pg_select_historic_reserve_revenue.c \
- pg_insert_predicted_result.h pg_insert_predicted_result.c \
- pg_update_predicted_result.h pg_update_predicted_result.c \
- pg_get_predicted_balance.h pg_get_predicted_balance.c \
- pg_insert_exchange.h pg_insert_exchange.c \
- pg_list_exchanges.h pg_list_exchanges.c \
- pg_delete_exchange.h pg_delete_exchange.c \
- pg_insert_exchange_signkey.h pg_insert_exchange_signkey.c \
- pg_insert_deposit_confirmation.h pg_insert_deposit_confirmation.c \
- pg_delete_deposit_confirmations.h pg_delete_deposit_confirmations.c \
- pg_get_purse_info.h pg_get_purse_info.c \
- pg_delete_purse_info.h pg_delete_purse_info.c \
- pg_update_purse_info.h pg_update_purse_info.c \
- pg_insert_purse_info.h pg_insert_purse_info.c \
- pg_get_purse_summary.h pg_get_purse_summary.c \
- pg_select_purse_expired.h pg_select_purse_expired.c \
- pg_insert_purse_summary.h pg_insert_purse_summary.c \
- pg_update_purse_summary.h pg_update_purse_summary.c \
- pg_get_deposit_confirmations.h pg_get_deposit_confirmations.c
+ pg_delete_deposit_confirmations.c pg_delete_deposit_confirmations.h \
+ pg_delete_pending_deposit.c pg_delete_pending_deposit.h \
+ pg_delete_purse_info.c pg_delete_purse_info.h \
+ pg_del_denomination_balance.h pg_del_denomination_balance.c \
+ pg_del_reserve_info.c pg_del_reserve_info.h \
+ pg_get_auditor_progress.c pg_get_auditor_progress.h \
+ pg_get_balance.c pg_get_balance.h \
+ pg_get_denomination_balance.c pg_get_denomination_balance.h \
+ pg_get_deposit_confirmations.c pg_get_deposit_confirmations.h \
+ pg_get_purse_info.c pg_get_purse_info.h \
+ pg_get_reserve_info.c pg_get_reserve_info.h \
+ pg_get_wire_fee_summary.c pg_get_wire_fee_summary.h \
+ pg_insert_auditor_progress.c pg_insert_auditor_progress.h \
+ pg_insert_balance.c pg_insert_balance.h \
+ pg_insert_denomination_balance.c pg_insert_denomination_balance.h \
+ pg_insert_deposit_confirmation.c pg_insert_deposit_confirmation.h \
+ pg_insert_exchange_signkey.c pg_insert_exchange_signkey.h \
+ pg_insert_historic_denom_revenue.c pg_insert_historic_denom_revenue.h \
+ pg_insert_historic_reserve_revenue.c pg_insert_historic_reserve_revenue.h \
+ pg_insert_pending_deposit.c pg_insert_pending_deposit.h \
+ pg_insert_purse_info.c pg_insert_purse_info.h \
+ pg_insert_reserve_info.c pg_insert_reserve_info.h \
+ 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 \
+ pg_select_purse_expired.c pg_select_purse_expired.h \
+ pg_update_auditor_progress.c pg_update_auditor_progress.h \
+ pg_update_balance.c pg_update_balance.h \
+ pg_update_denomination_balance.c pg_update_denomination_balance.h \
+ pg_update_purse_info.c pg_update_purse_info.h \
+ pg_update_reserve_info.c pg_update_reserve_info.h \
+ pg_update_wire_fee_summary.c pg_update_wire_fee_summary.h
libtaler_plugin_auditordb_postgres_la_LDFLAGS = \
$(TALER_PLUGIN_LDFLAGS)
libtaler_plugin_auditordb_postgres_la_LIBADD = \
@@ -139,11 +120,22 @@ libtalerauditordb_la_LDFLAGS = \
check_PROGRAMS = \
- test-auditordb-postgres
+ test_auditordb_checkpoints-postgres \
+ test_auditordb-postgres
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \
- test-auditordb-postgres
+ test_auditordb_checkpoints-postgres \
+ test_auditordb-postgres
+
+test_auditordb_checkpoints_postgres_SOURCES = \
+ test_auditordb_checkpoints.c
+test_auditordb_checkpoints_postgres_LDADD = \
+ libtalerauditordb.la \
+ $(top_srcdir)/src/pq/libtalerpq.la \
+ $(top_srcdir)/src/util/libtalerutil.la \
+ -lgnunetutil \
+ $(XLIB)
test_auditordb_postgres_SOURCES = \
test_auditordb.c
diff --git a/src/auditordb/auditor-0001.sql b/src/auditordb/auditor-0001.sql
index 779f61aaa..0b7823cec 100644
--- a/src/auditordb/auditor-0001.sql
+++ b/src/auditordb/auditor-0001.sql
@@ -1,6 +1,6 @@
--
-- This file is part of TALER
--- Copyright (C) 2014--2023 Taler Systems SA
+-- Copyright (C) 2014--2024 Taler Systems SA
--
-- TALER is free software; you can redistribute it and/or modify it under the
-- terms of the GNU General Public License as published by the Free Software
@@ -14,10 +14,8 @@
-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
--
--- Everything in one big transaction
BEGIN;
--- Check patch versioning is in place.
SELECT _v.register_patch('auditor-0001', NULL, NULL);
CREATE SCHEMA auditor;
@@ -25,321 +23,274 @@ COMMENT ON SCHEMA auditor IS 'taler-auditor data';
SET search_path TO auditor;
-CREATE TYPE taler_amount
- AS
- (val INT8
- ,frac INT4
+---------------------------------------------------------------------------
+-- General procedures for DB setup
+---------------------------------------------------------------------------
+
+CREATE TABLE auditor_tables
+ (table_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY
+ ,name TEXT NOT NULL
+ ,version TEXT NOT NULL
+ ,action TEXT NOT NULL
+ ,partitioned BOOL NOT NULL
+ ,by_range BOOL NOT NULL
+ ,finished BOOL NOT NULL DEFAULT(FALSE));
+COMMENT ON TABLE auditor_tables
+ IS 'Tables of the auditor and their status';
+COMMENT ON COLUMN auditor_tables.name
+ IS 'Base name of the table (without partition/shard)';
+COMMENT ON COLUMN auditor_tables.version
+ IS 'Version of the DB in which the given action happened';
+COMMENT ON COLUMN auditor_tables.action
+ IS 'Action to take on the table (e.g. create, constrain, or foreign). Create is done for the master table and each partition; constrain is only for partitions or for master if there are no partitions; master only on master (takes no argument); foreign only on master if there are no partitions.';
+COMMENT ON COLUMN auditor_tables.partitioned
+ IS 'TRUE if the table is partitioned';
+COMMENT ON COLUMN auditor_tables.by_range
+ IS 'TRUE if the table is partitioned by range';
+COMMENT ON COLUMN auditor_tables.finished
+ IS 'TRUE if the respective migration has been run';
+
+
+CREATE FUNCTION create_partitioned_table(
+ IN table_definition TEXT -- SQL template for table creation
+ ,IN table_name TEXT -- base name of the table
+ ,IN main_table_partition_str TEXT -- declaration for how to partition the table
+ ,IN partition_suffix TEXT DEFAULT NULL -- NULL: no partitioning, 0: yes partitioning, no sharding, >0: sharding
+)
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ IF (partition_suffix IS NULL)
+ THEN
+ -- no partitioning, disable option
+ main_table_partition_str = '';
+ ELSE
+ IF (partition_suffix::int > 0)
+ THEN
+ -- sharding, add shard name
+ table_name=table_name || '_' || partition_suffix;
+ END IF;
+ END IF;
+ EXECUTE FORMAT(
+ table_definition,
+ table_name,
+ main_table_partition_str
);
-COMMENT ON TYPE taler_amount
- IS 'Stores an amount, fraction is in units of 1/100000000 of the base value';
-
-
-CREATE TABLE IF NOT EXISTS auditor_exchanges
- (master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)
- ,exchange_url TEXT NOT NULL
- );
-COMMENT ON TABLE auditor_exchanges
- IS 'list of the exchanges we are auditing';
-
-
-CREATE TABLE IF NOT EXISTS auditor_exchange_signkeys
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,ep_start INT8 NOT NULL
- ,ep_expire INT8 NOT NULL
- ,ep_end INT8 NOT NULL
- ,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)
- ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
- );
-COMMENT ON TABLE auditor_exchange_signkeys
- IS 'list of the online signing keys of exchanges we are auditing';
-
-
-CREATE TABLE IF NOT EXISTS auditor_progress_reserve
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0
- ,last_reserve_out_serial_id INT8 NOT NULL DEFAULT 0
- ,last_reserve_recoup_serial_id INT8 NOT NULL DEFAULT 0
- ,last_reserve_open_serial_id INT8 NOT NULL DEFAULT 0
- ,last_reserve_close_serial_id INT8 NOT NULL DEFAULT 0
- ,last_purse_decision_serial_id INT8 NOT NULL DEFAULT 0
- ,last_account_merges_serial_id INT8 NOT NULL DEFAULT 0
- ,last_history_requests_serial_id INT8 NOT NULL DEFAULT 0
- ,PRIMARY KEY (master_pub)
- );
-COMMENT ON TABLE auditor_progress_reserve
- IS 'information as to which transactions the reserve auditor has processed in the exchange database. Used for SELECTing the
- statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
-
-
-CREATE TABLE IF NOT EXISTS auditor_progress_purse
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,last_purse_request_serial_id INT8 NOT NULL DEFAULT 0
- ,last_purse_decision_serial_id INT8 NOT NULL DEFAULT 0
- ,last_purse_merges_serial_id INT8 NOT NULL DEFAULT 0
- ,last_account_merges_serial_id INT8 NOT NULL DEFAULT 0
- ,last_purse_deposits_serial_id INT8 NOT NULL DEFAULT 0
- ,PRIMARY KEY (master_pub)
- );
-COMMENT ON TABLE auditor_progress_purse
- IS 'information as to which purses the purse auditor has processed in the exchange database. Used for SELECTing the
- statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
-
-
-CREATE TABLE IF NOT EXISTS auditor_progress_aggregation
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,last_wire_out_serial_id INT8 NOT NULL DEFAULT 0
- ,PRIMARY KEY (master_pub)
- );
-COMMENT ON TABLE auditor_progress_aggregation
- IS 'information as to which transactions the auditor has processed in the exchange database. Used for SELECTing the
- statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
-
-
-CREATE TABLE IF NOT EXISTS auditor_progress_deposit_confirmation
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,last_deposit_confirmation_serial_id INT8 NOT NULL DEFAULT 0
- ,PRIMARY KEY (master_pub)
- );
-COMMENT ON TABLE auditor_progress_deposit_confirmation
- IS 'information as to which transactions the auditor has processed in the exchange database. Used for SELECTing the
- statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
-
-
-CREATE TABLE IF NOT EXISTS auditor_progress_coin
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,last_withdraw_serial_id INT8 NOT NULL DEFAULT 0
- ,last_deposit_serial_id INT8 NOT NULL DEFAULT 0
- ,last_melt_serial_id INT8 NOT NULL DEFAULT 0
- ,last_refund_serial_id INT8 NOT NULL DEFAULT 0
- ,last_recoup_serial_id INT8 NOT NULL DEFAULT 0
- ,last_recoup_refresh_serial_id INT8 NOT NULL DEFAULT 0
- ,last_open_deposits_serial_id INT8 NOT NULL DEFAULT 0
- ,last_purse_deposits_serial_id INT8 NOT NULL DEFAULT 0
- ,last_purse_decision_serial_id INT8 NOT NULL DEFAULT 0
- ,PRIMARY KEY (master_pub)
- );
-COMMENT ON TABLE auditor_progress_coin
- IS 'information as to which transactions the auditor has processed in the exchange database. Used for SELECTing the
- statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
-
-
-CREATE TABLE IF NOT EXISTS wire_auditor_account_progress
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,account_name TEXT NOT NULL
- ,last_wire_reserve_in_serial_id INT8 NOT NULL DEFAULT 0
- ,last_wire_wire_out_serial_id INT8 NOT NULL DEFAULT 0
- ,wire_in_off INT8 NOT NULL
- ,wire_out_off INT8 NOT NULL
- ,PRIMARY KEY (master_pub,account_name)
- );
-COMMENT ON TABLE wire_auditor_account_progress
- IS 'information as to which transactions the auditor has processed in the exchange database. Used for SELECTing the
- statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
-
-
-CREATE TABLE IF NOT EXISTS wire_auditor_progress
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,last_reserve_close_uuid INT8 NOT NULL
- ,last_batch_deposit_uuid INT8 NOT NULL
- ,last_aggregation_serial INT8 NOT NULL
- ,PRIMARY KEY (master_pub)
- );
-
-
-CREATE TABLE IF NOT EXISTS auditor_reserves
- (reserve_pub BYTEA NOT NULL CHECK(LENGTH(reserve_pub)=32)
- ,master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,reserve_balance taler_amount NOT NULL
- ,reserve_loss taler_amount NOT NULL
- ,withdraw_fee_balance taler_amount NOT NULL
- ,close_fee_balance taler_amount NOT NULL
- ,purse_fee_balance taler_amount NOT NULL
- ,open_fee_balance taler_amount NOT NULL
- ,history_fee_balance taler_amount NOT NULL
- ,expiration_date INT8 NOT NULL
- ,auditor_reserves_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
- ,origin_account TEXT
+END $$;
+
+COMMENT ON FUNCTION create_partitioned_table
+ IS 'Generic function to create a table that is partitioned or sharded.';
+
+
+CREATE FUNCTION comment_partitioned_table(
+ IN table_comment TEXT
+ ,IN table_name TEXT
+ ,IN partition_suffix TEXT DEFAULT NULL
+)
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ IF ( (partition_suffix IS NOT NULL) AND
+ (partition_suffix::int > 0) )
+ THEN
+ -- sharding, add shard name
+ table_name=table_name || '_' || partition_suffix;
+ END IF;
+ EXECUTE FORMAT(
+ 'COMMENT ON TABLE %s IS %s'
+ ,table_name
+ ,quote_literal(table_comment)
);
-COMMENT ON TABLE auditor_reserves
- IS 'all of the customer reserves and their respective balances that the auditor is aware of';
-
-CREATE INDEX IF NOT EXISTS auditor_reserves_by_reserve_pub
- ON auditor_reserves
- (reserve_pub);
-
-
-CREATE TABLE IF NOT EXISTS auditor_purses
- (purse_pub BYTEA NOT NULL CHECK(LENGTH(purse_pub)=32)
- ,master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,balance taler_amount NOT NULL DEFAULT(0,0)
- ,target taler_amount NOT NULL
- ,expiration_date INT8 NOT NULL
- ,auditor_purses_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
+END $$;
+
+COMMENT ON FUNCTION comment_partitioned_table
+ IS 'Generic function to create a comment on table that is partitioned.';
+
+
+CREATE FUNCTION comment_partitioned_column(
+ IN table_comment TEXT
+ ,IN column_name TEXT
+ ,IN table_name TEXT
+ ,IN partition_suffix TEXT DEFAULT NULL
+)
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ IF ( (partition_suffix IS NOT NULL) AND
+ (partition_suffix::int > 0) )
+ THEN
+ -- sharding, add shard name
+ table_name=table_name || '_' || partition_suffix;
+ END IF;
+ EXECUTE FORMAT(
+ 'COMMENT ON COLUMN %s.%s IS %s'
+ ,table_name
+ ,column_name
+ ,quote_literal(table_comment)
);
-COMMENT ON TABLE auditor_purses
- IS 'all of the purses and their respective balances that the auditor is aware of';
+END $$;
+
+COMMENT ON FUNCTION comment_partitioned_column
+ IS 'Generic function to create a comment on column of a table that is partitioned.';
+
+
+---------------------------------------------------------------------------
+-- Main DB setup loop
+---------------------------------------------------------------------------
+
+CREATE FUNCTION do_create_tables(
+ num_partitions INTEGER
+-- NULL: no partitions, add foreign constraints
+-- 0: no partitions, no foreign constraints
+-- 1: only 1 default partition
+-- > 1: normal partitions
+)
+ RETURNS VOID
+ LANGUAGE plpgsql
+AS $$
+DECLARE
+ tc CURSOR FOR
+ SELECT table_serial_id
+ ,name
+ ,action
+ ,partitioned
+ ,by_range
+ FROM auditor.auditor_tables
+ WHERE NOT finished
+ ORDER BY table_serial_id ASC;
+BEGIN
+ FOR rec IN tc
+ LOOP
+ CASE rec.action
+ -- "create" actions apply to master and partitions
+ WHEN 'create'
+ THEN
+ IF (rec.partitioned AND
+ (num_partitions IS NOT NULL))
+ THEN
+ -- Create master table with partitioning.
+ EXECUTE FORMAT(
+ 'SELECT auditor.%s_table_%s (%s)'::text
+ ,rec.action
+ ,rec.name
+ ,quote_literal('0')
+ );
+ IF (rec.by_range OR
+ (num_partitions = 0))
+ THEN
+ -- Create default partition.
+ IF (rec.by_range)
+ THEN
+ -- Range partition
+ EXECUTE FORMAT(
+ 'CREATE TABLE auditor.%s_default'
+ ' PARTITION OF %s'
+ ' DEFAULT'
+ ,rec.name
+ ,rec.name
+ );
+ ELSE
+ -- Hash partition
+ EXECUTE FORMAT(
+ 'CREATE TABLE auditor.%s_default'
+ ' PARTITION OF %s'
+ ' FOR VALUES WITH (MODULUS 1, REMAINDER 0)'
+ ,rec.name
+ ,rec.name
+ );
+ END IF;
+ ELSE
+ FOR i IN 1..num_partitions LOOP
+ -- Create num_partitions
+ EXECUTE FORMAT(
+ 'CREATE TABLE auditor.%I'
+ ' PARTITION OF %I'
+ ' FOR VALUES WITH (MODULUS %s, REMAINDER %s)'
+ ,rec.name || '_' || i
+ ,rec.name
+ ,num_partitions
+ ,i-1
+ );
+ END LOOP;
+ END IF;
+ ELSE
+ -- Only create master table. No partitions.
+ EXECUTE FORMAT(
+ 'SELECT auditor.%s_table_%s ()'::text
+ ,rec.action
+ ,rec.name
+ );
+ END IF;
+ -- Constrain action apply to master OR each partition
+ WHEN 'constrain'
+ THEN
+ ASSERT rec.partitioned, 'constrain action only applies to partitioned tables';
+ IF (num_partitions IS NULL)
+ THEN
+ -- Constrain master table
+ EXECUTE FORMAT(
+ 'SELECT auditor.%s_table_%s (NULL)'::text
+ ,rec.action
+ ,rec.name
+ );
+ ELSE
+ IF ( (num_partitions = 0) OR
+ (rec.by_range) )
+ THEN
+ -- Constrain default table
+ EXECUTE FORMAT(
+ 'SELECT auditor.%s_table_%s (%s)'::text
+ ,rec.action
+ ,rec.name
+ ,quote_literal('default')
+ );
+ ELSE
+ -- Constrain each partition
+ FOR i IN 1..num_partitions LOOP
+ EXECUTE FORMAT(
+ 'SELECT auditor.%s_table_%s (%s)'::text
+ ,rec.action
+ ,rec.name
+ ,quote_literal(i)
+ );
+ END LOOP;
+ END IF;
+ END IF;
+ -- Foreign actions only apply if partitioning is off
+ WHEN 'foreign'
+ THEN
+ IF (num_partitions IS NULL)
+ THEN
+ -- Add foreign constraints
+ EXECUTE FORMAT(
+ 'SELECT auditor.%s_table_%s (%s)'::text
+ ,rec.action
+ ,rec.name
+ ,NULL
+ );
+ END IF;
+ WHEN 'master'
+ THEN
+ EXECUTE FORMAT(
+ 'SELECT auditor.%s_table_%s ()'::text
+ ,rec.action
+ ,rec.name
+ );
+ ELSE
+ ASSERT FALSE, 'unsupported action type: ' || rec.action;
+ END CASE; -- END CASE (rec.action)
+ -- Mark as finished
+ UPDATE auditor.auditor_tables
+ SET finished=TRUE
+ WHERE table_serial_id=rec.table_serial_id;
+ END LOOP; -- create/alter/drop actions
+END $$;
+
+COMMENT ON FUNCTION do_create_tables
+ IS 'Creates all tables for the given number of partitions that need creating. Does NOT support sharding.';
-CREATE INDEX IF NOT EXISTS auditor_purses_by_purse_pub
- ON auditor_purses
- (purse_pub);
-
-
-CREATE TABLE IF NOT EXISTS auditor_purse_summary
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,balance taler_amount NOT NULL
- ,open_purses INT8 NOT NULL
- );
-COMMENT ON TABLE auditor_purse_summary
- IS 'sum of the balances in open purses';
-
-CREATE TABLE IF NOT EXISTS auditor_reserve_balance
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,reserve_balance taler_amount NOT NULL
- ,reserve_loss taler_amount NOT NULL
- ,withdraw_fee_balance taler_amount NOT NULL
- ,close_fee_balance taler_amount NOT NULL
- ,purse_fee_balance taler_amount NOT NULL
- ,open_fee_balance taler_amount NOT NULL
- ,history_fee_balance taler_amount NOT NULL
- );
-COMMENT ON TABLE auditor_reserve_balance
- IS 'sum of the balances of all customer reserves (by exchange master public key)';
-
-
-CREATE TABLE IF NOT EXISTS auditor_wire_fee_balance
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,wire_fee_balance taler_amount NOT NULL
- );
-COMMENT ON TABLE auditor_wire_fee_balance
- IS 'sum of the balances of all wire fees (by exchange master public key)';
-
-
-CREATE TABLE IF NOT EXISTS auditor_denomination_pending
- (denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)
- ,denom_balance taler_amount NOT NULL
- ,denom_loss taler_amount NOT NULL
- ,num_issued INT8 NOT NULL
- ,denom_risk taler_amount NOT NULL
- ,recoup_loss taler_amount NOT NULL
- );
-COMMENT ON TABLE auditor_denomination_pending
- IS 'outstanding denomination coins that the exchange is aware of and what the respective balances are (outstanding as well as issued overall which implies the maximum value at risk).';
-COMMENT ON COLUMN auditor_denomination_pending.num_issued
- IS 'counts the number of coins issued (withdraw, refresh) of this denomination';
-COMMENT ON COLUMN auditor_denomination_pending.denom_risk
- IS 'amount that could theoretically be lost in the future due to recoup operations';
-COMMENT ON COLUMN auditor_denomination_pending.denom_loss
- IS 'amount that was lost due to failures by the exchange';
-COMMENT ON COLUMN auditor_denomination_pending.recoup_loss
- IS 'amount actually lost due to recoup operations after a revocation';
-
-
-CREATE TABLE IF NOT EXISTS auditor_balance_summary
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,denom_balance taler_amount NOT NULL
- ,deposit_fee_balance taler_amount NOT NULL
- ,melt_fee_balance taler_amount NOT NULL
- ,refund_fee_balance taler_amount NOT NULL
- ,purse_fee_balance taler_amount NOT NULL
- ,open_deposit_fee_balance taler_amount NOT NULL
- ,risk taler_amount NOT NULL
- ,loss taler_amount NOT NULL
- ,irregular_loss taler_amount NOT NULL
- );
-COMMENT ON TABLE auditor_balance_summary
- IS 'the sum of the outstanding coins from auditor_denomination_pending (denom_pubs must belong to the respectives exchange master public key); it represents the auditor_balance_summary of the exchange at this point (modulo unexpected historic_loss-style events where denomination keys are compromised)';
-COMMENT ON COLUMN auditor_balance_summary.denom_balance
- IS 'total amount we should have in escrow for all denominations';
-
-
-CREATE TABLE IF NOT EXISTS auditor_historic_denomination_revenue
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)
- ,revenue_timestamp INT8 NOT NULL
- ,revenue_balance taler_amount NOT NULL
- ,loss_balance taler_amount NOT NULL
- );
-COMMENT ON TABLE auditor_historic_denomination_revenue
- IS 'Table with historic profits; basically, when a denom_pub has expired and everything associated with it is garbage collected, the final profits end up in here; note that the denom_pub here is not a foreign key, we just keep it as a reference point.';
-COMMENT ON COLUMN auditor_historic_denomination_revenue.revenue_balance
- IS 'the sum of all of the profits we made on the coin except for withdraw fees (which are in historic_reserve_revenue); so this includes the deposit, melt and refund fees';
-
-
-CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,start_date INT8 NOT NULL
- ,end_date INT8 NOT NULL
- ,reserve_profits taler_amount NOT NULL
- );
-COMMENT ON TABLE auditor_historic_reserve_summary
- IS 'historic profits from reserves; we eventually GC auditor_historic_reserve_revenue, and then store the totals in here (by time intervals).';
-
-CREATE INDEX IF NOT EXISTS auditor_historic_reserve_summary_by_master_pub_start_date
- ON auditor_historic_reserve_summary
- (master_pub
- ,start_date);
-
-
-CREATE TABLE IF NOT EXISTS deposit_confirmations
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
- ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)
- ,h_policy BYTEA NOT NULL CHECK (LENGTH(h_policy)=64)
- ,h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)
- ,exchange_timestamp INT8 NOT NULL
- ,refund_deadline INT8 NOT NULL
- ,wire_deadline INT8 NOT NULL
- ,total_without_fee taler_amount NOT NULL
- ,coin_pubs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_pubs)>0)
- ,coin_sigs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_sigs)=CARDINALITY(coin_pubs))
- ,merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)
- ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64)
- ,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)
- ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
- ,suppressed BOOLEAN NOT NULL DEFAULT FALSE
- ,ancient BOOLEAN NOT NULL DEFAULT FALSE
- ,PRIMARY KEY (h_contract_terms,h_wire,merchant_pub,exchange_sig,exchange_pub,master_sig)
- );
-COMMENT ON TABLE deposit_confirmations
- IS 'deposit confirmation sent to us by merchants; we must check that the exchange reported these properly.';
-
-CREATE INDEX IF NOT EXISTS auditor_deposit_confirmations_not_ancient
- ON deposit_confirmations
- (exchange_timestamp ASC)
- WHERE NOT ancient;
-
-
-CREATE TABLE IF NOT EXISTS auditor_predicted_result
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,balance taler_amount NOT NULL
- ,drained taler_amount NOT NULL
- );
-COMMENT ON TABLE auditor_predicted_result
- IS 'Table with the sum of the ledger, auditor_historic_revenue and the auditor_reserve_balance and the drained profits. This is the final amount that the exchange should have in its bank account right now (and the total amount drained as profits to non-escrow accounts).';
-
-
-CREATE TABLE IF NOT EXISTS auditor_pending_deposits
- (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,total_amount taler_amount NOT NULL
- ,wire_target_h_payto BYTEA CHECK (LENGTH(wire_target_h_payto)=32)
- ,batch_deposit_serial_id INT8 NOT NULL
- ,deadline INT8 NOT NULL
- ,PRIMARY KEY(master_pub, batch_deposit_serial_id)
- );
-COMMENT ON TABLE auditor_pending_deposits
- IS 'Table with the sum of the (batch) deposits we have seen but not yet checked that they have been aggregated and wired for a particular target bank account';
-COMMENT ON COLUMN auditor_pending_deposits.total_amount
- IS 'Amount we expect to be wired in total for the batch. Includes deposit fees, not the actual expected net wire transfer amount.';
-COMMENT ON COLUMN auditor_pending_deposits.wire_target_h_payto
- IS 'Hash of the payto URI of the bank account to be credited by the deadline';
-COMMENT ON COLUMN auditor_pending_deposits.batch_deposit_serial_id
- IS 'Entry in the batch_deposits table of the exchange this entry is for';
-COMMENT ON COLUMN auditor_pending_deposits.deadline
- IS 'Deadline by which funds should be wired (may be in the future)';
-CREATE INDEX IF NOT EXISTS auditor_pending_deposits_by_deadline
- ON auditor_pending_deposits
- (master_pub
- ,deadline ASC);
--- Finally, commit everything
COMMIT;
diff --git a/src/auditordb/auditor_do_get_auditor_progress.sql b/src/auditordb/auditor_do_get_auditor_progress.sql
new file mode 100644
index 000000000..9371cf67b
--- /dev/null
+++ b/src/auditordb/auditor_do_get_auditor_progress.sql
@@ -0,0 +1,38 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2024 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+-- @author Christian Grothoff
+
+CREATE OR REPLACE FUNCTION auditor_do_get_auditor_progress(
+ IN in_keys TEXT[])
+RETURNS INT8
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ my_key TEXT;
+ my_off INT8;
+BEGIN
+ FOREACH my_key IN ARRAY in_keys
+ LOOP
+ SELECT progress_offset
+ INTO my_off
+ FROM auditor_progress
+ WHERE progress_key=my_key;
+ RETURN my_off;
+ END LOOP;
+END $$;
+
+COMMENT ON FUNCTION auditor_do_get_auditor_progress(TEXT[])
+ IS 'Finds all progress offsets associated with the array of keys given as the argument and returns them in order';
diff --git a/src/auditordb/auditor_do_get_balance.sql b/src/auditordb/auditor_do_get_balance.sql
new file mode 100644
index 000000000..782a31f89
--- /dev/null
+++ b/src/auditordb/auditor_do_get_balance.sql
@@ -0,0 +1,47 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2024 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+-- @author Christian Grothoff
+
+CREATE OR REPLACE FUNCTION auditor_do_get_balance(
+ IN in_keys TEXT[])
+RETURNS taler_amount
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ my_key TEXT;
+ my_rec RECORD;
+ my_val taler_amount;
+BEGIN
+ FOREACH my_key IN ARRAY in_keys
+ LOOP
+ SELECT (ab.balance_value).val
+ ,(ab.balance_value).frac
+ INTO my_rec
+ FROM auditor_balances ab
+ WHERE balance_key=my_key;
+ IF FOUND
+ THEN
+ my_val.val = my_rec.val;
+ my_val.frac = my_rec.frac;
+ RETURN my_val;
+ ELSE
+ RETURN NULL;
+ END IF;
+ END LOOP;
+END $$;
+
+COMMENT ON FUNCTION auditor_do_get_balance(TEXT[])
+ IS 'Finds all balances associated with the array of keys given as the argument and returns them in order';
diff --git a/src/auditordb/pg_delete_exchange.c b/src/auditordb/pg_del_denomination_balance.c
index 9415335c2..154dc50bb 100644
--- a/src/auditordb/pg_delete_exchange.c
+++ b/src/auditordb/pg_del_denomination_balance.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -14,34 +14,34 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file pg_delete_exchange.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
+ * @file auditordb/pg_del_denomination_balance.c
+ * @brief Implementation of the del_denomination_balance function for Postgres
* @author Christian Grothoff
*/
#include "platform.h"
#include "taler_error_codes.h"
#include "taler_dbevents.h"
#include "taler_pq_lib.h"
-#include "pg_delete_exchange.h"
+#include "pg_del_denomination_balance.h"
#include "pg_helper.h"
-
enum GNUNET_DB_QueryStatus
-TAH_PG_delete_exchange (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub)
+TAH_PG_del_denomination_balance (
+ void *cls,
+ const struct TALER_DenominationHashP *denom_pub_hash)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
+ GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
- "auditor_delete_exchange",
+ "auditor_del_denomination_balance",
"DELETE"
- " FROM auditor_exchanges"
- " WHERE master_pub=$1;");
+ " FROM auditor_denomination_pending"
+ " WHERE denom_pub_hash=$1");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_delete_exchange",
+ "auditor_del_denomination_balance",
params);
}
diff --git a/src/auditordb/pg_get_balance_summary.h b/src/auditordb/pg_del_denomination_balance.h
index 1fc31109f..56e9232b0 100644
--- a/src/auditordb/pg_get_balance_summary.h
+++ b/src/auditordb/pg_del_denomination_balance.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -14,30 +14,27 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file pg_get_balance_summary.h
- * @brief implementation of the get_balance_summary function
+ * @file auditordb/pg_del_denomination_balance.h
+ * @brief implementation of the del_denomination_balance function for Postgres
* @author Christian Grothoff
*/
-#ifndef PG_GET_BALANCE_SUMMARY_H
-#define PG_GET_BALANCE_SUMMARY_H
+#ifndef PG_DEL_DENOMINATION_BALANCE_H
+#define PG_DEL_DENOMINATION_BALANCE_H
#include "taler_util.h"
#include "taler_json_lib.h"
#include "taler_auditordb_plugin.h"
-
/**
- * Get information about an exchange's denomination balances.
+ * Delete information about a denomination key's balances.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param[out] dfb where to return the denomination balances
+ * @param denom_pub_hash hash of the denomination public key
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
-TAH_PG_get_balance_summary (
+TAH_PG_del_denomination_balance (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_GlobalCoinBalance *dfb);
+ const struct TALER_DenominationHashP *denom_pub_hash);
#endif
diff --git a/src/auditordb/pg_del_reserve_info.c b/src/auditordb/pg_del_reserve_info.c
index 81db98df9..619bd0afa 100644
--- a/src/auditordb/pg_del_reserve_info.c
+++ b/src/auditordb/pg_del_reserve_info.c
@@ -28,23 +28,20 @@
enum GNUNET_DB_QueryStatus
TAH_PG_del_reserve_info (void *cls,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub)
+ const struct TALER_ReservePublicKeyP *reserve_pub)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
- "auditor_reserves_delete",
+ "auditor_del_reserve_info",
"DELETE"
" FROM auditor_reserves"
- " WHERE reserve_pub=$1"
- " AND master_pub=$2;");
+ " WHERE reserve_pub=$1");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_reserves_delete",
+ "auditor_del_reserve_info",
params);
}
diff --git a/src/auditordb/pg_del_reserve_info.h b/src/auditordb/pg_del_reserve_info.h
index 1bed879d9..88a10bcfd 100644
--- a/src/auditordb/pg_del_reserve_info.h
+++ b/src/auditordb/pg_del_reserve_info.h
@@ -31,13 +31,11 @@
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param reserve_pub public key of the reserve
- * @param master_pub master public key of the exchange
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
TAH_PG_del_reserve_info (void *cls,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub);
+ const struct TALER_ReservePublicKeyP *reserve_pub);
#endif
diff --git a/src/auditordb/pg_delete_deposit_confirmations.c b/src/auditordb/pg_delete_deposit_confirmations.c
index 553e97121..6cb76d4e9 100644
--- a/src/auditordb/pg_delete_deposit_confirmations.c
+++ b/src/auditordb/pg_delete_deposit_confirmations.c
@@ -26,37 +26,22 @@
#include "pg_helper.h"
enum GNUNET_DB_QueryStatus
-TAH_PG_delete_deposit_confirmations (
+TAH_PG_delete_deposit_confirmation (
void *cls,
- const struct TALER_PrivateContractHashP *h_contract_terms,
- const struct TALER_MerchantWireHashP *h_wire,
- const struct TALER_MerchantPublicKeyP *merchant_pub,
- const struct TALER_ExchangeSignatureP *exchange_sig,
- const struct TALER_ExchangePublicKeyP *exchange_pub,
- const struct TALER_MasterSignatureP *master_sig)
+ uint64_t row_id)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
- GNUNET_PQ_query_param_auto_from_type (h_wire),
- GNUNET_PQ_query_param_auto_from_type (merchant_pub),
- GNUNET_PQ_query_param_auto_from_type (exchange_sig),
- GNUNET_PQ_query_param_auto_from_type (exchange_pub),
- GNUNET_PQ_query_param_auto_from_type (master_sig),
+ GNUNET_PQ_query_param_uint64 (&row_id),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
- "auditor_delete_deposit_confirmations",
+ "auditor_delete_deposit_confirmation",
"DELETE"
" FROM deposit_confirmations"
- " WHERE h_contract_terms=$1"
- " AND h_wire=$2"
- " AND merchant_pub=$3"
- " AND exchange_sig=$4"
- " AND exchange_pub=$5"
- " AND master_sig=$6;");
+ " WHERE deposit_confirmation_serial_id=$1;");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_delete_deposit_confirmations",
+ "auditor_delete_deposit_confirmation",
params);
}
diff --git a/src/auditordb/pg_delete_deposit_confirmations.h b/src/auditordb/pg_delete_deposit_confirmations.h
index f0339fd3d..5f7700ba1 100644
--- a/src/auditordb/pg_delete_deposit_confirmations.h
+++ b/src/auditordb/pg_delete_deposit_confirmations.h
@@ -15,7 +15,7 @@
*/
/**
* @file auditordb/pg_delete_deposit_confirmations.h
- * @brief implementation of the delete_deposit_confirmations function for Postgres
+ * @brief implementation of the delete_deposit_confirmation function for Postgres
* @author Nicola Eigel
*/
#ifndef PG_DELETE_DEPOSIT_CONFIRMATIONS_H
@@ -29,23 +29,13 @@
* Delete a row from the deposit confirmations table.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param h_contract_terms private contract hash
- * @param h_wire merchant wire hash
- * @param merchant_pub master key of the merchant
- * @param exchange_sig signature of the exchange
- * @param exchange_pub master key of the exchange
- * @param master_sig master signature of the exchange
- * @return
+ * @param row_id row to delete
+ * @return query transaction status
*/
enum GNUNET_DB_QueryStatus
-TAH_PG_delete_deposit_confirmations (
+TAH_PG_delete_deposit_confirmation (
void *cls,
- const struct TALER_PrivateContractHashP *h_contract_terms,
- const struct TALER_MerchantWireHashP *h_wire,
- const struct TALER_MerchantPublicKeyP *merchant_pub,
- const struct TALER_ExchangeSignatureP *exchange_sig,
- const struct TALER_ExchangePublicKeyP *exchange_pub,
- const struct TALER_MasterSignatureP *master_sig);
+ uint64_t row_id);
#endif
diff --git a/src/auditordb/pg_delete_exchange.h b/src/auditordb/pg_delete_exchange.h
deleted file mode 100644
index 4b639a62b..000000000
--- a/src/auditordb/pg_delete_exchange.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_delete_exchange.h
- * @brief implementation of the delete_exchange function
- * @author Christian Grothoff
- */
-#ifndef PG_DELETE_EXCHANGE_H
-#define PG_DELETE_EXCHANGE_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Delete an exchange from the list of exchanges this auditor is auditing.
- * Warning: this will cascade and delete all knowledge of this auditor related
- * to this exchange!
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @return query result status
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_delete_exchange (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub);
-
-
-#endif
diff --git a/src/auditordb/pg_delete_pending_deposit.c b/src/auditordb/pg_delete_pending_deposit.c
index 3dfd467c5..29814e84b 100644
--- a/src/auditordb/pg_delete_pending_deposit.c
+++ b/src/auditordb/pg_delete_pending_deposit.c
@@ -29,12 +29,10 @@
enum GNUNET_DB_QueryStatus
TAH_PG_delete_pending_deposit (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
uint64_t batch_deposit_serial_id)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_uint64 (&batch_deposit_serial_id),
GNUNET_PQ_query_param_end
};
@@ -43,8 +41,7 @@ TAH_PG_delete_pending_deposit (
"auditor_delete_pending_deposit",
"DELETE"
" FROM auditor_pending_deposits"
- " WHERE master_pub=$1"
- " AND batch_deposit_serial_id=$2;");
+ " WHERE batch_deposit_serial_id=$1;");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_delete_pending_deposit",
params);
diff --git a/src/auditordb/pg_delete_pending_deposit.h b/src/auditordb/pg_delete_pending_deposit.h
index fb39ef199..8e7159eac 100644
--- a/src/auditordb/pg_delete_pending_deposit.h
+++ b/src/auditordb/pg_delete_pending_deposit.h
@@ -32,14 +32,12 @@
* was finally detected.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
* @param batch_deposit_serial_id which entry to delete
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
TAH_PG_delete_pending_deposit (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
uint64_t batch_deposit_serial_id);
diff --git a/src/auditordb/pg_delete_purse_info.c b/src/auditordb/pg_delete_purse_info.c
index cd390d0ca..8fa77ba46 100644
--- a/src/auditordb/pg_delete_purse_info.c
+++ b/src/auditordb/pg_delete_purse_info.c
@@ -29,21 +29,18 @@
enum GNUNET_DB_QueryStatus
TAH_PG_delete_purse_info (
void *cls,
- const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub)
+ const struct TALER_PurseContractPublicKeyP *purse_pub)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (purse_pub),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
"auditor_purses_delete",
"DELETE FROM auditor_purses "
- " WHERE purse_pub=$1"
- " AND master_pub=$2;");
+ " WHERE purse_pub=$1");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_purses_delete",
params);
diff --git a/src/auditordb/pg_delete_purse_info.h b/src/auditordb/pg_delete_purse_info.h
index 88b59fde2..88393f9b8 100644
--- a/src/auditordb/pg_delete_purse_info.h
+++ b/src/auditordb/pg_delete_purse_info.h
@@ -31,14 +31,12 @@
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param purse_pub public key of the reserve
- * @param master_pub master public key of the exchange
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
TAH_PG_delete_purse_info (
void *cls,
- const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub);
+ const struct TALER_PurseContractPublicKeyP *purse_pub);
#endif
diff --git a/src/auditordb/pg_get_auditor_progress.c b/src/auditordb/pg_get_auditor_progress.c
new file mode 100644
index 000000000..3742d2eb6
--- /dev/null
+++ b/src/auditordb/pg_get_auditor_progress.c
@@ -0,0 +1,178 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file pg_get_auditor_progress.c
+ * @brief Implementation of get_auditor_progress function
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_get_auditor_progress.h"
+#include "pg_helper.h"
+
+
+/**
+ * Closure for #auditor_progress_cb().
+ */
+struct AuditorProgressContext
+{
+
+ /**
+ * Where to store results.
+ */
+ uint64_t **dst;
+
+ /**
+ * Offset in @e dst.
+ */
+ unsigned int off;
+
+ /**
+ * Length of array at @e dst.
+ */
+ unsigned int len;
+
+ /**
+ * Plugin context.
+ */
+ struct PostgresClosure *pg;
+
+ /**
+ * Set to true on failure.
+ */
+ bool failure;
+};
+
+
+/**
+ * Helper function for #TAH_PG_get_auditor_progress().
+ * To be called with the results of a SELECT statement
+ * that has returned @a num_results results.
+ *
+ * @param cls closure of type `struct AuditorProgressContext *`
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+auditor_progress_cb (void *cls,
+ PGresult *result,
+ unsigned int num_results)
+{
+ struct AuditorProgressContext *ctx = cls;
+
+ GNUNET_assert (num_results <= ctx->len);
+ for (unsigned int i = 0; i < num_results; i++)
+ {
+ bool is_missing = false;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_uint64 ("progress_offset",
+ ctx->dst[i]),
+ &is_missing),
+ GNUNET_PQ_result_spec_end
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ i))
+ {
+ GNUNET_break (0);
+ ctx->failure = true;
+ return;
+ }
+ if (is_missing)
+ *ctx->dst[i] = 0;
+ ctx->off++;
+ }
+}
+
+
+enum GNUNET_DB_QueryStatus
+TAH_PG_get_auditor_progress (void *cls,
+ const char *progress_key,
+ uint64_t *progress_offset,
+ ...)
+{
+ struct PostgresClosure *pg = cls;
+ unsigned int cnt = 1;
+ va_list ap;
+
+ va_start (ap,
+ progress_offset);
+ while (NULL != va_arg (ap,
+ const char *))
+ {
+ cnt++;
+ (void) va_arg (ap,
+ uint64_t *);
+ }
+ va_end (ap);
+ {
+ const char *keys[cnt];
+ uint64_t *dsts[cnt];
+ unsigned int off = 1;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_array_ptrs_string (cnt,
+ keys,
+ pg->conn),
+ GNUNET_PQ_query_param_end
+ };
+ struct AuditorProgressContext ctx = {
+ .dst = dsts,
+ .len = cnt,
+ .pg = pg
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ keys[0] = progress_key;
+ dsts[0] = progress_offset;
+
+ va_start (ap,
+ progress_offset);
+ while (off < cnt)
+ {
+ keys[off] = va_arg (ap,
+ const char *);
+ dsts[off] = va_arg (ap,
+ uint64_t *);
+ off++;
+ }
+ GNUNET_assert (NULL == va_arg (ap,
+ const char *));
+ va_end (ap);
+
+ PREPARE (pg,
+ "get_auditor_progress",
+ "SELECT"
+ " auditor_do_get_auditor_progress AS progress_offset"
+ " FROM auditor_do_get_auditor_progress "
+ "($1);");
+ qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
+ "get_auditor_progress",
+ params,
+ &auditor_progress_cb,
+ &ctx);
+ GNUNET_PQ_cleanup_query_params_closures (params);
+ if (ctx.failure)
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ if (qs < 0)
+ return qs;
+ return qs;
+ }
+}
diff --git a/src/auditordb/pg_get_auditor_progress_deposit_confirmation.h b/src/auditordb/pg_get_auditor_progress.h
index 3b558d0c6..fee7a4424 100644
--- a/src/auditordb/pg_get_auditor_progress_deposit_confirmation.h
+++ b/src/auditordb/pg_get_auditor_progress.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -14,12 +14,12 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file pg_get_auditor_progress_deposit_confirmation.h
- * @brief implementation of the get_auditor_progress_deposit_confirmation function
+ * @file pg_get_auditor_progress.h
+ * @brief implementation of the get_auditor_progress function
* @author Christian Grothoff
*/
-#ifndef PG_GET_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
-#define PG_GET_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
+#ifndef PG_GET_AUDITOR_PROGRESS_H
+#define PG_GET_AUDITOR_PROGRESS_H
#include "taler_util.h"
#include "taler_json_lib.h"
@@ -30,14 +30,15 @@
* Get information about the progress of the auditor.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param[out] ppdc set to where the auditor is in processing
+ * @param progress_key name of the progress indicator
+ * @param[out] progress_offset set to offset until which we have made progress
+ * @param ... NULL terminated list of additional key-value pairs to fetch
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_deposit_confirmation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc);
+TAH_PG_get_auditor_progress (void *cls,
+ const char *progress_key,
+ uint64_t *progress_offset,
+ ...);
#endif
diff --git a/src/auditordb/pg_get_auditor_progress_aggregation.c b/src/auditordb/pg_get_auditor_progress_aggregation.c
deleted file mode 100644
index a9f89d07a..000000000
--- a/src/auditordb/pg_get_auditor_progress_aggregation.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_auditor_progress_aggregation.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_auditor_progress_aggregation.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_aggregation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointAggregation *ppa)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("last_wire_out_serial_id",
- &ppa->last_wire_out_serial_id),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "auditor_progress_select_aggregation",
- "SELECT"
- " last_wire_out_serial_id"
- " FROM auditor_progress_aggregation"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_progress_select_aggregation",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_auditor_progress_aggregation.h b/src/auditordb/pg_get_auditor_progress_aggregation.h
deleted file mode 100644
index b20a00adf..000000000
--- a/src/auditordb/pg_get_auditor_progress_aggregation.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_auditor_progress_aggregation.h
- * @brief implementation of the get_auditor_progress_aggregation function
- * @author Christian Grothoff
- */
-#ifndef PG_GET_AUDITOR_PROGRESS_AGGREGATION_H
-#define PG_GET_AUDITOR_PROGRESS_AGGREGATION_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Get information about the progress of the auditor.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param[out] ppa set to where the auditor is in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_aggregation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
-
-#endif
diff --git a/src/auditordb/pg_get_auditor_progress_coin.c b/src/auditordb/pg_get_auditor_progress_coin.c
deleted file mode 100644
index a160f1ccc..000000000
--- a/src/auditordb/pg_get_auditor_progress_coin.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_auditor_progress_coin.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_auditor_progress_coin.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_coin (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointCoin *ppc)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("last_withdraw_serial_id",
- &ppc->last_withdraw_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_deposit_serial_id",
- &ppc->last_deposit_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_melt_serial_id",
- &ppc->last_melt_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_refund_serial_id",
- &ppc->last_refund_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_recoup_serial_id",
- &ppc->last_recoup_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_recoup_refresh_serial_id",
- &ppc->last_recoup_refresh_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_purse_deposits_serial_id",
- &ppc->last_purse_deposits_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_purse_decision_serial_id",
- &ppc->last_purse_refunds_serial_id),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "auditor_progress_select_coin",
- "SELECT"
- " last_withdraw_serial_id"
- ",last_deposit_serial_id"
- ",last_melt_serial_id"
- ",last_refund_serial_id"
- ",last_recoup_serial_id"
- ",last_recoup_refresh_serial_id"
- ",last_purse_deposits_serial_id"
- ",last_purse_decision_serial_id"
- " FROM auditor_progress_coin"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_progress_select_coin",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_auditor_progress_coin.h b/src/auditordb/pg_get_auditor_progress_coin.h
deleted file mode 100644
index 46f997b36..000000000
--- a/src/auditordb/pg_get_auditor_progress_coin.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_auditor_progress_coin.h
- * @brief implementation of the get_auditor_progress_coin function
- * @author Christian Grothoff
- */
-#ifndef PG_GET_AUDITOR_PROGRESS_COIN_H
-#define PG_GET_AUDITOR_PROGRESS_COIN_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Get information about the progress of the auditor.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param[out] ppc set to where the auditor is in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_coin (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointCoin *ppc);
-
-#endif
diff --git a/src/auditordb/pg_get_auditor_progress_deposit_confirmation.c b/src/auditordb/pg_get_auditor_progress_deposit_confirmation.c
deleted file mode 100644
index 7a14b4600..000000000
--- a/src/auditordb/pg_get_auditor_progress_deposit_confirmation.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_auditor_progress_deposit_confirmation.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_auditor_progress_deposit_confirmation.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_deposit_confirmation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("last_deposit_confirmation_serial_id",
- &ppdc->last_deposit_confirmation_serial_id),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "auditor_progress_select_deposit_confirmation",
- "SELECT"
- " last_deposit_confirmation_serial_id"
- " FROM auditor_progress_deposit_confirmation;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_progress_select_deposit_confirmation",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_auditor_progress_purse.c b/src/auditordb/pg_get_auditor_progress_purse.c
deleted file mode 100644
index de8628ce7..000000000
--- a/src/auditordb/pg_get_auditor_progress_purse.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_auditor_progress_purse.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_auditor_progress_purse.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_purse (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointPurse *ppp)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("last_purse_request_serial_id",
- &ppp->last_purse_request_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_purse_decision_serial_id",
- &ppp->last_purse_decision_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_purse_merges_serial_id",
- &ppp->last_purse_merge_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_account_merges_serial_id",
- &ppp->last_account_merge_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_purse_deposits_serial_id",
- &ppp->last_purse_deposits_serial_id),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "auditor_progress_select_purse",
- "SELECT"
- " last_purse_request_serial_id"
- ",last_purse_decision_serial_id"
- ",last_purse_merges_serial_id"
- ",last_account_merges_serial_id"
- ",last_purse_deposits_serial_id"
- " FROM auditor_progress_purse"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_progress_select_purse",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_auditor_progress_reserve.c b/src/auditordb/pg_get_auditor_progress_reserve.c
deleted file mode 100644
index 90923a0f7..000000000
--- a/src/auditordb/pg_get_auditor_progress_reserve.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_auditor_progress_reserve.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_auditor_progress_reserve.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_reserve (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointReserve *ppr)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("last_reserve_in_serial_id",
- &ppr->last_reserve_in_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_reserve_out_serial_id",
- &ppr->last_reserve_out_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_reserve_recoup_serial_id",
- &ppr->last_reserve_recoup_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_reserve_open_serial_id",
- &ppr->last_reserve_open_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_reserve_close_serial_id",
- &ppr->last_reserve_close_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_purse_decision_serial_id",
- &ppr->last_purse_decisions_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_account_merges_serial_id",
- &ppr->last_account_merges_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_history_requests_serial_id",
- &ppr->last_history_requests_serial_id),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "auditor_progress_select_reserve",
- "SELECT"
- " last_reserve_in_serial_id"
- ",last_reserve_out_serial_id"
- ",last_reserve_recoup_serial_id"
- ",last_reserve_close_serial_id"
- ",last_purse_decision_serial_id"
- ",last_account_merges_serial_id"
- ",last_history_requests_serial_id"
- ",last_reserve_open_serial_id"
- " FROM auditor_progress_reserve"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_progress_select_reserve",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_auditor_progress_reserve.h b/src/auditordb/pg_get_auditor_progress_reserve.h
deleted file mode 100644
index 6b9cfabed..000000000
--- a/src/auditordb/pg_get_auditor_progress_reserve.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_auditor_progress_reserve.h
- * @brief implementation of the get_auditor_progress_reserve function
- * @author Christian Grothoff
- */
-#ifndef PG_GET_AUDITOR_PROGRESS_RESERVE_H
-#define PG_GET_AUDITOR_PROGRESS_RESERVE_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Get information about the progress of the auditor.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param[out] ppr set to where the auditor is in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_reserve (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointReserve *ppr);
-
-#endif
diff --git a/src/auditordb/pg_get_balance.c b/src/auditordb/pg_get_balance.c
new file mode 100644
index 000000000..4edc1c89f
--- /dev/null
+++ b/src/auditordb/pg_get_balance.c
@@ -0,0 +1,183 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file auditordb/pg_get_balance.c
+ * @brief Implementation of the get_balance function for Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_get_balance.h"
+#include "pg_helper.h"
+
+
+/**
+ * Closure for #balance_cb().
+ */
+struct BalanceContext
+{
+
+ /**
+ * Where to store results.
+ */
+ struct TALER_Amount **dst;
+
+ /**
+ * Offset in @e dst.
+ */
+ unsigned int off;
+
+ /**
+ * Length of array at @e dst.
+ */
+ unsigned int len;
+
+ /**
+ * Plugin context.
+ */
+ struct PostgresClosure *pg;
+
+ /**
+ * Set to true on failure.
+ */
+ bool failure;
+};
+
+
+/**
+ * Helper function for #TAH_PG_get_balance().
+ * To be called with the results of a SELECT statement
+ * that has returned @a num_results results.
+ *
+ * @param cls closure of type `struct BalanceContext *`
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+balance_cb (void *cls,
+ PGresult *result,
+ unsigned int num_results)
+{
+ struct BalanceContext *ctx = cls;
+ struct PostgresClosure *pg = ctx->pg;
+
+ GNUNET_assert (num_results <= ctx->len);
+ for (unsigned int i = 0; i < num_results; i++)
+ {
+ bool is_missing = false;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_allow_null (
+ TALER_PQ_result_spec_amount ("balance",
+ pg->currency,
+ ctx->dst[i]),
+ &is_missing),
+ GNUNET_PQ_result_spec_end
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ i))
+ {
+ GNUNET_break (0);
+ ctx->failure = true;
+ return;
+ }
+ if (is_missing)
+ memset (ctx->dst[i],
+ 0,
+ sizeof (struct TALER_Amount));
+ ctx->off++;
+ }
+}
+
+
+enum GNUNET_DB_QueryStatus
+TAH_PG_get_balance (void *cls,
+ const char *balance_key,
+ struct TALER_Amount *balance_value,
+ ...)
+{
+ struct PostgresClosure *pg = cls;
+ unsigned int cnt = 1;
+ va_list ap;
+
+ va_start (ap,
+ balance_value);
+ while (NULL != va_arg (ap,
+ const char *))
+ {
+ cnt++;
+ (void) va_arg (ap,
+ struct TALER_Amount *);
+ }
+ va_end (ap);
+ {
+ const char *keys[cnt];
+ struct TALER_Amount *dsts[cnt];
+ unsigned int off = 1;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_array_ptrs_string (cnt,
+ keys,
+ pg->conn),
+ GNUNET_PQ_query_param_end
+ };
+ struct BalanceContext ctx = {
+ .dst = dsts,
+ .len = cnt,
+ .pg = pg
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ keys[0] = balance_key;
+ dsts[0] = balance_value;
+
+ va_start (ap,
+ balance_value);
+ while (off < cnt)
+ {
+ keys[off] = va_arg (ap,
+ const char *);
+ dsts[off] = va_arg (ap,
+ struct TALER_Amount *);
+ off++;
+ }
+ GNUNET_assert (NULL == va_arg (ap,
+ const char *));
+ va_end (ap);
+
+ PREPARE (pg,
+ "get_balance",
+ "SELECT "
+ " auditor_do_get_balance AS balance"
+ " FROM auditor_do_get_balance "
+ "($1);");
+ qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
+ "get_balance",
+ params,
+ &balance_cb,
+ &ctx);
+ GNUNET_PQ_cleanup_query_params_closures (params);
+ if (ctx.failure)
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ if (qs < 0)
+ return qs;
+ GNUNET_assert (qs == ctx.off);
+ return qs;
+ }
+}
diff --git a/src/auditordb/pg_get_purse_summary.h b/src/auditordb/pg_get_balance.h
index e3c5d92f7..1cbb2541f 100644
--- a/src/auditordb/pg_get_purse_summary.h
+++ b/src/auditordb/pg_get_balance.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -14,12 +14,12 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file auditordb/pg_get_purse_summary.h
- * @brief implementation of the get_purse_summary function for Postgres
+ * @file auditordb/pg_get_balance.h
+ * @brief implementation of the get_balance function for Postgres
* @author Christian Grothoff
*/
-#ifndef PG_GET_PURSE_SUMMARY_H
-#define PG_GET_PURSE_SUMMARY_H
+#ifndef PG_GET_BALANCE_H
+#define PG_GET_BALANCE_H
#include "taler_util.h"
#include "taler_json_lib.h"
@@ -27,17 +27,18 @@
/**
- * Get summary information about all purses.
+ * Get summary information about balance tracked by the auditor.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @param[out] sum purse balances summary to initialize
+ * @param balance_key key of the blance to store
+ * @param[out] balance_value set to amount stored under @a balance_key
+ * @param ... NULL terminated list of additional key-value pairs to fetch
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
-TAH_PG_get_purse_summary (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_PurseBalance *sum);
-
+TAH_PG_get_balance (void *cls,
+ const char *balance_key,
+ struct TALER_Amount *balance_value,
+ ...);
#endif
diff --git a/src/auditordb/pg_get_balance_summary.c b/src/auditordb/pg_get_balance_summary.c
deleted file mode 100644
index b2706aeb0..000000000
--- a/src/auditordb/pg_get_balance_summary.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_balance_summary.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_balance_summary.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_balance_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_GlobalCoinBalance *dfb)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance",
- &dfb->total_escrowed),
- TALER_PQ_RESULT_SPEC_AMOUNT ("deposit_fee_balance",
- &dfb->deposit_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("melt_fee_balance",
- &dfb->melt_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("refund_fee_balance",
- &dfb->refund_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
- &dfb->purse_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("open_deposit_fee_balance",
- &dfb->open_deposit_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("risk",
- &dfb->risk),
- TALER_PQ_RESULT_SPEC_AMOUNT ("loss",
- &dfb->loss),
- TALER_PQ_RESULT_SPEC_AMOUNT ("irregular_loss",
- &dfb->irregular_loss),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "auditor_balance_summary_select",
- "SELECT"
- " denom_balance"
- ",deposit_fee_balance"
- ",melt_fee_balance"
- ",refund_fee_balance"
- ",purse_fee_balance"
- ",open_deposit_fee_balance"
- ",risk"
- ",loss"
- ",irregular_loss"
- " FROM auditor_balance_summary"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_balance_summary_select",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_deposit_confirmations.c b/src/auditordb/pg_get_deposit_confirmations.c
index ede9b8d77..b8055a296 100644
--- a/src/auditordb/pg_get_deposit_confirmations.c
+++ b/src/auditordb/pg_get_deposit_confirmations.c
@@ -33,11 +33,6 @@ struct DepositConfirmationContext
{
/**
- * Master public key that is being used.
- */
- const struct TALER_MasterPublicKeyP *master_pub;
-
- /**
* Function to call for each deposit confirmation.
*/
TALER_AUDITORDB_DepositConfirmationCallback cb;
@@ -79,9 +74,7 @@ deposit_confirmation_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
uint64_t serial_id;
- struct TALER_AUDITORDB_DepositConfirmation dc = {
- .master_public_key = *dcc->master_pub
- };
+ struct TALER_AUDITORDB_DepositConfirmation dc = { 0};
struct TALER_CoinSpendPublicKeyP *coin_pubs = NULL;
struct TALER_CoinSpendSignatureP *coin_sigs = NULL;
size_t num_pubs = 0;
@@ -157,12 +150,14 @@ enum GNUNET_DB_QueryStatus
TAH_PG_get_deposit_confirmations (
void *cls,
uint64_t start_id,
+ bool return_suppressed,
TALER_AUDITORDB_DepositConfirmationCallback cb,
void *cb_cls)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&start_id),
+ GNUNET_PQ_query_param_bool (return_suppressed),
GNUNET_PQ_query_param_end
};
struct DepositConfirmationContext dcc = {
@@ -171,7 +166,6 @@ TAH_PG_get_deposit_confirmations (
.pg = pg
};
enum GNUNET_DB_QueryStatus qs;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "id above %ld\n", start_id);
PREPARE (pg,
"auditor_deposit_confirmation_select",
@@ -189,9 +183,10 @@ TAH_PG_get_deposit_confirmations (
",merchant_pub"
",exchange_sig"
",exchange_pub"
- ",master_sig" /* master_sig could be normalized... */
- " FROM deposit_confirmations"
- " WHERE deposit_confirmation_serial_id>$1");
+ ",master_sig"
+ " FROM auditor_deposit_confirmations"
+ " WHERE deposit_confirmation_serial_id>$1"
+ " AND ($2 OR NOT suppressed);");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"auditor_deposit_confirmation_select",
params,
diff --git a/src/auditordb/pg_get_deposit_confirmations.h b/src/auditordb/pg_get_deposit_confirmations.h
index 3ed3ff55b..6b33e9e6f 100644
--- a/src/auditordb/pg_get_deposit_confirmations.h
+++ b/src/auditordb/pg_get_deposit_confirmations.h
@@ -32,6 +32,7 @@
* @param cls the @e cls of this struct with the plugin-specific state
* @param start_id row/serial ID where to start the iteration (0 from
* the start, exclusive, i.e. serial_ids must start from 1)
+ * @param return_suppressed should suppressed rows be returned anyway?
* @param cb function to call with results
* @param cb_cls closure for @a cb
* @return query result status
@@ -40,6 +41,7 @@ enum GNUNET_DB_QueryStatus
TAH_PG_get_deposit_confirmations (
void *cls,
uint64_t start_id,
+ bool return_suppressed,
TALER_AUDITORDB_DepositConfirmationCallback cb,
void *cb_cls);
diff --git a/src/auditordb/pg_get_predicted_balance.c b/src/auditordb/pg_get_predicted_balance.c
deleted file mode 100644
index 583a63fd4..000000000
--- a/src/auditordb/pg_get_predicted_balance.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_predicted_balance.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_predicted_balance.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_predicted_balance (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_Amount *balance,
- struct TALER_Amount *drained)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("balance",
- balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("drained",
- drained),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "auditor_predicted_result_select",
- "SELECT"
- " balance"
- ",drained"
- " FROM auditor_predicted_result"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_predicted_result_select",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_predicted_balance.h b/src/auditordb/pg_get_predicted_balance.h
deleted file mode 100644
index 925e6a85b..000000000
--- a/src/auditordb/pg_get_predicted_balance.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_predicted_balance.h
- * @brief implementation of the get_predicted_balance function
- * @author Christian Grothoff
- */
-#ifndef PG_GET_PREDICTED_BALANCE_H
-#define PG_GET_PREDICTED_BALANCE_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Get an exchange's predicted balance.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param[out] balance expected bank account balance of the exchange
- * @param[out] drained amount drained so far
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_predicted_balance (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_Amount *balance,
- struct TALER_Amount *drained);
-
-#endif
diff --git a/src/auditordb/pg_get_purse_info.c b/src/auditordb/pg_get_purse_info.c
index df11bdbc9..6a0faf616 100644
--- a/src/auditordb/pg_get_purse_info.c
+++ b/src/auditordb/pg_get_purse_info.c
@@ -29,7 +29,6 @@ enum GNUNET_DB_QueryStatus
TAH_PG_get_purse_info (
void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
uint64_t *rowid,
struct TALER_Amount *balance,
struct GNUNET_TIME_Timestamp *expiration_date)
@@ -37,7 +36,6 @@ TAH_PG_get_purse_info (
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (purse_pub),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -56,8 +54,7 @@ TAH_PG_get_purse_info (
" expiration_date"
",balance"
" FROM auditor_purses"
- " WHERE purse_pub=$1"
- " AND master_pub=$2;");
+ " WHERE purse_pub=$1");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"auditor_get_purse_info",
params,
diff --git a/src/auditordb/pg_get_purse_info.h b/src/auditordb/pg_get_purse_info.h
index 2b2e77415..e8268282e 100644
--- a/src/auditordb/pg_get_purse_info.h
+++ b/src/auditordb/pg_get_purse_info.h
@@ -31,7 +31,6 @@
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param purse_pub public key of the purse
- * @param master_pub master public key of the exchange
* @param[out] rowid which row did we get the information from
* @param[out] balance set to balance of the purse
* @param[out] expiration_date expiration date of the purse
@@ -41,7 +40,6 @@ enum GNUNET_DB_QueryStatus
TAH_PG_get_purse_info (
void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
uint64_t *rowid,
struct TALER_Amount *balance,
struct GNUNET_TIME_Timestamp *expiration_date);
diff --git a/src/auditordb/pg_get_purse_summary.c b/src/auditordb/pg_get_purse_summary.c
deleted file mode 100644
index cc40a21e1..000000000
--- a/src/auditordb/pg_get_purse_summary.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file auditordb/pg_get_purse_summary.c
- * @brief Implementation of the get_purse_summary function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_purse_summary.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_purse_summary (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_PurseBalance *sum)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("balance",
- &sum->balance),
- GNUNET_PQ_result_spec_uint64 ("open_purses",
- &sum->open_purses),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "auditor_get_purse_summary",
- "SELECT"
- " open_purses"
- ",balance"
- " FROM auditor_purse_summary"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_get_purse_summary",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_reserve_info.c b/src/auditordb/pg_get_reserve_info.c
index 3cfc3a613..f16c6d995 100644
--- a/src/auditordb/pg_get_reserve_info.c
+++ b/src/auditordb/pg_get_reserve_info.c
@@ -29,7 +29,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_get_reserve_info (void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
uint64_t *rowid,
struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
struct GNUNET_TIME_Timestamp *expiration_date,
@@ -38,7 +37,6 @@ TAH_PG_get_reserve_info (void *cls,
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -69,7 +67,7 @@ TAH_PG_get_reserve_info (void *cls,
*sender_account = NULL;
PREPARE (pg,
- "auditor_reserves_select",
+ "auditor_get_reserve_info",
"SELECT"
" reserve_balance"
",reserve_loss"
@@ -82,9 +80,9 @@ TAH_PG_get_reserve_info (void *cls,
",auditor_reserves_rowid"
",origin_account"
" FROM auditor_reserves"
- " WHERE reserve_pub=$1 AND master_pub=$2;");
+ " WHERE reserve_pub=$1;");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_reserves_select",
+ "auditor_get_reserve_info",
params,
rs);
}
diff --git a/src/auditordb/pg_get_reserve_info.h b/src/auditordb/pg_get_reserve_info.h
index a04d23c27..3eba035fc 100644
--- a/src/auditordb/pg_get_reserve_info.h
+++ b/src/auditordb/pg_get_reserve_info.h
@@ -31,7 +31,6 @@
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param reserve_pub public key of the reserve
- * @param master_pub master public key of the exchange
* @param[out] rowid which row did we get the information from
* @param[out] rfb where to store the reserve balance summary
* @param[out] expiration_date expiration date of the reserve
@@ -41,7 +40,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_get_reserve_info (void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
uint64_t *rowid,
struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
struct GNUNET_TIME_Timestamp *expiration_date,
diff --git a/src/auditordb/pg_get_reserve_summary.c b/src/auditordb/pg_get_reserve_summary.c
deleted file mode 100644
index e314afa1a..000000000
--- a/src/auditordb/pg_get_reserve_summary.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_reserve_summary.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_reserve_summary.h"
-#include "pg_helper.h"
-
-
-/**
- * Get summary information about all reserves.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @param[out] rfb balances are returned here
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_reserve_summary (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ReserveFeeBalance *rfb)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance",
- &rfb->reserve_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss",
- &rfb->reserve_loss),
- TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance",
- &rfb->withdraw_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance",
- &rfb->close_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
- &rfb->purse_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance",
- &rfb->open_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee_balance",
- &rfb->history_fee_balance),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "auditor_reserve_balance_select",
- "SELECT"
- " reserve_balance"
- ",reserve_loss"
- ",withdraw_fee_balance"
- ",close_fee_balance"
- ",purse_fee_balance"
- ",open_fee_balance"
- ",history_fee_balance"
- " FROM auditor_reserve_balance"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "auditor_reserve_balance_select",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_reserve_summary.h b/src/auditordb/pg_get_reserve_summary.h
deleted file mode 100644
index d9a3ea5aa..000000000
--- a/src/auditordb/pg_get_reserve_summary.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_reserve_summary.h
- * @brief implementation of the get_reserve_summary function
- * @author Christian Grothoff
- */
-#ifndef PG_GET_RESERVE_SUMMARY_H
-#define PG_GET_RESERVE_SUMMARY_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Get summary information about all reserves.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @param[out] rfb balances are returned here
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_reserve_summary (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
-
-
-#endif
diff --git a/src/auditordb/pg_get_wire_auditor_account_progress.c b/src/auditordb/pg_get_wire_auditor_account_progress.c
deleted file mode 100644
index 147fffa7c..000000000
--- a/src/auditordb/pg_get_wire_auditor_account_progress.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_wire_auditor_account_progress.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_wire_auditor_account_progress.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_wire_auditor_account_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *account_name,
- struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- struct TALER_AUDITORDB_BankAccountProgressPoint *bapp)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_string (account_name),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("last_wire_reserve_in_serial_id",
- &pp->last_reserve_in_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_wire_wire_out_serial_id",
- &pp->last_wire_out_serial_id),
- GNUNET_PQ_result_spec_uint64 ("wire_in_off",
- &bapp->in_wire_off),
- GNUNET_PQ_result_spec_uint64 ("wire_out_off",
- &bapp->out_wire_off),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "wire_auditor_account_progress_select",
- "SELECT"
- " last_wire_reserve_in_serial_id"
- ",last_wire_wire_out_serial_id"
- ",wire_in_off"
- ",wire_out_off"
- " FROM wire_auditor_account_progress"
- " WHERE master_pub=$1 AND account_name=$2;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "wire_auditor_account_progress_select",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_wire_auditor_account_progress.h b/src/auditordb/pg_get_wire_auditor_account_progress.h
deleted file mode 100644
index ab1d2bb96..000000000
--- a/src/auditordb/pg_get_wire_auditor_account_progress.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_wire_auditor_account_progress.h
- * @brief implementation of the get_wire_auditor_account_progress function
- * @author Christian Grothoff
- */
-#ifndef PG_GET_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
-#define PG_GET_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Get information about the progress of the auditor.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param account_name name of the wire account we are auditing
- * @param[out] pp where is the auditor in processing
- * @param[out] bapp how far are we in the wire transaction histories
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_wire_auditor_account_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *account_name,
- struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- struct TALER_AUDITORDB_BankAccountProgressPoint *bapp);
-
-
-#endif
diff --git a/src/auditordb/pg_get_wire_auditor_progress.c b/src/auditordb/pg_get_wire_auditor_progress.c
deleted file mode 100644
index a0eaefc65..000000000
--- a/src/auditordb/pg_get_wire_auditor_progress.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022-2023 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_wire_auditor_progress.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_wire_auditor_progress.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_wire_auditor_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_WireProgressPoint *pp)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("last_reserve_close_uuid",
- &pp->last_reserve_close_uuid),
- GNUNET_PQ_result_spec_uint64 ("last_batch_deposit_uuid",
- &pp->last_batch_deposit_uuid),
- GNUNET_PQ_result_spec_uint64 ("last_aggregation_serial",
- &pp->last_aggregation_serial),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "wire_auditor_progress_select",
- "SELECT"
- " last_reserve_close_uuid"
- ",last_batch_deposit_uuid"
- ",last_aggregation_serial"
- " FROM wire_auditor_progress"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "wire_auditor_progress_select",
- params,
- rs);
-}
diff --git a/src/auditordb/pg_get_wire_auditor_progress.h b/src/auditordb/pg_get_wire_auditor_progress.h
deleted file mode 100644
index dec554acc..000000000
--- a/src/auditordb/pg_get_wire_auditor_progress.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_get_wire_auditor_progress.h
- * @brief implementation of the get_wire_auditor_progress function
- * @author Christian Grothoff
- */
-#ifndef PG_GET_WIRE_AUDITOR_PROGRESS_H
-#define PG_GET_WIRE_AUDITOR_PROGRESS_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Get information about the progress of the auditor.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param[out] pp set to where the auditor is in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_get_wire_auditor_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_WireProgressPoint *pp);
-
-
-#endif
diff --git a/src/auditordb/pg_get_wire_fee_summary.c b/src/auditordb/pg_get_wire_fee_summary.c
index 36ed19996..b0eb9ba50 100644
--- a/src/auditordb/pg_get_wire_fee_summary.c
+++ b/src/auditordb/pg_get_wire_fee_summary.c
@@ -30,18 +30,15 @@
* Get summary information about an exchanges wire fee balance.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
* @param[out] wire_fee_balance set amount the exchange gained in wire fees
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
TAH_PG_get_wire_fee_summary (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
struct TALER_Amount *wire_fee_balance)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -54,8 +51,7 @@ TAH_PG_get_wire_fee_summary (void *cls,
"auditor_wire_fee_balance_select",
"SELECT"
" wire_fee_balance"
- " FROM auditor_wire_fee_balance"
- " WHERE master_pub=$1;");
+ " FROM auditor_wire_fee_balance");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"auditor_wire_fee_balance_select",
params,
diff --git a/src/auditordb/pg_get_wire_fee_summary.h b/src/auditordb/pg_get_wire_fee_summary.h
index c6e5bacde..4c7f1aebd 100644
--- a/src/auditordb/pg_get_wire_fee_summary.h
+++ b/src/auditordb/pg_get_wire_fee_summary.h
@@ -30,13 +30,11 @@
* Get summary information about an exchanges wire fee balance.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
* @param[out] wire_fee_balance set amount the exchange gained in wire fees
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
TAH_PG_get_wire_fee_summary (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
struct TALER_Amount *wire_fee_balance);
diff --git a/src/auditordb/pg_insert_auditor_progress.c b/src/auditordb/pg_insert_auditor_progress.c
new file mode 100644
index 000000000..3c5d25eef
--- /dev/null
+++ b/src/auditordb/pg_insert_auditor_progress.c
@@ -0,0 +1,97 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file pg_insert_auditor_progress.c
+ * @brief Low-level (statement-level) Postgres database access for the exchange
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_insert_auditor_progress.h"
+#include "pg_helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TAH_PG_insert_auditor_progress (
+ void *cls,
+ const char *progress_key,
+ uint64_t progress_offset,
+ ...)
+{
+ struct PostgresClosure *pg = cls;
+ unsigned int cnt = 1;
+ va_list ap;
+
+ va_start (ap,
+ progress_offset);
+ while (NULL != va_arg (ap,
+ const char *))
+ {
+ cnt++;
+ (void) va_arg (ap,
+ uint64_t);
+ }
+ va_end (ap);
+ {
+ const char *keys[cnt];
+ uint64_t offsets[cnt];
+ unsigned int off = 1;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_array_ptrs_string (cnt,
+ keys,
+ pg->conn),
+ GNUNET_PQ_query_param_array_uint64 (cnt,
+ offsets,
+ pg->conn),
+ GNUNET_PQ_query_param_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ keys[0] = progress_key;
+ offsets[0] = progress_offset;
+
+ va_start (ap,
+ progress_offset);
+ while (off < cnt)
+ {
+ keys[off] = va_arg (ap,
+ const char *);
+ offsets[off] = va_arg (ap,
+ uint64_t);
+ off++;
+ }
+ GNUNET_assert (NULL == va_arg (ap,
+ const char *));
+ va_end (ap);
+
+ PREPARE (pg,
+ "auditor_progress_insert",
+ "INSERT INTO auditor_progress "
+ "(progress_key"
+ ",progress_offset"
+ ") SELECT *"
+ " FROM UNNEST (CAST($1 AS TEXT[]),"
+ " CAST($2 AS INT8[]))"
+ " ON CONFLICT DO NOTHING;");
+ qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "auditor_progress_insert",
+ params);
+ GNUNET_PQ_cleanup_query_params_closures (params);
+ return qs;
+ }
+}
diff --git a/src/auditordb/pg_insert_wire_auditor_progress.h b/src/auditordb/pg_insert_auditor_progress.h
index 1e3b60805..a20e376c8 100644
--- a/src/auditordb/pg_insert_wire_auditor_progress.h
+++ b/src/auditordb/pg_insert_auditor_progress.h
@@ -14,12 +14,12 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file pg_insert_wire_auditor_progress.h
- * @brief implementation of the insert_wire_auditor_progress function
+ * @file pg_insert_auditor_progress.h
+ * @brief implementation of the insert_auditor_progress function
* @author Christian Grothoff
*/
-#ifndef PG_INSERT_WIRE_AUDITOR_PROGRESS_H
-#define PG_INSERT_WIRE_AUDITOR_PROGRESS_H
+#ifndef PG_INSERT_AUDITOR_PROGRESS_H
+#define PG_INSERT_AUDITOR_PROGRESS_H
#include "taler_util.h"
#include "taler_json_lib.h"
@@ -31,15 +31,16 @@
* data.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param pp where is the auditor in processing
+ * @param progress_key name of the progress indicator
+ * @param progress_offset offset until which we have made progress
+ * @param ... NULL terminated list of additional key-value pairs to insert
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
-TAH_PG_insert_wire_auditor_progress (
+TAH_PG_insert_auditor_progress (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_WireProgressPoint *pp);
-
+ const char *progress_key,
+ uint64_t progress_offset,
+ ...);
#endif
diff --git a/src/auditordb/pg_insert_auditor_progress_aggregation.c b/src/auditordb/pg_insert_auditor_progress_aggregation.c
deleted file mode 100644
index f119548f8..000000000
--- a/src/auditordb/pg_insert_auditor_progress_aggregation.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_aggregation.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_auditor_progress_aggregation.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_aggregation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointAggregation *ppa)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_progress_insert_aggregation",
- "INSERT INTO auditor_progress_aggregation "
- "(master_pub"
- ",last_wire_out_serial_id"
- ") VALUES ($1,$2);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_insert_aggregation",
- params);
-}
diff --git a/src/auditordb/pg_insert_auditor_progress_aggregation.h b/src/auditordb/pg_insert_auditor_progress_aggregation.h
deleted file mode 100644
index 74d4b6fd6..000000000
--- a/src/auditordb/pg_insert_auditor_progress_aggregation.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_aggregation.h
- * @brief implementation of the insert_auditor_progress_aggregation function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_AUDITOR_PROGRESS_AGGREGATION_H
-#define PG_INSERT_AUDITOR_PROGRESS_AGGREGATION_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about the auditor's progress with an exchange's
- * data.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppa where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_aggregation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
-
-
-#endif
diff --git a/src/auditordb/pg_insert_auditor_progress_coin.c b/src/auditordb/pg_insert_auditor_progress_coin.c
deleted file mode 100644
index aec745c5c..000000000
--- a/src/auditordb/pg_insert_auditor_progress_coin.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_coin.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_auditor_progress_coin.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_coin (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointCoin *ppc)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_recoup_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_recoup_refresh_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_purse_deposits_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_purse_refunds_serial_id),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_progress_insert_coin",
- "INSERT INTO auditor_progress_coin "
- "(master_pub"
- ",last_withdraw_serial_id"
- ",last_deposit_serial_id"
- ",last_melt_serial_id"
- ",last_refund_serial_id"
- ",last_recoup_serial_id"
- ",last_recoup_refresh_serial_id"
- ",last_purse_deposits_serial_id"
- ",last_purse_decision_serial_id"
- ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_insert_coin",
- params);
-}
diff --git a/src/auditordb/pg_insert_auditor_progress_coin.h b/src/auditordb/pg_insert_auditor_progress_coin.h
deleted file mode 100644
index 57f728cbb..000000000
--- a/src/auditordb/pg_insert_auditor_progress_coin.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_coin.h
- * @brief implementation of the insert_auditor_progress_coin function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_AUDITOR_PROGRESS_COIN_H
-#define PG_INSERT_AUDITOR_PROGRESS_COIN_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about the auditor's progress with an exchange's
- * data.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppc where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_coin (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointCoin *ppc);
-
-#endif
diff --git a/src/auditordb/pg_insert_auditor_progress_deposit_confirmation.c b/src/auditordb/pg_insert_auditor_progress_deposit_confirmation.c
deleted file mode 100644
index 94231b1c6..000000000
--- a/src/auditordb/pg_insert_auditor_progress_deposit_confirmation.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_deposit_confirmation.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_auditor_progress_deposit_confirmation.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_deposit_confirmation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_uint64 (&ppdc->last_deposit_confirmation_serial_id),
- GNUNET_PQ_query_param_end
- };
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "isnert ppdc last deposit conf serial id above %ld\n",
- ppdc->last_deposit_confirmation_serial_id);
- PREPARE (pg,
- "auditor_progress_insert_deposit_confirmation",
- "INSERT INTO auditor_progress_deposit_confirmation "
- "(master_pub"
- ",last_deposit_confirmation_serial_id"
- ") VALUES ($1,$2);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_insert_deposit_confirmation",
- params);
-}
diff --git a/src/auditordb/pg_insert_auditor_progress_deposit_confirmation.h b/src/auditordb/pg_insert_auditor_progress_deposit_confirmation.h
deleted file mode 100644
index 21a5ed282..000000000
--- a/src/auditordb/pg_insert_auditor_progress_deposit_confirmation.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_deposit_confirmation.h
- * @brief implementation of the insert_auditor_progress_deposit_confirmation function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
-#define PG_INSERT_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about the auditor's progress with an exchange's
- * data.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppdc where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_deposit_confirmation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc);
-
-#endif
diff --git a/src/auditordb/pg_insert_auditor_progress_purse.c b/src/auditordb/pg_insert_auditor_progress_purse.c
deleted file mode 100644
index fa4f0bd29..000000000
--- a/src/auditordb/pg_insert_auditor_progress_purse.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_purse.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_auditor_progress_purse.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_purse (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointPurse *ppp)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_uint64 (&ppp->last_purse_request_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppp->last_purse_decision_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppp->last_purse_merge_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppp->last_account_merge_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppp->last_purse_deposits_serial_id),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_progress_insert_purse",
- "INSERT INTO auditor_progress_purse "
- "(master_pub"
- ",last_purse_request_serial_id"
- ",last_purse_decision_serial_id"
- ",last_purse_merges_serial_id"
- ",last_account_merges_serial_id"
- ",last_purse_deposits_serial_id"
- ") VALUES ($1,$2,$3,$4,$5,$6);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_insert_purse",
- params);
-}
diff --git a/src/auditordb/pg_insert_auditor_progress_purse.h b/src/auditordb/pg_insert_auditor_progress_purse.h
deleted file mode 100644
index d364f2f0d..000000000
--- a/src/auditordb/pg_insert_auditor_progress_purse.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_purse.h
- * @brief implementation of the insert_auditor_progress_purse function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_AUDITOR_PROGRESS_PURSE_H
-#define PG_INSERT_AUDITOR_PROGRESS_PURSE_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about the auditor's progress with an exchange's
- * data.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppp where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_purse (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointPurse *ppp);
-
-#endif
diff --git a/src/auditordb/pg_insert_auditor_progress_reserve.c b/src/auditordb/pg_insert_auditor_progress_reserve.c
deleted file mode 100644
index 864ca6f0f..000000000
--- a/src/auditordb/pg_insert_auditor_progress_reserve.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_reserve.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_auditor_progress_reserve.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_reserve (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointReserve *ppr)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_out_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_recoup_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_open_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_close_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_purse_decisions_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_account_merges_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_history_requests_serial_id),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_progress_insert_reserve",
- "INSERT INTO auditor_progress_reserve "
- "(master_pub"
- ",last_reserve_in_serial_id"
- ",last_reserve_out_serial_id"
- ",last_reserve_recoup_serial_id"
- ",last_reserve_open_serial_id"
- ",last_reserve_close_serial_id"
- ",last_purse_decision_serial_id"
- ",last_account_merges_serial_id"
- ",last_history_requests_serial_id"
- ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_insert_reserve",
- params);
-}
diff --git a/src/auditordb/pg_insert_auditor_progress_reserve.h b/src/auditordb/pg_insert_auditor_progress_reserve.h
deleted file mode 100644
index d1e4d04e0..000000000
--- a/src/auditordb/pg_insert_auditor_progress_reserve.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_auditor_progress_reserve.h
- * @brief implementation of the insert_auditor_progress_reserve function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_AUDITOR_PROGRESS_RESERVE_H
-#define PG_INSERT_AUDITOR_PROGRESS_RESERVE_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-/**
- * Insert information about the auditor's progress with an exchange's
- * data.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppr where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_auditor_progress_reserve (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointReserve *ppr);
-
-#endif
diff --git a/src/auditordb/pg_insert_balance.c b/src/auditordb/pg_insert_balance.c
new file mode 100644
index 000000000..0d1762acc
--- /dev/null
+++ b/src/auditordb/pg_insert_balance.c
@@ -0,0 +1,97 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file pg_insert_balance.c
+ * @brief Implementation of the insert_balance function
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_insert_balance.h"
+#include "pg_helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TAH_PG_insert_balance (void *cls,
+ const char *balance_key,
+ const struct TALER_Amount *balance_value,
+ ...)
+{
+ struct PostgresClosure *pg = cls;
+ unsigned int cnt = 1;
+ va_list ap;
+
+ va_start (ap,
+ balance_value);
+ while (NULL != va_arg (ap,
+ const char *))
+ {
+ cnt++;
+ (void) va_arg (ap,
+ const struct TALER_Amount *);
+ }
+ va_end (ap);
+ {
+ const char *keys[cnt];
+ struct TALER_Amount amounts[cnt];
+ unsigned int off = 1;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_array_ptrs_string (cnt,
+ keys,
+ pg->conn),
+ TALER_PQ_query_param_array_amount (cnt,
+ amounts,
+ pg->conn),
+ GNUNET_PQ_query_param_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ keys[0] = balance_key;
+ amounts[0] = *balance_value;
+
+ va_start (ap,
+ balance_value);
+ while (off < cnt)
+ {
+ keys[off] = va_arg (ap,
+ const char *);
+ amounts[off] = *va_arg (ap,
+ const struct TALER_Amount *);
+ off++;
+ }
+ GNUNET_assert (NULL == va_arg (ap,
+ const char *));
+ va_end (ap);
+
+ PREPARE (pg,
+ "auditor_balance_insert",
+ "INSERT INTO auditor_balances "
+ "(balance_key"
+ ",balance_value.val"
+ ",balance_value.frac"
+ ") SELECT *"
+ " FROM UNNEST (CAST($1 AS TEXT[]),"
+ " CAST($2 AS taler_amount[]))"
+ " ON CONFLICT DO NOTHING;");
+ qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "auditor_balance_insert",
+ params);
+ GNUNET_PQ_cleanup_query_params_closures (params);
+ return qs;
+ }
+}
diff --git a/src/auditordb/pg_get_auditor_progress_purse.h b/src/auditordb/pg_insert_balance.h
index db8d48e8e..19c7a8c6c 100644
--- a/src/auditordb/pg_get_auditor_progress_purse.h
+++ b/src/auditordb/pg_insert_balance.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -14,31 +14,32 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file pg_get_auditor_progress_purse.h
- * @brief implementation of the get_auditor_progress_purse function
+ * @file pg_insert_balance.h
+ * @brief implementation of the insert_balance function
* @author Christian Grothoff
*/
-#ifndef PG_GET_AUDITOR_PROGRESS_PURSE_H
-#define PG_GET_AUDITOR_PROGRESS_PURSE_H
+#ifndef PG_INSERT_BALANCE_H
+#define PG_INSERT_BALANCE_H
#include "taler_util.h"
#include "taler_json_lib.h"
#include "taler_auditordb_plugin.h"
-
/**
- * Get information about the progress of the auditor.
+ * Insert information about a balance tracked by the auditor. There must not be an
+ * existing record.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param[out] ppp set to where the auditor is in processing
+ * @param balance_key key of the blance to store
+ * @param balance_value value to store
+ * @param ... NULL terminated list of additional key-value pairs to insert
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
-TAH_PG_get_auditor_progress_purse (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointPurse *ppp);
+TAH_PG_insert_balance (void *cls,
+ const char *balance_key,
+ const struct TALER_Amount *balance_value,
+ ...);
#endif
diff --git a/src/auditordb/pg_insert_balance_summary.c b/src/auditordb/pg_insert_balance_summary.c
deleted file mode 100644
index 7634ab80b..000000000
--- a/src/auditordb/pg_insert_balance_summary.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_balance_summary.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_balance_summary.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_balance_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_GlobalCoinBalance *dfb)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->total_escrowed),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->deposit_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->melt_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->refund_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->purse_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->open_deposit_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->risk),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->loss),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->irregular_loss),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_balance_summary_insert",
- "INSERT INTO auditor_balance_summary "
- "(master_pub"
- ",denom_balance"
- ",deposit_fee_balance"
- ",melt_fee_balance"
- ",refund_fee_balance"
- ",purse_fee_balance"
- ",open_deposit_fee_balance"
- ",risk"
- ",loss"
- ",irregular_loss"
- ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_balance_summary_insert",
- params);
-}
diff --git a/src/auditordb/pg_insert_balance_summary.h b/src/auditordb/pg_insert_balance_summary.h
deleted file mode 100644
index ee00ae7f0..000000000
--- a/src/auditordb/pg_insert_balance_summary.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_balance_summary.h
- * @brief implementation of the insert_balance_summary function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_BALANCE_SUMMARY_H
-#define PG_INSERT_BALANCE_SUMMARY_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about an exchange's denomination balances. There
- * must not be an existing record for the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param dfb denomination balance data to store
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_balance_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_GlobalCoinBalance *dfb);
-
-#endif
diff --git a/src/auditordb/pg_insert_deposit_confirmation.c b/src/auditordb/pg_insert_deposit_confirmation.c
index b811e267a..1b5205782 100644
--- a/src/auditordb/pg_insert_deposit_confirmation.c
+++ b/src/auditordb/pg_insert_deposit_confirmation.c
@@ -33,7 +33,6 @@ TAH_PG_insert_deposit_confirmation (
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (&dc->master_public_key),
GNUNET_PQ_query_param_auto_from_type (&dc->h_contract_terms),
GNUNET_PQ_query_param_auto_from_type (&dc->h_policy),
GNUNET_PQ_query_param_auto_from_type (&dc->h_wire),
@@ -58,8 +57,7 @@ TAH_PG_insert_deposit_confirmation (
PREPARE (pg,
"auditor_deposit_confirmation_insert",
"INSERT INTO deposit_confirmations "
- "(master_pub"
- ",h_contract_terms"
+ "(h_contract_terms"
",h_policy"
",h_wire"
",exchange_timestamp"
@@ -72,7 +70,7 @@ TAH_PG_insert_deposit_confirmation (
",exchange_sig"
",exchange_pub"
",master_sig" /* master_sig could be normalized... */
- ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14);");
+ ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_deposit_confirmation_insert",
params);
diff --git a/src/auditordb/pg_insert_exchange.c b/src/auditordb/pg_insert_exchange.c
deleted file mode 100644
index bc84ad77c..000000000
--- a/src/auditordb/pg_insert_exchange.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_exchange.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_exchange.h"
-#include "pg_helper.h"
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_exchange (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *exchange_url)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_string (exchange_url),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_insert_exchange",
- "INSERT INTO auditor_exchanges "
- "(master_pub"
- ",exchange_url"
- ") VALUES ($1,$2);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_insert_exchange",
- params);
-}
diff --git a/src/auditordb/pg_insert_exchange.h b/src/auditordb/pg_insert_exchange.h
deleted file mode 100644
index c06f2115c..000000000
--- a/src/auditordb/pg_insert_exchange.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_exchange.h
- * @brief implementation of the insert_exchange function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_EXCHANGE_H
-#define PG_INSERT_EXCHANGE_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about an exchange this auditor will be auditing.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @param exchange_url public (base) URL of the API of the exchange
- * @return query result status
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_exchange (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *exchange_url);
-
-
-#endif
diff --git a/src/auditordb/pg_insert_exchange_signkey.c b/src/auditordb/pg_insert_exchange_signkey.c
index fa310f2ef..8bf439da0 100644
--- a/src/auditordb/pg_insert_exchange_signkey.c
+++ b/src/auditordb/pg_insert_exchange_signkey.c
@@ -33,7 +33,6 @@ TAH_PG_insert_exchange_signkey (
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (&sk->master_public_key),
GNUNET_PQ_query_param_timestamp (&sk->ep_start),
GNUNET_PQ_query_param_timestamp (&sk->ep_expire),
GNUNET_PQ_query_param_timestamp (&sk->ep_end),
@@ -45,13 +44,12 @@ TAH_PG_insert_exchange_signkey (
PREPARE (pg,
"auditor_insert_exchange_signkey",
"INSERT INTO auditor_exchange_signkeys "
- "(master_pub"
- ",ep_start"
+ "(ep_start"
",ep_expire"
",ep_end"
",exchange_pub"
",master_sig"
- ") VALUES ($1,$2,$3,$4,$5,$6);");
+ ") VALUES ($1,$2,$3,$4,$5);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_insert_exchange_signkey",
params);
diff --git a/src/auditordb/pg_insert_historic_denom_revenue.c b/src/auditordb/pg_insert_historic_denom_revenue.c
index bcafe068a..2c3dd44cc 100644
--- a/src/auditordb/pg_insert_historic_denom_revenue.c
+++ b/src/auditordb/pg_insert_historic_denom_revenue.c
@@ -29,7 +29,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_insert_historic_denom_revenue (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_DenominationHashP *denom_pub_hash,
struct GNUNET_TIME_Timestamp revenue_timestamp,
const struct TALER_Amount *revenue_balance,
@@ -37,7 +36,6 @@ TAH_PG_insert_historic_denom_revenue (
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
GNUNET_PQ_query_param_timestamp (&revenue_timestamp),
TALER_PQ_query_param_amount (pg->conn,
@@ -50,12 +48,11 @@ TAH_PG_insert_historic_denom_revenue (
PREPARE (pg,
"auditor_historic_denomination_revenue_insert",
"INSERT INTO auditor_historic_denomination_revenue"
- "(master_pub"
- ",denom_pub_hash"
+ "(denom_pub_hash"
",revenue_timestamp"
",revenue_balance"
",loss_balance"
- ") VALUES ($1,$2,$3,$4,$5);");
+ ") VALUES ($1,$2,$3,$4);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_historic_denomination_revenue_insert",
params);
diff --git a/src/auditordb/pg_insert_historic_denom_revenue.h b/src/auditordb/pg_insert_historic_denom_revenue.h
index 2f8e005d7..02567119b 100644
--- a/src/auditordb/pg_insert_historic_denom_revenue.h
+++ b/src/auditordb/pg_insert_historic_denom_revenue.h
@@ -31,7 +31,6 @@
* revenue about a denomination key.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
* @param denom_pub_hash hash of the denomination key
* @param revenue_timestamp when did this profit get realized
* @param revenue_balance what was the total profit made from
@@ -43,7 +42,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_insert_historic_denom_revenue (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_DenominationHashP *denom_pub_hash,
struct GNUNET_TIME_Timestamp revenue_timestamp,
const struct TALER_Amount *revenue_balance,
diff --git a/src/auditordb/pg_insert_historic_reserve_revenue.c b/src/auditordb/pg_insert_historic_reserve_revenue.c
index d5ce9ed47..953fba34a 100644
--- a/src/auditordb/pg_insert_historic_reserve_revenue.c
+++ b/src/auditordb/pg_insert_historic_reserve_revenue.c
@@ -28,14 +28,12 @@
enum GNUNET_DB_QueryStatus
TAH_PG_insert_historic_reserve_revenue (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_Amount *reserve_profits)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_timestamp (&start_time),
GNUNET_PQ_query_param_timestamp (&end_time),
TALER_PQ_query_param_amount (pg->conn,
@@ -46,11 +44,10 @@ TAH_PG_insert_historic_reserve_revenue (
PREPARE (pg,
"auditor_historic_reserve_summary_insert",
"INSERT INTO auditor_historic_reserve_summary"
- "(master_pub"
- ",start_date"
+ "(start_date"
",end_date"
",reserve_profits"
- ") VALUES ($1,$2,$3,$4);");
+ ") VALUES ($1,$2,$3);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_historic_reserve_summary_insert",
params);
diff --git a/src/auditordb/pg_insert_historic_reserve_revenue.h b/src/auditordb/pg_insert_historic_reserve_revenue.h
index d6c29ed08..a76a50b39 100644
--- a/src/auditordb/pg_insert_historic_reserve_revenue.h
+++ b/src/auditordb/pg_insert_historic_reserve_revenue.h
@@ -30,7 +30,6 @@
* Insert information about an exchange's historic revenue from reserves.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
* @param start_time beginning of aggregated time interval
* @param end_time end of aggregated time interval
* @param reserve_profits total profits made
@@ -39,7 +38,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_insert_historic_reserve_revenue (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_Amount *reserve_profits);
diff --git a/src/auditordb/pg_insert_pending_deposit.c b/src/auditordb/pg_insert_pending_deposit.c
index 11b3e48e1..50b655ee7 100644
--- a/src/auditordb/pg_insert_pending_deposit.c
+++ b/src/auditordb/pg_insert_pending_deposit.c
@@ -29,7 +29,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_insert_pending_deposit (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
uint64_t batch_deposit_serial_id,
const struct TALER_PaytoHashP *wire_target_h_payto,
const struct TALER_Amount *total_amount,
@@ -37,7 +36,6 @@ TAH_PG_insert_pending_deposit (
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
TALER_PQ_query_param_amount (pg->conn,
total_amount),
GNUNET_PQ_query_param_auto_from_type (wire_target_h_payto),
@@ -49,12 +47,11 @@ TAH_PG_insert_pending_deposit (
PREPARE (pg,
"auditor_insert_pending_deposit",
"INSERT INTO auditor_pending_deposits "
- "(master_pub"
- ",total_amount"
+ "(total_amount"
",wire_target_h_payto"
",batch_deposit_serial_id"
",deadline"
- ") VALUES ($1,$2,$3,$4,$5);");
+ ") VALUES ($1,$2,$3,$4);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_insert_pending_deposit",
params);
diff --git a/src/auditordb/pg_insert_pending_deposit.h b/src/auditordb/pg_insert_pending_deposit.h
index 2f867e87e..7c2b59809 100644
--- a/src/auditordb/pg_insert_pending_deposit.h
+++ b/src/auditordb/pg_insert_pending_deposit.h
@@ -30,7 +30,6 @@
* Insert new row into the pending deposits table.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
* @param batch_deposit_serial_id where in the 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
@@ -40,7 +39,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_insert_pending_deposit (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
uint64_t batch_deposit_serial_id,
const struct TALER_PaytoHashP *wire_target_h_payto,
const struct TALER_Amount *total_amount,
diff --git a/src/auditordb/pg_insert_predicted_result.c b/src/auditordb/pg_insert_predicted_result.c
deleted file mode 100644
index 6f5250f01..000000000
--- a/src/auditordb/pg_insert_predicted_result.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_predicted_result.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_predicted_result.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_predicted_result (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *balance,
- const struct TALER_Amount *drained)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- TALER_PQ_query_param_amount (pg->conn,
- balance),
- TALER_PQ_query_param_amount (pg->conn,
- drained),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_predicted_result_insert",
- "INSERT INTO auditor_predicted_result"
- "(master_pub"
- ",balance"
- ",drained"
- ") VALUES ($1,$2,$3);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_predicted_result_insert",
- params);
-}
diff --git a/src/auditordb/pg_insert_predicted_result.h b/src/auditordb/pg_insert_predicted_result.h
deleted file mode 100644
index ef9f4c3b3..000000000
--- a/src/auditordb/pg_insert_predicted_result.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_predicted_result.h
- * @brief implementation of the insert_predicted_result function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_PREDICTED_RESULT_H
-#define PG_INSERT_PREDICTED_RESULT_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about the predicted exchange's bank
- * account balance.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param balance what the bank account balance of the exchange should show
- * @param drained amount that was drained in profits
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_predicted_result (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *balance,
- const struct TALER_Amount *drained);
-
-#endif
diff --git a/src/auditordb/pg_insert_purse_info.c b/src/auditordb/pg_insert_purse_info.c
index cd97defc0..7eaad8d3c 100644
--- a/src/auditordb/pg_insert_purse_info.c
+++ b/src/auditordb/pg_insert_purse_info.c
@@ -30,14 +30,12 @@ enum GNUNET_DB_QueryStatus
TAH_PG_insert_purse_info (
void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_Amount *balance,
struct GNUNET_TIME_Timestamp expiration_date)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (purse_pub),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
TALER_PQ_query_param_amount (pg->conn,
balance),
GNUNET_PQ_query_param_timestamp (&expiration_date),
@@ -48,10 +46,9 @@ TAH_PG_insert_purse_info (
"auditor_purses_insert",
"INSERT INTO auditor_purses "
"(purse_pub"
- ",master_pub"
",target"
",expiration_date"
- ") VALUES ($1,$2,$3,$4);");
+ ") VALUES ($1,$2,$3);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_purses_insert",
params);
diff --git a/src/auditordb/pg_insert_purse_info.h b/src/auditordb/pg_insert_purse_info.h
index 67ac3dba1..ee1b3eebd 100644
--- a/src/auditordb/pg_insert_purse_info.h
+++ b/src/auditordb/pg_insert_purse_info.h
@@ -31,7 +31,6 @@
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param purse_pub public key of the purse
- * @param master_pub master public key of the exchange
* @param balance balance of the purse
* @param expiration_date expiration date of the purse
* @return transaction status code
@@ -40,7 +39,6 @@ enum GNUNET_DB_QueryStatus
TAH_PG_insert_purse_info (
void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_Amount *balance,
struct GNUNET_TIME_Timestamp expiration_date);
diff --git a/src/auditordb/pg_insert_purse_summary.c b/src/auditordb/pg_insert_purse_summary.c
deleted file mode 100644
index addb4adc7..000000000
--- a/src/auditordb/pg_insert_purse_summary.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file auditordb/pg_insert_purse_summary.c
- * @brief Implementation of the insert_purse_summary function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_purse_summary.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_purse_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_PurseBalance *sum)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- TALER_PQ_query_param_amount (pg->conn,
- &sum->balance),
- GNUNET_PQ_query_param_uint64 (&sum->open_purses),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_purse_summary_insert",
- "INSERT INTO auditor_purse_summary "
- "(master_pub"
- ",balance"
- ",open_purses"
- ") VALUES ($1,$2,$3);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_purse_summary_insert",
- params);
-}
diff --git a/src/auditordb/pg_insert_purse_summary.h b/src/auditordb/pg_insert_purse_summary.h
deleted file mode 100644
index 37e1843d7..000000000
--- a/src/auditordb/pg_insert_purse_summary.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file auditordb/pg_insert_purse_summary.h
- * @brief implementation of the insert_purse_summary function for Postgres
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_PURSE_SUMMARY_H
-#define PG_INSERT_PURSE_SUMMARY_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about all purses. There must not be an
- * existing record for the @a master_pub.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @param sum purse balance summary to store
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_purse_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_PurseBalance *sum);
-
-
-#endif
diff --git a/src/auditordb/pg_insert_reserve_info.c b/src/auditordb/pg_insert_reserve_info.c
index a7e3fd922..4c99394fe 100644
--- a/src/auditordb/pg_insert_reserve_info.c
+++ b/src/auditordb/pg_insert_reserve_info.c
@@ -30,7 +30,6 @@ enum GNUNET_DB_QueryStatus
TAH_PG_insert_reserve_info (
void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
struct GNUNET_TIME_Timestamp expiration_date,
const char *origin_account)
@@ -38,7 +37,6 @@ TAH_PG_insert_reserve_info (
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
TALER_PQ_query_param_amount (pg->conn,
&rfb->reserve_balance),
TALER_PQ_query_param_amount (pg->conn,
@@ -61,10 +59,9 @@ TAH_PG_insert_reserve_info (
};
PREPARE (pg,
- "auditor_reserves_insert",
+ "auditor_insert_reserve_info",
"INSERT INTO auditor_reserves "
"(reserve_pub"
- ",master_pub"
",reserve_balance"
",reserve_loss"
",withdraw_fee_balance"
@@ -74,10 +71,9 @@ TAH_PG_insert_reserve_info (
",history_fee_balance"
",expiration_date"
",origin_account"
-
") VALUES "
- "($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);");
+ "($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_reserves_insert",
+ "auditor_insert_reserve_info",
params);
}
diff --git a/src/auditordb/pg_insert_reserve_info.h b/src/auditordb/pg_insert_reserve_info.h
index 5b5aa67eb..b416aa556 100644
--- a/src/auditordb/pg_insert_reserve_info.h
+++ b/src/auditordb/pg_insert_reserve_info.h
@@ -32,7 +32,6 @@
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param reserve_pub public key of the reserve
- * @param master_pub master public key of the exchange
* @param rfb balance amounts for the reserve
* @param expiration_date when will the reserve expire
* @param origin_account where did the money in the reserve originally come from
@@ -42,7 +41,6 @@ enum GNUNET_DB_QueryStatus
TAH_PG_insert_reserve_info (
void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
struct GNUNET_TIME_Timestamp expiration_date,
const char *origin_account);
diff --git a/src/auditordb/pg_insert_reserve_summary.c b/src/auditordb/pg_insert_reserve_summary.c
deleted file mode 100644
index e085d23b6..000000000
--- a/src/auditordb/pg_insert_reserve_summary.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_reserve_summary.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_reserve_summary.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_reserve_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ReserveFeeBalance *rfb)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->reserve_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->reserve_loss),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->withdraw_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->close_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->purse_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->open_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->history_fee_balance),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_reserve_balance_insert",
- "INSERT INTO auditor_reserve_balance"
- "(master_pub"
- ",reserve_balance"
- ",reserve_loss"
- ",withdraw_fee_balance"
- ",close_fee_balance"
- ",purse_fee_balance"
- ",open_fee_balance"
- ",history_fee_balance"
- ") VALUES "
- "($1,$2,$3,$4,$5,$6,$7,$8)");
- GNUNET_assert (GNUNET_YES ==
- TALER_amount_cmp_currency (&rfb->reserve_balance,
- &rfb->withdraw_fee_balance));
-
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_reserve_balance_insert",
- params);
-}
diff --git a/src/auditordb/pg_insert_reserve_summary.h b/src/auditordb/pg_insert_reserve_summary.h
deleted file mode 100644
index b5e200766..000000000
--- a/src/auditordb/pg_insert_reserve_summary.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_reserve_summary.h
- * @brief implementation of the insert_reserve_summary function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_RESERVE_SUMMARY_H
-#define PG_INSERT_RESERVE_SUMMARY_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about all reserves. There must not be an
- * existing record for the @a master_pub.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @param rfb balances to be stored for the reserve
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_reserve_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
-
-
-#endif
diff --git a/src/auditordb/pg_insert_wire_auditor_account_progress.c b/src/auditordb/pg_insert_wire_auditor_account_progress.c
deleted file mode 100644
index b0e416a42..000000000
--- a/src/auditordb/pg_insert_wire_auditor_account_progress.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_wire_auditor_account_progress.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_wire_auditor_account_progress.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_wire_auditor_account_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *account_name,
- const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_string (account_name),
- GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
- GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),
- GNUNET_PQ_query_param_uint64 (&bapp->in_wire_off),
- GNUNET_PQ_query_param_uint64 (&bapp->out_wire_off),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "wire_auditor_account_progress_insert",
- "INSERT INTO wire_auditor_account_progress "
- "(master_pub"
- ",account_name"
- ",last_wire_reserve_in_serial_id"
- ",last_wire_wire_out_serial_id"
- ",wire_in_off"
- ",wire_out_off"
- ") VALUES ($1,$2,$3,$4,$5,$6);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "wire_auditor_account_progress_insert",
- params);
-}
diff --git a/src/auditordb/pg_insert_wire_auditor_account_progress.h b/src/auditordb/pg_insert_wire_auditor_account_progress.h
deleted file mode 100644
index 72c2b595c..000000000
--- a/src/auditordb/pg_insert_wire_auditor_account_progress.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_wire_auditor_account_progress.h
- * @brief implementation of the insert_wire_auditor_account_progress function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
-#define PG_INSERT_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about the auditor's progress with an exchange's
- * data.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param account_name name of the wire account we are auditing
- * @param pp how far are we in the auditor's tables
- * @param bapp progress in wire transaction histories
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_wire_auditor_account_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *account_name,
- const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp);
-
-#endif
diff --git a/src/auditordb/pg_insert_wire_auditor_progress.c b/src/auditordb/pg_insert_wire_auditor_progress.c
deleted file mode 100644
index c9e302773..000000000
--- a/src/auditordb/pg_insert_wire_auditor_progress.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022-2023 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_wire_auditor_progress.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_wire_auditor_progress.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_wire_auditor_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_WireProgressPoint *pp)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_uint64 (&pp->last_reserve_close_uuid),
- GNUNET_PQ_query_param_uint64 (&pp->last_batch_deposit_uuid),
- GNUNET_PQ_query_param_uint64 (&pp->last_aggregation_serial),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "wire_auditor_progress_insert",
- "INSERT INTO wire_auditor_progress "
- "(master_pub"
- ",last_reserve_close_uuid"
- ",last_batch_deposit_uuid"
- ",last_aggregation_serial"
- ") VALUES ($1,$2,$3,$4);");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "wire_auditor_progress_insert",
- params);
-}
diff --git a/src/auditordb/pg_insert_wire_fee_summary.c b/src/auditordb/pg_insert_wire_fee_summary.c
deleted file mode 100644
index 26ca1ac98..000000000
--- a/src/auditordb/pg_insert_wire_fee_summary.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_wire_fee_summary.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_wire_fee_summary.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_wire_fee_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *wire_fee_balance)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- TALER_PQ_query_param_amount (pg->conn,
- wire_fee_balance),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_wire_fee_balance_insert",
- "INSERT INTO auditor_wire_fee_balance"
- "(master_pub"
- ",wire_fee_balance"
- ") VALUES ($1,$2)");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_wire_fee_balance_insert",
- params);
-}
diff --git a/src/auditordb/pg_insert_wire_fee_summary.h b/src/auditordb/pg_insert_wire_fee_summary.h
deleted file mode 100644
index 9c969fb65..000000000
--- a/src/auditordb/pg_insert_wire_fee_summary.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_insert_wire_fee_summary.h
- * @brief implementation of the insert_wire_fee_summary function
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_WIRE_FEE_SUMMARY_H
-#define PG_INSERT_WIRE_FEE_SUMMARY_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Insert information about exchange's wire fee balance. There must not be an
- * existing record for the same @a master_pub.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @param wire_fee_balance amount the exchange gained in wire fees
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_insert_wire_fee_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *wire_fee_balance);
-
-#endif
diff --git a/src/auditordb/pg_list_exchanges.c b/src/auditordb/pg_list_exchanges.c
deleted file mode 100644
index a455ee32a..000000000
--- a/src/auditordb/pg_list_exchanges.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_list_exchanges.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_list_exchanges.h"
-#include "pg_helper.h"
-
-
-/**
- * Closure for #exchange_info_cb().
- */
-struct ExchangeInfoContext
-{
-
- /**
- * Function to call for each exchange.
- */
- TALER_AUDITORDB_ExchangeCallback cb;
-
- /**
- * Closure for @e cb
- */
- void *cb_cls;
-
- /**
- * Query status to return.
- */
- enum GNUNET_DB_QueryStatus qs;
-};
-
-
-/**
- * Helper function for #TAH_PG_list_exchanges().
- * To be called with the results of a SELECT statement
- * that has returned @a num_results results.
- *
- * @param cls closure of type `struct ExchangeInfoContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-exchange_info_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct ExchangeInfoContext *eic = cls;
-
- for (unsigned int i = 0; i < num_results; i++)
- {
- struct TALER_MasterPublicKeyP master_pub;
- char *exchange_url;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("master_pub", &master_pub),
- GNUNET_PQ_result_spec_string ("exchange_url", &exchange_url),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- eic->qs = GNUNET_DB_STATUS_HARD_ERROR;
- return;
- }
- eic->qs = i + 1;
- eic->cb (eic->cb_cls,
- &master_pub,
- exchange_url);
- GNUNET_free (exchange_url);
- }
-}
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_list_exchanges (void *cls,
- TALER_AUDITORDB_ExchangeCallback cb,
- void *cb_cls)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_end
- };
- struct ExchangeInfoContext eic = {
- .cb = cb,
- .cb_cls = cb_cls
- };
- enum GNUNET_DB_QueryStatus qs;
- PREPARE (pg,
- "auditor_list_exchanges",
- "SELECT"
- " master_pub"
- ",exchange_url"
- " FROM auditor_exchanges");
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- "auditor_list_exchanges",
- params,
- &exchange_info_cb,
- &eic);
- if (qs > 0)
- return eic.qs;
- GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
- return qs;
-}
diff --git a/src/auditordb/pg_list_exchanges.h b/src/auditordb/pg_list_exchanges.h
deleted file mode 100644
index 4396603ee..000000000
--- a/src/auditordb/pg_list_exchanges.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_list_exchanges.h
- * @brief implementation of the list_exchanges function
- * @author Christian Grothoff
- */
-#ifndef PG_LIST_EXCHANGES_H
-#define PG_LIST_EXCHANGES_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Obtain information about exchanges this auditor is auditing.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param cb function to call with the results
- * @param cb_cls closure for @a cb
- * @return query result status
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_list_exchanges (void *cls,
- TALER_AUDITORDB_ExchangeCallback cb,
- void *cb_cls);
-
-
-#endif
diff --git a/src/auditordb/pg_select_historic_denom_revenue.c b/src/auditordb/pg_select_historic_denom_revenue.c
index 6005b915f..aa44625e7 100644
--- a/src/auditordb/pg_select_historic_denom_revenue.c
+++ b/src/auditordb/pg_select_historic_denom_revenue.c
@@ -113,13 +113,11 @@ historic_denom_revenue_cb (void *cls,
enum GNUNET_DB_QueryStatus
TAH_PG_select_historic_denom_revenue (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb,
void *cb_cls)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
struct HistoricDenomRevenueContext hrc = {
@@ -136,8 +134,7 @@ TAH_PG_select_historic_denom_revenue (
",revenue_timestamp"
",revenue_balance"
",loss_balance"
- " FROM auditor_historic_denomination_revenue"
- " WHERE master_pub=$1;");
+ " FROM auditor_historic_denomination_revenue;");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"auditor_historic_denomination_revenue_select",
params,
diff --git a/src/auditordb/pg_select_historic_denom_revenue.h b/src/auditordb/pg_select_historic_denom_revenue.h
index 68afcd019..25a68dacb 100644
--- a/src/auditordb/pg_select_historic_denom_revenue.h
+++ b/src/auditordb/pg_select_historic_denom_revenue.h
@@ -28,10 +28,8 @@
/**
* Obtain all of the historic denomination key revenue
- * of the given @a master_pub.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
* @param cb function to call with the results
* @param cb_cls closure for @a cb
* @return transaction status code
@@ -39,7 +37,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_select_historic_denom_revenue (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb,
void *cb_cls);
diff --git a/src/auditordb/pg_select_historic_reserve_revenue.c b/src/auditordb/pg_select_historic_reserve_revenue.c
index a05cc8a1f..877c3e2d7 100644
--- a/src/auditordb/pg_select_historic_reserve_revenue.c
+++ b/src/auditordb/pg_select_historic_reserve_revenue.c
@@ -108,13 +108,11 @@ historic_reserve_revenue_cb (void *cls,
enum GNUNET_DB_QueryStatus
TAH_PG_select_historic_reserve_revenue (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb,
void *cb_cls)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
enum GNUNET_DB_QueryStatus qs;
@@ -130,8 +128,7 @@ TAH_PG_select_historic_reserve_revenue (
" start_date"
",end_date"
",reserve_profits"
- " FROM auditor_historic_reserve_summary"
- " WHERE master_pub=$1;");
+ " FROM auditor_historic_reserve_summary");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"auditor_historic_reserve_summary_select",
params,
diff --git a/src/auditordb/pg_select_historic_reserve_revenue.h b/src/auditordb/pg_select_historic_reserve_revenue.h
index 87a6b06a1..b067c8917 100644
--- a/src/auditordb/pg_select_historic_reserve_revenue.h
+++ b/src/auditordb/pg_select_historic_reserve_revenue.h
@@ -29,7 +29,6 @@
* Return information about an exchange's historic revenue from reserves.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
* @param cb function to call with results
* @param cb_cls closure for @a cb
* @return transaction status code
@@ -37,7 +36,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_select_historic_reserve_revenue (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb,
void *cb_cls);
diff --git a/src/auditordb/pg_select_pending_deposits.c b/src/auditordb/pg_select_pending_deposits.c
index 3a46770a2..1190fb132 100644
--- a/src/auditordb/pg_select_pending_deposits.c
+++ b/src/auditordb/pg_select_pending_deposits.c
@@ -111,7 +111,6 @@ wire_missing_cb (void *cls,
enum GNUNET_DB_QueryStatus
TAH_PG_select_pending_deposits (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
struct GNUNET_TIME_Absolute deadline,
TALER_AUDITORDB_WireMissingCallback cb,
void *cb_cls)
diff --git a/src/auditordb/pg_select_pending_deposits.h b/src/auditordb/pg_select_pending_deposits.h
index 7e085304d..e165098c5 100644
--- a/src/auditordb/pg_select_pending_deposits.h
+++ b/src/auditordb/pg_select_pending_deposits.h
@@ -31,7 +31,6 @@
* seen the required wire transfer.
*
* @param cls closure
- * @param master_pub master public key of the exchange
* @param deadline only return up to this deadline
* @param cb function to call on each entry
* @param cb_cls closure for @a cb
@@ -40,7 +39,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_select_pending_deposits (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
struct GNUNET_TIME_Absolute deadline,
TALER_AUDITORDB_WireMissingCallback cb,
void *cb_cls);
diff --git a/src/auditordb/pg_select_purse_expired.c b/src/auditordb/pg_select_purse_expired.c
index 95ba5ff37..77c6d3b26 100644
--- a/src/auditordb/pg_select_purse_expired.c
+++ b/src/auditordb/pg_select_purse_expired.c
@@ -109,7 +109,6 @@ purse_expired_cb (void *cls,
enum GNUNET_DB_QueryStatus
TAH_PG_select_purse_expired (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_ExpiredPurseCallback cb,
void *cb_cls)
{
@@ -117,7 +116,6 @@ TAH_PG_select_purse_expired (
struct GNUNET_TIME_Timestamp now
= GNUNET_TIME_timestamp_get ();
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_end
};
@@ -135,8 +133,7 @@ TAH_PG_select_purse_expired (
",expiration_date"
",balance"
" FROM auditor_purses"
- " WHERE master_pub=$1"
- " AND expiration_date<$2;");
+ " AND expiration_date<$1;");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"auditor_select_expired_purses",
params,
diff --git a/src/auditordb/pg_select_purse_expired.h b/src/auditordb/pg_select_purse_expired.h
index 9f501408a..36d81285c 100644
--- a/src/auditordb/pg_select_purse_expired.h
+++ b/src/auditordb/pg_select_purse_expired.h
@@ -30,7 +30,6 @@
* Get information about expired purses.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
* @param cb function to call on expired purses
* @param cb_cls closure for @a cb
* @return transaction status code
@@ -38,7 +37,6 @@
enum GNUNET_DB_QueryStatus
TAH_PG_select_purse_expired (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_ExpiredPurseCallback cb,
void *cb_cls);
diff --git a/src/auditordb/pg_template.c b/src/auditordb/pg_template.c
index ab1f968e6..e44fdab60 100644
--- a/src/auditordb/pg_template.c
+++ b/src/auditordb/pg_template.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2023 Taler Systems SA
+ Copyright (C) 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
diff --git a/src/auditordb/pg_template.h b/src/auditordb/pg_template.h
index 3910115b1..911faf107 100644
--- a/src/auditordb/pg_template.h
+++ b/src/auditordb/pg_template.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2023 Taler Systems SA
+ Copyright (C) 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
diff --git a/src/auditordb/pg_update_auditor_progress.c b/src/auditordb/pg_update_auditor_progress.c
new file mode 100644
index 000000000..b30be18bd
--- /dev/null
+++ b/src/auditordb/pg_update_auditor_progress.c
@@ -0,0 +1,99 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file pg_update_auditor_progress.c
+ * @brief Low-level (statement-level) Postgres database access for the exchange
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_update_auditor_progress.h"
+#include "pg_helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TAH_PG_update_auditor_progress (
+ void *cls,
+ const char *progress_key,
+ uint64_t progress_offset,
+ ...)
+{
+ struct PostgresClosure *pg = cls;
+ unsigned int cnt = 1;
+ va_list ap;
+
+ va_start (ap,
+ progress_offset);
+ while (NULL != va_arg (ap,
+ const char *))
+ {
+ cnt++;
+ (void) va_arg (ap,
+ uint64_t);
+ }
+ va_end (ap);
+ {
+ const char *keys[cnt];
+ uint64_t offsets[cnt];
+ unsigned int off = 1;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_array_ptrs_string (cnt,
+ keys,
+ pg->conn),
+ GNUNET_PQ_query_param_array_uint64 (cnt,
+ offsets,
+ pg->conn),
+ GNUNET_PQ_query_param_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ keys[0] = progress_key;
+ offsets[0] = progress_offset;
+
+ va_start (ap,
+ progress_offset);
+ while (off < cnt)
+ {
+ keys[off] = va_arg (ap,
+ const char *);
+ offsets[off] = va_arg (ap,
+ uint64_t);
+ off++;
+ }
+ GNUNET_assert (NULL == va_arg (ap,
+ const char *));
+ va_end (ap);
+
+ PREPARE (pg,
+ "auditor_progress_update",
+ "UPDATE auditor_progress"
+ " SET progress_offset=data.off"
+ " FROM ("
+ " SELECT *"
+ " FROM UNNEST (CAST($1 AS TEXT[]),"
+ " CAST($2 AS INT8[]))"
+ " AS t(key,off)"
+ " ) AS data"
+ " WHERE auditor_progress.progress_key=data.key;");
+ qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "auditor_progress_update",
+ params);
+ GNUNET_PQ_cleanup_query_params_closures (params);
+ return qs;
+ }
+}
diff --git a/src/auditordb/pg_update_wire_auditor_progress.h b/src/auditordb/pg_update_auditor_progress.h
index e46c6119b..e8de58161 100644
--- a/src/auditordb/pg_update_wire_auditor_progress.h
+++ b/src/auditordb/pg_update_auditor_progress.h
@@ -14,12 +14,12 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file pg_update_wire_auditor_progress.h
- * @brief implementation of the update_wire_auditor_progress function
+ * @file pg_update_auditor_progress.h
+ * @brief implementation of the update_auditor_progress function
* @author Christian Grothoff
*/
-#ifndef PG_UPDATE_WIRE_AUDITOR_PROGRESS_H
-#define PG_UPDATE_WIRE_AUDITOR_PROGRESS_H
+#ifndef PG_UPDATE_AUDITOR_PROGRESS_H
+#define PG_UPDATE_AUDITOR_PROGRESS_H
#include "taler_util.h"
#include "taler_json_lib.h"
@@ -31,15 +31,16 @@
* must be an existing record for the exchange.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param pp where is the auditor in processing
+ * @param progress_key name of the progress indicator
+ * @param progress_offset offset until which we have made progress
+ * @param ... NULL terminated list of additional key-value pairs to update
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
-TAH_PG_update_wire_auditor_progress (
+TAH_PG_update_auditor_progress (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_WireProgressPoint *pp);
-
+ const char *progress_key,
+ uint64_t progress_offset,
+ ...);
#endif
diff --git a/src/auditordb/pg_update_auditor_progress_aggregation.c b/src/auditordb/pg_update_auditor_progress_aggregation.c
deleted file mode 100644
index 24404e4aa..000000000
--- a/src/auditordb/pg_update_auditor_progress_aggregation.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_aggregation.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_auditor_progress_aggregation.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_aggregation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointAggregation *ppa)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_progress_update_aggregation",
- "UPDATE auditor_progress_aggregation SET "
- " last_wire_out_serial_id=$1"
- " WHERE master_pub=$2");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_update_aggregation",
- params);
-}
diff --git a/src/auditordb/pg_update_auditor_progress_aggregation.h b/src/auditordb/pg_update_auditor_progress_aggregation.h
deleted file mode 100644
index f8917ca7c..000000000
--- a/src/auditordb/pg_update_auditor_progress_aggregation.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_aggregation.h
- * @brief implementation of the update_auditor_progress_aggregation function
- * @author Christian Grothoff
- */
-#ifndef PG_UPDATE_AUDITOR_PROGRESS_AGGREGATION_H
-#define PG_UPDATE_AUDITOR_PROGRESS_AGGREGATION_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Update information about the progress of the auditor. There
- * must be an existing record for the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppa where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_aggregation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
-
-#endif
diff --git a/src/auditordb/pg_update_auditor_progress_coin.c b/src/auditordb/pg_update_auditor_progress_coin.c
deleted file mode 100644
index 1d7e01525..000000000
--- a/src/auditordb/pg_update_auditor_progress_coin.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_coin.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_auditor_progress_coin.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_coin (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointCoin *ppc)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_recoup_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_recoup_refresh_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_purse_deposits_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppc->last_purse_refunds_serial_id),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_progress_update_coin",
- "UPDATE auditor_progress_coin SET "
- " last_withdraw_serial_id=$1"
- ",last_deposit_serial_id=$2"
- ",last_melt_serial_id=$3"
- ",last_refund_serial_id=$4"
- ",last_recoup_serial_id=$5"
- ",last_recoup_refresh_serial_id=$6"
- ",last_purse_deposits_serial_id=$7"
- ",last_purse_decision_serial_id=$8"
- " WHERE master_pub=$9");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_update_coin",
- params);
-}
diff --git a/src/auditordb/pg_update_auditor_progress_coin.h b/src/auditordb/pg_update_auditor_progress_coin.h
deleted file mode 100644
index 0ce7f1495..000000000
--- a/src/auditordb/pg_update_auditor_progress_coin.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_coin.h
- * @brief implementation of the update_auditor_progress_coin function
- * @author Christian Grothoff
- */
-#ifndef PG_UPDATE_AUDITOR_PROGRESS_COIN_H
-#define PG_UPDATE_AUDITOR_PROGRESS_COIN_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Update information about the progress of the auditor. There
- * must be an existing record for the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppc where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_coin (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointCoin *ppc);
-
-#endif
diff --git a/src/auditordb/pg_update_auditor_progress_deposit_confirmation.c b/src/auditordb/pg_update_auditor_progress_deposit_confirmation.c
deleted file mode 100644
index 9a244f5f1..000000000
--- a/src/auditordb/pg_update_auditor_progress_deposit_confirmation.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_deposit_confirmation.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_auditor_progress_deposit_confirmation.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_deposit_confirmation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&ppdc->last_deposit_confirmation_serial_id),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_progress_update_deposit_confirmation",
- "UPDATE auditor_progress_deposit_confirmation SET "
- " last_deposit_confirmation_serial_id=$1"
- " WHERE master_pub=$2");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_update_deposit_confirmation",
- params);
-}
diff --git a/src/auditordb/pg_update_auditor_progress_deposit_confirmation.h b/src/auditordb/pg_update_auditor_progress_deposit_confirmation.h
deleted file mode 100644
index 7927e485b..000000000
--- a/src/auditordb/pg_update_auditor_progress_deposit_confirmation.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_deposit_confirmation.h
- * @brief implementation of the update_auditor_progress_deposit_confirmation function
- * @author Christian Grothoff
- */
-#ifndef PG_UPDATE_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
-#define PG_UPDATE_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Update information about the progress of the auditor. There
- * must be an existing record for the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppdc where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_deposit_confirmation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc);
-
-
-#endif
diff --git a/src/auditordb/pg_update_auditor_progress_purse.c b/src/auditordb/pg_update_auditor_progress_purse.c
deleted file mode 100644
index c8fb64660..000000000
--- a/src/auditordb/pg_update_auditor_progress_purse.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_purse.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_auditor_progress_purse.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_purse (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointPurse *ppp)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&ppp->last_purse_request_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppp->last_purse_decision_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppp->last_purse_merge_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppp->last_account_merge_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppp->last_purse_deposits_serial_id),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_progress_update_purse",
- "UPDATE auditor_progress_purse SET "
- " last_purse_request_serial_id=$1"
- ",last_purse_decision_serial_id=$2"
- ",last_purse_merges_serial_id=$3"
- ",last_account_merges_serial_id=$4"
- ",last_purse_deposits_serial_id=$5"
- " WHERE master_pub=$6");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_update_purse",
- params);
-}
diff --git a/src/auditordb/pg_update_auditor_progress_purse.h b/src/auditordb/pg_update_auditor_progress_purse.h
deleted file mode 100644
index 12a643e52..000000000
--- a/src/auditordb/pg_update_auditor_progress_purse.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_purse.h
- * @brief implementation of the update_auditor_progress_purse function
- * @author Christian Grothoff
- */
-#ifndef PG_UPDATE_AUDITOR_PROGRESS_PURSE_H
-#define PG_UPDATE_AUDITOR_PROGRESS_PURSE_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Update information about the progress of the auditor. There
- * must be an existing record for the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppp where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_purse (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointPurse *ppp);
-
-#endif
diff --git a/src/auditordb/pg_update_auditor_progress_reserve.c b/src/auditordb/pg_update_auditor_progress_reserve.c
deleted file mode 100644
index a8ef39286..000000000
--- a/src/auditordb/pg_update_auditor_progress_reserve.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_reserve.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_auditor_progress_reserve.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_reserve (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointReserve *ppr)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_out_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_recoup_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_open_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_close_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_purse_decisions_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_account_merges_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_history_requests_serial_id),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_progress_update_reserve",
- "UPDATE auditor_progress_reserve SET "
- " last_reserve_in_serial_id=$1"
- ",last_reserve_out_serial_id=$2"
- ",last_reserve_recoup_serial_id=$3"
- ",last_reserve_open_serial_id=$4"
- ",last_reserve_close_serial_id=$5"
- ",last_purse_decision_serial_id=$6"
- ",last_account_merges_serial_id=$7"
- ",last_history_requests_serial_id=$8"
- " WHERE master_pub=$9");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_progress_update_reserve",
- params);
-}
diff --git a/src/auditordb/pg_update_auditor_progress_reserve.h b/src/auditordb/pg_update_auditor_progress_reserve.h
deleted file mode 100644
index 3feaa0dc4..000000000
--- a/src/auditordb/pg_update_auditor_progress_reserve.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_auditor_progress_reserve.h
- * @brief implementation of the update_auditor_progress_reserve function
- * @author Christian Grothoff
- */
-#ifndef PG_UPDATE_AUDITOR_PROGRESS_RESERVE_H
-#define PG_UPDATE_AUDITOR_PROGRESS_RESERVE_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-/**
- * Update information about the progress of the auditor. There
- * must be an existing record for the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param ppr where is the auditor in processing
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_auditor_progress_reserve (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointReserve *ppr);
-
-#endif
diff --git a/src/auditordb/pg_update_balance.c b/src/auditordb/pg_update_balance.c
new file mode 100644
index 000000000..eff03056b
--- /dev/null
+++ b/src/auditordb/pg_update_balance.c
@@ -0,0 +1,100 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2023 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file auditordb/pg_update_balance.c
+ * @brief Implementation of the update_balance function for Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_update_balance.h"
+#include "pg_helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TAH_PG_update_balance (
+ void *cls,
+ const char *balance_key,
+ const struct TALER_Amount *balance_amount,
+ ...)
+{
+ struct PostgresClosure *pg = cls;
+ unsigned int cnt = 1;
+ va_list ap;
+
+ va_start (ap,
+ balance_amount);
+ while (NULL != va_arg (ap,
+ const char *))
+ {
+ cnt++;
+ (void) va_arg (ap,
+ const struct TALER_Amount *);
+ }
+ va_end (ap);
+ {
+ const char *keys[cnt];
+ struct TALER_Amount amounts[cnt];
+ unsigned int off = 1;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_array_ptrs_string (cnt,
+ keys,
+ pg->conn),
+ TALER_PQ_query_param_array_amount (cnt,
+ amounts,
+ pg->conn),
+ GNUNET_PQ_query_param_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ keys[0] = balance_key;
+ amounts[0] = *balance_amount;
+
+ va_start (ap,
+ balance_amount);
+ while (off < cnt)
+ {
+ keys[off] = va_arg (ap,
+ const char *);
+ amounts[off] = *va_arg (ap,
+ const struct TALER_Amount *);
+ off++;
+ }
+ GNUNET_assert (NULL == va_arg (ap,
+ const char *));
+ va_end (ap);
+
+ PREPARE (pg,
+ "auditor_balance_update",
+ "UPDATE auditor_balances"
+ " SET balance_value.val=data.val"
+ " ,balance_value.frac=data.frac"
+ " FROM ("
+ " SELECT *"
+ " FROM UNNEST (CAST($1 AS TEXT[]),"
+ " CAST($2 AS taler_amount[]))"
+ " AS t(key,val,frac)"
+ " ) AS data"
+ " WHERE auditor_balances.balance_key=data.key;");
+ qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "auditor_balance_update",
+ params);
+ GNUNET_PQ_cleanup_query_params_closures (params);
+ return qs;
+ }
+}
diff --git a/src/auditordb/pg_update_purse_summary.h b/src/auditordb/pg_update_balance.h
index b613f7c0d..1f67c8551 100644
--- a/src/auditordb/pg_update_purse_summary.h
+++ b/src/auditordb/pg_update_balance.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -14,12 +14,12 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file auditordb/pg_update_purse_summary.h
- * @brief implementation of the update_purse_summary function for Postgres
+ * @file auditordb/pg_update_balance.h
+ * @brief implementation of the update_balance function for Postgres
* @author Christian Grothoff
*/
-#ifndef PG_UPDATE_PURSE_SUMMARY_H
-#define PG_UPDATE_PURSE_SUMMARY_H
+#ifndef PG_UPDATE_BALANCE_H
+#define PG_UPDATE_BALANCE_H
#include "taler_util.h"
#include "taler_json_lib.h"
@@ -27,19 +27,21 @@
/**
- * Update information about all purses. Destructively updates an
+ * Insert information about a balance tracked by the auditor. Destructively updates an
* existing record, which must already exist.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @param sum purse balances summary to store
+ * @param balance_key key of the blance to store
+ * @param balance_value value to store
+ * @param ... NULL terminated list of additional key-value pairs to update
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
-TAH_PG_update_purse_summary (
+TAH_PG_update_balance (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_PurseBalance *sum);
+ const char *balance_key,
+ const struct TALER_Amount *balance_amount,
+ ...);
#endif
diff --git a/src/auditordb/pg_update_balance_summary.c b/src/auditordb/pg_update_balance_summary.c
deleted file mode 100644
index d96980791..000000000
--- a/src/auditordb/pg_update_balance_summary.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_balance_summary.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_balance_summary.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_balance_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_GlobalCoinBalance *dfb)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->total_escrowed),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->deposit_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->melt_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->refund_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->purse_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->open_deposit_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->risk),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->loss),
- TALER_PQ_query_param_amount (pg->conn,
- &dfb->irregular_loss),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_balance_summary_update",
- "UPDATE auditor_balance_summary SET"
- " denom_balance=$1"
- ",deposit_fee_balance=$2"
- ",melt_fee_balance=$3"
- ",refund_fee_balance=$4"
- ",purse_fee_balance=$5"
- ",open_deposit_fee_balance=$6"
- ",risk=$7"
- ",loss=$8"
- ",irregular_loss=$9"
- " WHERE master_pub=$10;");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_balance_summary_update",
- params);
-}
diff --git a/src/auditordb/pg_update_balance_summary.h b/src/auditordb/pg_update_balance_summary.h
deleted file mode 100644
index dbb721ecc..000000000
--- a/src/auditordb/pg_update_balance_summary.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_balance_summary.h
- * @brief implementation of the update_balance_summary function
- * @author Christian Grothoff
- */
-#ifndef PG_UPDATE_BALANCE_SUMMARY_H
-#define PG_UPDATE_BALANCE_SUMMARY_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Update information about an exchange's denomination balances. There
- * must be an existing record for the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param dfb denomination balance data to store
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_balance_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_GlobalCoinBalance *dfb);
-
-#endif
diff --git a/src/auditordb/pg_update_predicted_result.c b/src/auditordb/pg_update_predicted_result.c
deleted file mode 100644
index fd82ecc59..000000000
--- a/src/auditordb/pg_update_predicted_result.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_predicted_result.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_predicted_result.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_predicted_result (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *balance,
- const struct TALER_Amount *drained)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- TALER_PQ_query_param_amount (pg->conn,
- balance),
- TALER_PQ_query_param_amount (pg->conn,
- drained),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_predicted_result_update",
- "UPDATE auditor_predicted_result SET"
- " balance=$1"
- ",drained=$2"
- " WHERE master_pub=$3;");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_predicted_result_update",
- params);
-}
diff --git a/src/auditordb/pg_update_predicted_result.h b/src/auditordb/pg_update_predicted_result.h
deleted file mode 100644
index e70d079d6..000000000
--- a/src/auditordb/pg_update_predicted_result.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_predicted_result.h
- * @brief implementation of the update_predicted_result function
- * @author Christian Grothoff
- */
-#ifndef PG_UPDATE_PREDICTED_RESULT_H
-#define PG_UPDATE_PREDICTED_RESULT_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Update information about an exchange's predicted balance. There
- * must be an existing record for the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param balance what the bank account balance of the exchange should show
- * @param drained amount that was drained in profits
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_predicted_result (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *balance,
- const struct TALER_Amount *drained);
-
-#endif
diff --git a/src/auditordb/pg_update_purse_info.c b/src/auditordb/pg_update_purse_info.c
index 5e2d65bca..66dfd490e 100644
--- a/src/auditordb/pg_update_purse_info.c
+++ b/src/auditordb/pg_update_purse_info.c
@@ -30,14 +30,12 @@ enum GNUNET_DB_QueryStatus
TAH_PG_update_purse_info (
void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_Amount *balance)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (purse_pub),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
TALER_PQ_query_param_amount (pg->conn,
balance),
GNUNET_PQ_query_param_end
@@ -45,10 +43,9 @@ TAH_PG_update_purse_info (
PREPARE (pg,
"auditor_purses_update",
- "UPDATE auditor_purses SET "
- " balance=$3"
- " WHERE purse_pub=$1"
- " AND master_pub=$2;");
+ "UPDATE auditor_purses"
+ " SET balance=$2"
+ " WHERE purse_pub=$1");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_purses_update",
params);
diff --git a/src/auditordb/pg_update_purse_info.h b/src/auditordb/pg_update_purse_info.h
index 0b1f71d31..ac37be7b4 100644
--- a/src/auditordb/pg_update_purse_info.h
+++ b/src/auditordb/pg_update_purse_info.h
@@ -32,7 +32,6 @@
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param purse_pub public key of the purse
- * @param master_pub master public key of the exchange
* @param balance new balance for the purse
* @return transaction status code
*/
@@ -40,7 +39,6 @@ enum GNUNET_DB_QueryStatus
TAH_PG_update_purse_info (
void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_Amount *balance);
diff --git a/src/auditordb/pg_update_purse_summary.c b/src/auditordb/pg_update_purse_summary.c
deleted file mode 100644
index 626151a26..000000000
--- a/src/auditordb/pg_update_purse_summary.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file auditordb/pg_update_purse_summary.c
- * @brief Implementation of the update_purse_summary function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_purse_summary.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_purse_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_PurseBalance *sum)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- TALER_PQ_query_param_amount (pg->conn,
- &sum->balance),
- GNUNET_PQ_query_param_uint64 (&sum->open_purses),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_purse_summary_update",
- "UPDATE auditor_purse_summary SET"
- " balance=$2"
- ",open_purses=$3"
- " WHERE master_pub=$1;");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_purse_summary_update",
- params);
-}
diff --git a/src/auditordb/pg_update_reserve_info.c b/src/auditordb/pg_update_reserve_info.c
index b851feda9..2d38a2b0e 100644
--- a/src/auditordb/pg_update_reserve_info.c
+++ b/src/auditordb/pg_update_reserve_info.c
@@ -30,7 +30,6 @@ enum GNUNET_DB_QueryStatus
TAH_PG_update_reserve_info (
void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
struct GNUNET_TIME_Timestamp expiration_date)
{
@@ -50,12 +49,11 @@ TAH_PG_update_reserve_info (
&rfb->history_fee_balance),
GNUNET_PQ_query_param_timestamp (&expiration_date),
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
- "auditor_reserves_update",
+ "auditor_update_reserve_info",
"UPDATE auditor_reserves SET"
" reserve_balance=$1"
",reserve_loss=$2"
@@ -64,9 +62,8 @@ TAH_PG_update_reserve_info (
",open_fee_balance=$5"
",history_fee_balance=$6"
",expiration_date=$7"
- " WHERE reserve_pub=$8"
- " AND master_pub=$9;");
+ " WHERE reserve_pub=$8");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_reserves_update",
+ "auditor_update_reserve_info",
params);
}
diff --git a/src/auditordb/pg_update_reserve_info.h b/src/auditordb/pg_update_reserve_info.h
index 1c7707f07..25f43476a 100644
--- a/src/auditordb/pg_update_reserve_info.h
+++ b/src/auditordb/pg_update_reserve_info.h
@@ -32,7 +32,6 @@
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param reserve_pub public key of the reserve
- * @param master_pub master public key of the exchange
* @param rfb amounts for the reserve
* @param expiration_date expiration date of the reserve
* @return transaction status code
@@ -41,7 +40,6 @@ enum GNUNET_DB_QueryStatus
TAH_PG_update_reserve_info (
void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
struct GNUNET_TIME_Timestamp expiration_date);
diff --git a/src/auditordb/pg_update_reserve_summary.c b/src/auditordb/pg_update_reserve_summary.c
deleted file mode 100644
index 58da3048e..000000000
--- a/src/auditordb/pg_update_reserve_summary.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_reserve_summary.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_reserve_summary.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_reserve_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ReserveFeeBalance *rfb)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->reserve_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->reserve_loss),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->withdraw_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->close_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->purse_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->open_fee_balance),
- TALER_PQ_query_param_amount (pg->conn,
- &rfb->history_fee_balance),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_reserve_balance_update",
- "UPDATE auditor_reserve_balance SET"
- " reserve_balance=$1"
- ",reserve_loss=$2"
- ",withdraw_fee_balance=$3"
- ",close_fee_balance=$4"
- ",purse_fee_balance=$5"
- ",open_fee_balance=$6"
- ",history_fee_balance=$7"
- " WHERE master_pub=$8;");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_reserve_balance_update",
- params);
-}
diff --git a/src/auditordb/pg_update_reserve_summary.h b/src/auditordb/pg_update_reserve_summary.h
deleted file mode 100644
index 50d730750..000000000
--- a/src/auditordb/pg_update_reserve_summary.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_reserve_summary.h
- * @brief implementation of the update_reserve_summary function
- * @author Christian Grothoff
- */
-#ifndef PG_UPDATE_RESERVE_SUMMARY_H
-#define PG_UPDATE_RESERVE_SUMMARY_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Update information about all reserves. Destructively updates an
- * existing record, which must already exist.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
- * @param rfb balances to be stored for the reserve
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_reserve_summary (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
-
-
-#endif
diff --git a/src/auditordb/pg_update_wire_auditor_account_progress.c b/src/auditordb/pg_update_wire_auditor_account_progress.c
deleted file mode 100644
index ff01be09c..000000000
--- a/src/auditordb/pg_update_wire_auditor_account_progress.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_wire_auditor_account_progress.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_wire_auditor_account_progress.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_wire_auditor_account_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *account_name,
- const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
- GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),
- GNUNET_PQ_query_param_uint64 (&bapp->in_wire_off),
- GNUNET_PQ_query_param_uint64 (&bapp->out_wire_off),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_string (account_name),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "wire_auditor_account_progress_update",
- "UPDATE wire_auditor_account_progress SET "
- " last_wire_reserve_in_serial_id=$1"
- ",last_wire_wire_out_serial_id=$2"
- ",wire_in_off=$3"
- ",wire_out_off=$4"
- " WHERE master_pub=$5 AND account_name=$6");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "wire_auditor_account_progress_update",
- params);
-}
diff --git a/src/auditordb/pg_update_wire_auditor_account_progress.h b/src/auditordb/pg_update_wire_auditor_account_progress.h
deleted file mode 100644
index 03f5701c0..000000000
--- a/src/auditordb/pg_update_wire_auditor_account_progress.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_wire_auditor_account_progress.h
- * @brief implementation of the update_wire_auditor_account_progress function
- * @author Christian Grothoff
- */
-#ifndef PG_UPDATE_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
-#define PG_UPDATE_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_auditordb_plugin.h"
-
-
-/**
- * Update information about the progress of the auditor. There
- * must be an existing record for the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master key of the exchange
- * @param account_name name of the wire account we are auditing
- * @param pp where is the auditor in processing
- * @param bapp progress in wire transaction histories
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_wire_auditor_account_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *account_name,
- const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp);
-
-
-#endif
diff --git a/src/auditordb/pg_update_wire_auditor_progress.c b/src/auditordb/pg_update_wire_auditor_progress.c
deleted file mode 100644
index a4b991543..000000000
--- a/src/auditordb/pg_update_wire_auditor_progress.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022-2023 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file pg_update_wire_auditor_progress.c
- * @brief Low-level (statement-level) Postgres database access for the exchange
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_update_wire_auditor_progress.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_update_wire_auditor_progress (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_WireProgressPoint *pp)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&pp->last_reserve_close_uuid),
- GNUNET_PQ_query_param_uint64 (&pp->last_batch_deposit_uuid),
- GNUNET_PQ_query_param_uint64 (&pp->last_aggregation_serial),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "wire_auditor_progress_update",
- "UPDATE wire_auditor_progress SET "
- " last_reserve_close_uuid=$1"
- ",last_batch_deposit_uuid=$2"
- ",last_aggregation_serial=$3"
- " WHERE master_pub=$4");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "wire_auditor_progress_update",
- params);
-}
diff --git a/src/auditordb/pg_update_wire_fee_summary.c b/src/auditordb/pg_update_wire_fee_summary.c
index d57467a09..192612f17 100644
--- a/src/auditordb/pg_update_wire_fee_summary.c
+++ b/src/auditordb/pg_update_wire_fee_summary.c
@@ -29,22 +29,19 @@
enum GNUNET_DB_QueryStatus
TAH_PG_update_wire_fee_summary (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_Amount *wire_fee_balance)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
TALER_PQ_query_param_amount (pg->conn,
wire_fee_balance),
- GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
"auditor_wire_fee_balance_update",
"UPDATE auditor_wire_fee_balance SET"
- " wire_fee_balance=$1"
- " WHERE master_pub=$2;");
+ " wire_fee_balance=$1");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_wire_fee_balance_update",
params);
diff --git a/src/auditordb/pg_update_wire_fee_summary.h b/src/auditordb/pg_update_wire_fee_summary.h
index 5a1760eeb..a004a2db4 100644
--- a/src/auditordb/pg_update_wire_fee_summary.h
+++ b/src/auditordb/pg_update_wire_fee_summary.h
@@ -31,14 +31,12 @@
* existing record, which must already exist.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param master_pub master public key of the exchange
* @param wire_fee_balance amount the exchange gained in wire fees
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
TAH_PG_update_wire_fee_summary (
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_Amount *wire_fee_balance);
#endif
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index 2366eb69f..f5c405d8d 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2023 Taler Systems SA
+ Copyright (C) 2014-2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -23,82 +23,40 @@
#include "taler_pq_lib.h"
#include <pthread.h>
#include <libpq-fe.h>
-#include "pg_helper.h"
-#include "pg_insert_auditor_progress_reserve.h"
-#include "pg_update_auditor_progress_reserve.h"
-#include "pg_get_auditor_progress_reserve.h"
-#include "pg_insert_auditor_progress_purse.h"
-#include "pg_update_auditor_progress_purse.h"
-#include "pg_get_auditor_progress_purse.h"
-#include "pg_insert_auditor_progress_aggregation.h"
-#include "pg_update_auditor_progress_aggregation.h"
-#include "pg_get_auditor_progress_aggregation.h"
-#include "pg_insert_auditor_progress_deposit_confirmation.h"
-#include "pg_update_auditor_progress_deposit_confirmation.h"
-#include "pg_get_auditor_progress_deposit_confirmation.h"
-#include "pg_select_pending_deposits.h"
+#include "pg_delete_deposit_confirmations.h"
#include "pg_delete_pending_deposit.h"
-#include "pg_insert_pending_deposit.h"
-#include "pg_insert_auditor_progress_coin.h"
-#include "pg_update_auditor_progress_coin.h"
-#include "pg_get_auditor_progress_coin.h"
-#include "pg_insert_wire_auditor_account_progress.h"
-#include "pg_update_wire_auditor_account_progress.h"
-#include "pg_get_wire_auditor_account_progress.h"
-#include "pg_insert_wire_auditor_progress.h"
-#include "pg_update_wire_auditor_progress.h"
-#include "pg_get_wire_auditor_progress.h"
-#include "pg_insert_reserve_info.h"
-#include "pg_update_reserve_info.h"
+#include "pg_delete_purse_info.h"
+#include "pg_del_denomination_balance.h"
#include "pg_del_reserve_info.h"
+#include "pg_get_auditor_progress.h"
+#include "pg_get_balance.h"
+#include "pg_get_denomination_balance.h"
+#include "pg_get_deposit_confirmations.h"
+#include "pg_get_purse_info.h"
#include "pg_get_reserve_info.h"
-#include "pg_insert_reserve_summary.h"
-#include "pg_update_reserve_summary.h"
-#include "pg_get_reserve_summary.h"
-#include "pg_insert_wire_fee_summary.h"
-#include "pg_update_wire_fee_summary.h"
#include "pg_get_wire_fee_summary.h"
+#include "pg_helper.h"
+#include "pg_insert_auditor_progress.h"
+#include "pg_insert_balance.h"
#include "pg_insert_denomination_balance.h"
-#include "pg_update_denomination_balance.h"
-#include "pg_get_denomination_balance.h"
-#include "pg_insert_balance_summary.h"
-#include "pg_update_balance_summary.h"
-#include "pg_get_balance_summary.h"
-#include "pg_insert_historic_denom_revenue.h"
-#include "pg_select_historic_denom_revenue.h"
-#include "pg_insert_historic_reserve_revenue.h"
-#include "pg_select_historic_reserve_revenue.h"
-#include "pg_insert_predicted_result.h"
-#include "pg_update_predicted_result.h"
-#include "pg_get_predicted_balance.h"
-#include "pg_insert_exchange.h"
-#include "pg_list_exchanges.h"
-#include "pg_delete_exchange.h"
-#include "pg_insert_exchange_signkey.h"
#include "pg_insert_deposit_confirmation.h"
-#include "pg_get_deposit_confirmations.h"
-#include "pg_delete_deposit_confirmations.h"
-#include "pg_insert_auditor_progress_coin.h"
-#include "pg_update_auditor_progress_coin.h"
-#include "pg_get_auditor_progress_coin.h"
-#include "pg_insert_auditor_progress_purse.h"
-#include "pg_update_auditor_progress_purse.h"
-#include "pg_get_auditor_progress_purse.h"
-#include "pg_get_reserve_info.h"
-#include "pg_insert_historic_reserve_revenue.h"
-#include "pg_insert_wire_auditor_progress.h"
-#include "pg_update_wire_auditor_progress.h"
-#include "pg_get_wire_auditor_progress.h"
+#include "pg_insert_exchange_signkey.h"
+#include "pg_insert_historic_denom_revenue.h"
#include "pg_insert_historic_reserve_revenue.h"
-#include "pg_helper.h"
-#include "pg_get_purse_info.h"
-#include "pg_delete_purse_info.h"
-#include "pg_update_purse_info.h"
+#include "pg_insert_pending_deposit.h"
#include "pg_insert_purse_info.h"
-#include "pg_get_purse_summary.h"
+#include "pg_insert_reserve_info.h"
+#include "pg_select_historic_denom_revenue.h"
+#include "pg_select_historic_reserve_revenue.h"
+#include "pg_select_pending_deposits.h"
#include "pg_select_purse_expired.h"
-#include "pg_insert_purse_summary.h"
-#include "pg_update_purse_summary.h"
+#include "pg_update_auditor_progress.h"
+#include "pg_update_balance.h"
+#include "pg_update_denomination_balance.h"
+#include "pg_update_purse_info.h"
+#include "pg_update_reserve_info.h"
+#include "pg_update_wire_fee_summary.h"
+
#define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", \
__VA_ARGS__)
@@ -141,13 +99,31 @@ postgres_drop_tables (void *cls,
* Create the necessary tables if they are not present
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @param support_partitions true to support partitioning
+ * @param num_partitions number of partitions to use
* @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
*/
static enum GNUNET_GenericReturnValue
-postgres_create_tables (void *cls)
+postgres_create_tables (void *cls,
+ bool support_partitions,
+ uint32_t num_partitions)
{
struct PostgresClosure *pc = cls;
+ enum GNUNET_GenericReturnValue ret = GNUNET_OK;
struct GNUNET_PQ_Context *conn;
+ struct GNUNET_PQ_QueryParam params[] = {
+ support_partitions
+ ? GNUNET_PQ_query_param_uint32 (&num_partitions)
+ : GNUNET_PQ_query_param_null (),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_PreparedStatement ps[] = {
+ GNUNET_PQ_make_prepare ("create_tables",
+ "SELECT"
+ " auditor.do_create_tables"
+ " ($1);"),
+ GNUNET_PQ_PREPARED_STATEMENT_END
+ };
struct GNUNET_PQ_ExecuteStatement es[] = {
GNUNET_PQ_make_try_execute ("SET search_path TO auditor;"),
GNUNET_PQ_EXECUTE_STATEMENT_END
@@ -157,11 +133,32 @@ postgres_create_tables (void *cls)
"auditordb-postgres",
"auditor-",
es,
- NULL);
+ ps);
if (NULL == conn)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to connect to database\n");
return GNUNET_SYSERR;
+ }
+ if (0 >
+ GNUNET_PQ_eval_prepared_non_select (conn,
+ "create_tables",
+ params))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to run 'create_tables' prepared statement\n");
+ ret = GNUNET_SYSERR;
+ }
+ if (GNUNET_OK == ret)
+ {
+ ret = GNUNET_PQ_exec_sql (conn,
+ "procedures");
+ if (GNUNET_OK != ret)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to load stored procedures\n");
+ }
GNUNET_PQ_disconnect (conn);
- return GNUNET_OK;
+ return ret;
}
@@ -400,11 +397,6 @@ postgres_gc (void *cls)
struct GNUNET_PQ_Context *conn;
enum GNUNET_DB_QueryStatus qs;
struct GNUNET_PQ_PreparedStatement ps[] = {
-#if 0
- GNUNET_PQ_make_prepare ("gc_auditor",
- "TODO: #4960",
- 0),
-#endif
GNUNET_PQ_PREPARED_STATEMENT_END
};
struct GNUNET_PQ_ExecuteStatement es[] = {
@@ -470,12 +462,18 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
plugin->rollback = &postgres_rollback;
plugin->gc = &postgres_gc;
- plugin->insert_exchange
- = &TAH_PG_insert_exchange;
- plugin->delete_exchange
- = &TAH_PG_delete_exchange;
- plugin->list_exchanges
- = &TAH_PG_list_exchanges;
+ plugin->get_auditor_progress
+ = &TAH_PG_get_auditor_progress;
+ plugin->get_balance
+ = &TAH_PG_get_balance;
+ plugin->insert_auditor_progress
+ = &TAH_PG_insert_auditor_progress;
+ plugin->insert_balance
+ = &TAH_PG_insert_balance;
+ plugin->update_auditor_progress
+ = &TAH_PG_update_auditor_progress;
+ plugin->update_balance
+ = &TAH_PG_update_balance;
plugin->insert_exchange_signkey
= &TAH_PG_insert_exchange_signkey;
@@ -483,134 +481,54 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
= &TAH_PG_insert_deposit_confirmation;
plugin->get_deposit_confirmations
= &TAH_PG_get_deposit_confirmations;
+ plugin->delete_deposit_confirmation
+ = &TAH_PG_delete_deposit_confirmation;
- plugin->get_auditor_progress_reserve
- = &TAH_PG_get_auditor_progress_reserve;
- plugin->update_auditor_progress_reserve
- = &TAH_PG_update_auditor_progress_reserve;
- plugin->insert_auditor_progress_reserve
- = &TAH_PG_insert_auditor_progress_reserve;
-
- plugin->get_auditor_progress_purse
- = &TAH_PG_get_auditor_progress_purse;
- plugin->update_auditor_progress_purse
- = &TAH_PG_update_auditor_progress_purse;
- plugin->insert_auditor_progress_purse
- = &TAH_PG_insert_auditor_progress_purse;
-
- plugin->get_auditor_progress_aggregation
- = &TAH_PG_get_auditor_progress_aggregation;
- plugin->update_auditor_progress_aggregation
- = &TAH_PG_update_auditor_progress_aggregation;
- plugin->insert_auditor_progress_aggregation
- = &TAH_PG_insert_auditor_progress_aggregation;
-
- plugin->get_auditor_progress_deposit_confirmation
- = &TAH_PG_get_auditor_progress_deposit_confirmation;
- plugin->update_auditor_progress_deposit_confirmation
- = &TAH_PG_update_auditor_progress_deposit_confirmation;
- plugin->insert_auditor_progress_deposit_confirmation
- = &TAH_PG_insert_auditor_progress_deposit_confirmation;
-
- plugin->get_auditor_progress_coin
- = &TAH_PG_get_auditor_progress_coin;
- plugin->update_auditor_progress_coin
- = &TAH_PG_update_auditor_progress_coin;
- plugin->insert_auditor_progress_coin
- = &TAH_PG_insert_auditor_progress_coin;
-
- plugin->get_wire_auditor_account_progress
- = &TAH_PG_get_wire_auditor_account_progress;
- plugin->update_wire_auditor_account_progress
- = &TAH_PG_update_wire_auditor_account_progress;
- plugin->insert_wire_auditor_account_progress
- = &TAH_PG_insert_wire_auditor_account_progress;
-
- plugin->get_wire_auditor_progress
- = &TAH_PG_get_wire_auditor_progress;
- plugin->update_wire_auditor_progress
- = &TAH_PG_update_wire_auditor_progress;
- plugin->insert_wire_auditor_progress
- = &TAH_PG_insert_wire_auditor_progress;
-
- plugin->del_reserve_info
- = &TAH_PG_del_reserve_info;
- plugin->get_reserve_info
- = &TAH_PG_get_reserve_info;
- plugin->update_reserve_info
- = &TAH_PG_update_reserve_info;
plugin->insert_reserve_info
= &TAH_PG_insert_reserve_info;
+ plugin->update_reserve_info
+ = &TAH_PG_update_reserve_info;
+ plugin->get_reserve_info
+ = &TAH_PG_get_reserve_info;
+ plugin->del_reserve_info
+ = &TAH_PG_del_reserve_info;
- plugin->get_reserve_summary
- = &TAH_PG_get_reserve_summary;
- plugin->update_reserve_summary
- = &TAH_PG_update_reserve_summary;
- plugin->insert_reserve_summary
- = &TAH_PG_insert_reserve_summary;
-
- plugin->get_wire_fee_summary
- = &TAH_PG_get_wire_fee_summary;
- plugin->update_wire_fee_summary
- = &TAH_PG_update_wire_fee_summary;
- plugin->insert_wire_fee_summary
- = &TAH_PG_insert_wire_fee_summary;
-
- plugin->get_denomination_balance
- = &TAH_PG_get_denomination_balance;
- plugin->update_denomination_balance
- = &TAH_PG_update_denomination_balance;
- plugin->insert_denomination_balance
- = &TAH_PG_insert_denomination_balance;
-
- plugin->get_balance_summary
- = &TAH_PG_get_balance_summary;
- plugin->update_balance_summary
- = &TAH_PG_update_balance_summary;
- plugin->insert_balance_summary
- = &TAH_PG_insert_balance_summary;
-
- plugin->select_historic_denom_revenue
- = &TAH_PG_select_historic_denom_revenue;
- plugin->insert_historic_denom_revenue
- = &TAH_PG_insert_historic_denom_revenue;
-
- plugin->select_historic_reserve_revenue
- = &TAH_PG_select_historic_reserve_revenue;
- plugin->insert_historic_reserve_revenue
- = &TAH_PG_insert_historic_reserve_revenue;
-
+ plugin->insert_pending_deposit
+ = &TAH_PG_insert_pending_deposit;
plugin->select_pending_deposits
= &TAH_PG_select_pending_deposits;
plugin->delete_pending_deposit
= &TAH_PG_delete_pending_deposit;
- plugin->insert_pending_deposit
- = &TAH_PG_insert_pending_deposit;
- plugin->get_predicted_balance
- = &TAH_PG_get_predicted_balance;
- plugin->update_predicted_result
- = &TAH_PG_update_predicted_result;
- plugin->insert_predicted_result
- = &TAH_PG_insert_predicted_result;
+ plugin->insert_purse_info
+ = &TAH_PG_insert_purse_info;
+ plugin->update_purse_info
+ = &TAH_PG_update_purse_info;
plugin->get_purse_info
= &TAH_PG_get_purse_info;
-
plugin->delete_purse_info
= &TAH_PG_delete_purse_info;
- plugin->update_purse_info
- = &TAH_PG_update_purse_info;
- plugin->insert_purse_info
- = &TAH_PG_insert_purse_info;
- plugin->get_purse_summary
- = &TAH_PG_get_purse_summary;
-
plugin->select_purse_expired
= &TAH_PG_select_purse_expired;
- plugin->insert_purse_summary
- = &TAH_PG_insert_purse_summary;
- plugin->update_purse_summary
- = &TAH_PG_update_purse_summary;
+
+ plugin->insert_denomination_balance
+ = &TAH_PG_insert_denomination_balance;
+ plugin->update_denomination_balance
+ = &TAH_PG_update_denomination_balance;
+ plugin->del_denomination_balance
+ = &TAH_PG_del_denomination_balance;
+ plugin->get_denomination_balance
+ = &TAH_PG_get_denomination_balance;
+
+ plugin->insert_historic_denom_revenue
+ = &TAH_PG_insert_historic_denom_revenue;
+ plugin->select_historic_denom_revenue
+ = &TAH_PG_select_historic_denom_revenue;
+
+ plugin->insert_historic_reserve_revenue
+ = &TAH_PG_insert_historic_reserve_revenue;
+ plugin->select_historic_reserve_revenue
+ = &TAH_PG_select_historic_reserve_revenue;
return plugin;
}
diff --git a/src/auditordb/procedures.sql.in b/src/auditordb/procedures.sql.in
new file mode 100644
index 000000000..0c83bdb5e
--- /dev/null
+++ b/src/auditordb/procedures.sql.in
@@ -0,0 +1,24 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2024 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+
+BEGIN;
+
+SET search_path TO auditor;
+
+#include "auditor_do_get_auditor_progress.sql"
+#include "auditor_do_get_balance.sql"
+
+COMMIT;
diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c
index f8fbe66cf..5184722f0 100644
--- a/src/auditordb/test_auditordb.c
+++ b/src/auditordb/test_auditordb.c
@@ -196,7 +196,9 @@ run (void *cls)
(void) plugin->drop_tables (plugin->cls,
GNUNET_YES);
if (GNUNET_OK !=
- plugin->create_tables (plugin->cls))
+ plugin->create_tables (plugin->cls,
+ false,
+ 0))
{
result = 77;
goto unload;
@@ -236,13 +238,11 @@ run (void *cls)
TALER_string_to_amount (CURRENCY ":0.000014",
&fee_refund));
- struct TALER_MasterPublicKeyP master_pub;
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_DenominationPrivateKey denom_priv;
struct TALER_DenominationPublicKey denom_pub;
struct GNUNET_TIME_Timestamp date;
- RND_BLK (&master_pub);
RND_BLK (&reserve_pub);
RND_BLK (&rnd_hash);
GNUNET_assert (GNUNET_OK ==
@@ -267,59 +267,6 @@ run (void *cls)
GNUNET_TIME_UNIT_HOURS,
4)));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: auditor_insert_exchange\n");
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_exchange (plugin->cls,
- &master_pub,
- "https://exchange/"));
-
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_auditor_progress\n");
-
- struct TALER_AUDITORDB_ProgressPointCoin ppc = {
- .last_deposit_serial_id = 123,
- .last_melt_serial_id = 456,
- .last_refund_serial_id = 789,
- .last_withdraw_serial_id = 555
- };
- struct TALER_AUDITORDB_ProgressPointCoin ppc2 = {
- .last_deposit_serial_id = 0,
- .last_melt_serial_id = 0,
- .last_refund_serial_id = 0,
- .last_withdraw_serial_id = 0
- };
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_auditor_progress_coin (plugin->cls,
- &master_pub,
- &ppc));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: update_auditor_progress\n");
-
- ppc.last_deposit_serial_id++;
- ppc.last_melt_serial_id++;
- ppc.last_refund_serial_id++;
- ppc.last_withdraw_serial_id++;
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_auditor_progress_coin (plugin->cls,
- &master_pub,
- &ppc));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: get_auditor_progress\n");
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_auditor_progress_coin (plugin->cls,
- &master_pub,
- &ppc2));
- FAILIF ( (ppc.last_deposit_serial_id != ppc2.last_deposit_serial_id) ||
- (ppc.last_melt_serial_id != ppc2.last_melt_serial_id) ||
- (ppc.last_refund_serial_id != ppc2.last_refund_serial_id) ||
- (ppc.last_withdraw_serial_id != ppc2.last_withdraw_serial_id) );
-
{
struct TALER_AUDITORDB_ReserveFeeBalance rfb;
struct TALER_AUDITORDB_ReserveFeeBalance rfb2;
@@ -350,7 +297,6 @@ run (void *cls)
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_reserve_info (plugin->cls,
&reserve_pub,
- &master_pub,
&rfb,
past,
"payto://bla/blub"));
@@ -359,7 +305,6 @@ run (void *cls)
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->update_reserve_info (plugin->cls,
&reserve_pub,
- &master_pub,
&rfb,
future));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -370,7 +315,6 @@ run (void *cls)
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_reserve_info (plugin->cls,
&reserve_pub,
- &master_pub,
&rowid,
&rfb2,
&date,
@@ -394,39 +338,6 @@ run (void *cls)
|| (0 != TALER_amount_cmp (&rfb2.history_fee_balance,
&rfb.history_fee_balance))
);
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_reserve_summary\n");
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_reserve_summary (plugin->cls,
- &master_pub,
- &rfb));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: update_reserve_summary\n");
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_reserve_summary (plugin->cls,
- &master_pub,
- &rfb));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: get_reserve_summary\n");
- ZR_BLK (&rfb2);
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_reserve_summary (plugin->cls,
- &master_pub,
- &rfb2));
- FAILIF ( (0 != TALER_amount_cmp (&rfb2.reserve_balance,
- &rfb.reserve_balance) ||
- (0 != TALER_amount_cmp (&rfb2.withdraw_fee_balance,
- &rfb.withdraw_fee_balance)) ||
- (0 != TALER_amount_cmp (&rfb2.close_fee_balance,
- &rfb.close_fee_balance)) ||
- (0 != TALER_amount_cmp (&rfb2.purse_fee_balance,
- &rfb.purse_fee_balance)) ||
- (0 != TALER_amount_cmp (&rfb2.open_fee_balance,
- &rfb.open_fee_balance)) ||
- (0 != TALER_amount_cmp (&rfb2.history_fee_balance,
- &rfb.history_fee_balance))));
}
{
@@ -477,77 +388,6 @@ run (void *cls)
FAILIF (dcd2.num_issued != dcd.num_issued);
}
- {
- struct TALER_AUDITORDB_GlobalCoinBalance gcb;
- struct TALER_AUDITORDB_GlobalCoinBalance gcb2;
-
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":12.345678",
- &gcb.total_escrowed));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":23.456789",
- &gcb.deposit_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":34.567890",
- &gcb.melt_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":45.678901",
- &gcb.refund_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":55.678901",
- &gcb.purse_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":65.678901",
- &gcb.open_deposit_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":13.57986",
- &gcb.risk));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":0.1",
- &gcb.loss));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1",
- &gcb.irregular_loss));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_balance_summary\n");
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_balance_summary (plugin->cls,
- &master_pub,
- &gcb));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: update_balance_summary\n");
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_balance_summary (plugin->cls,
- &master_pub,
- &gcb));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: get_balance_summary\n");
- ZR_BLK (&gcb2);
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_balance_summary (plugin->cls,
- &master_pub,
- &gcb2));
- FAILIF (0 != TALER_amount_cmp (&gcb2.total_escrowed,
- &gcb.total_escrowed));
- FAILIF (0 != TALER_amount_cmp (&gcb2.deposit_fee_balance,
- &gcb.deposit_fee_balance) );
- FAILIF (0 != TALER_amount_cmp (&gcb2.melt_fee_balance,
- &gcb.melt_fee_balance) );
- FAILIF (0 != TALER_amount_cmp (&gcb2.refund_fee_balance,
- &gcb.refund_fee_balance));
- FAILIF (0 != TALER_amount_cmp (&gcb2.purse_fee_balance,
- &gcb.purse_fee_balance));
- FAILIF (0 != TALER_amount_cmp (&gcb2.open_deposit_fee_balance,
- &gcb.open_deposit_fee_balance));
- FAILIF (0 != TALER_amount_cmp (&gcb2.risk,
- &gcb.risk));
- FAILIF (0 != TALER_amount_cmp (&gcb2.loss,
- &gcb.loss));
- FAILIF (0 != TALER_amount_cmp (&gcb2.irregular_loss,
- &gcb.irregular_loss));
- }
-
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: insert_historic_denom_revenue\n");
GNUNET_assert (GNUNET_OK ==
@@ -558,14 +398,12 @@ run (void *cls)
&rloss));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_historic_denom_revenue (plugin->cls,
- &master_pub,
&denom_pub_hash,
past,
&rbalance,
&rloss));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_historic_denom_revenue (plugin->cls,
- &master_pub,
&rnd_hash,
now,
&rbalance,
@@ -575,7 +413,6 @@ run (void *cls)
FAILIF (0 >=
plugin->select_historic_denom_revenue (
plugin->cls,
- &master_pub,
&select_historic_denom_revenue_result,
NULL));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -585,13 +422,11 @@ run (void *cls)
&reserve_profits));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_historic_reserve_revenue (plugin->cls,
- &master_pub,
past,
future,
&reserve_profits));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_historic_reserve_revenue (plugin->cls,
- &master_pub,
now,
future,
&reserve_profits));
@@ -599,85 +434,15 @@ run (void *cls)
"Test: select_historic_reserve_revenue\n");
FAILIF (0 >=
plugin->select_historic_reserve_revenue (plugin->cls,
- &master_pub,
select_historic_reserve_revenue_result,
NULL));
- {
- struct TALER_Amount dbalance;
- struct TALER_Amount dbalance2;
- struct TALER_Amount rbalance2;
-
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":2.535678",
- &dbalance));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_predicted_result\n");
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_predicted_result (plugin->cls,
- &master_pub,
- &rbalance,
- &dbalance));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: update_predicted_result\n");
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":78.901234",
- &rbalance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":73.901234",
- &dbalance));
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_predicted_result (plugin->cls,
- &master_pub,
- &rbalance,
- &dbalance));
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_wire_fee_summary (plugin->cls,
- &master_pub,
- &rbalance));
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_wire_fee_summary (plugin->cls,
- &master_pub,
- &reserve_profits));
- {
- struct TALER_Amount rprof;
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_wire_fee_summary (plugin->cls,
- &master_pub,
- &rprof));
- FAILIF (0 !=
- TALER_amount_cmp (&rprof,
- &reserve_profits));
- }
- FAILIF (0 >
- plugin->commit (plugin->cls));
+ FAILIF (0 >
+ plugin->commit (plugin->cls));
-
- FAILIF (GNUNET_OK !=
- plugin->start (plugin->cls));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: get_predicted_balance\n");
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_predicted_balance (plugin->cls,
- &master_pub,
- &rbalance2,
- &dbalance2));
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->del_reserve_info (plugin->cls,
- &reserve_pub,
- &master_pub));
-
- FAILIF (0 != TALER_amount_cmp (&rbalance2,
- &rbalance));
- FAILIF (0 != TALER_amount_cmp (&dbalance2,
- &dbalance));
-
- plugin->rollback (plugin->cls);
- }
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->del_reserve_info (plugin->cls,
+ &reserve_pub));
#if GC_IMPLEMENTED
FAILIF (GNUNET_OK !=
@@ -687,18 +452,7 @@ run (void *cls)
result = 0;
drop:
- {
- plugin->rollback (plugin->cls);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: auditor_delete_exchange\n");
- GNUNET_break (GNUNET_OK ==
- plugin->start (plugin->cls));
- GNUNET_break (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
- plugin->delete_exchange (plugin->cls,
- &master_pub));
- GNUNET_break (0 <=
- plugin->commit (plugin->cls));
- }
+ plugin->rollback (plugin->cls);
GNUNET_break (GNUNET_OK ==
plugin->drop_tables (plugin->cls,
GNUNET_YES));
@@ -719,17 +473,20 @@ main (int argc,
(void) argc;
result = -1;
- if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
+ GNUNET_log_setup (argv[0],
+ "WARNING",
+ NULL);
+ TALER_OS_init ();
+ if (NULL == (plugin_name = strrchr (argv[0],
+ (int) '-')))
{
GNUNET_break (0);
return -1;
}
- GNUNET_log_setup (argv[0],
- "WARNING",
- NULL);
plugin_name++;
(void) GNUNET_asprintf (&testname,
- "test-auditor-db-%s", plugin_name);
+ "test-auditor-db-%s",
+ plugin_name);
(void) GNUNET_asprintf (&config_filename,
"%s.conf", testname);
cfg = GNUNET_CONFIGURATION_create ();
@@ -742,7 +499,8 @@ main (int argc,
GNUNET_free (testname);
return 2;
}
- GNUNET_SCHEDULER_run (&run, cfg);
+ GNUNET_SCHEDULER_run (&run,
+ cfg);
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free (config_filename);
GNUNET_free (testname);
diff --git a/src/auditordb/test_auditordb_checkpoints.c b/src/auditordb/test_auditordb_checkpoints.c
new file mode 100644
index 000000000..f9bb83142
--- /dev/null
+++ b/src/auditordb/test_auditordb_checkpoints.c
@@ -0,0 +1,386 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2016--2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file auditordb/test_auditordb_checkpoints.c
+ * @brief test cases for DB interaction functions
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_db_lib.h>
+#include "taler_auditordb_lib.h"
+#include "taler_auditordb_plugin.h"
+
+/**
+ * Currency we use, must match CURRENCY in "test-auditor-db-postgres.conf".
+ */
+#define CURRENCY "EUR"
+
+/**
+ * Report line of error if @a cond is true, and jump to label "drop".
+ */
+#define FAILIF(cond) \
+ do { \
+ if (! (cond)) { break;} \
+ GNUNET_break (0); \
+ goto drop; \
+ } while (0)
+
+/**
+ * Initializes @a ptr with random data.
+ */
+#define RND_BLK(ptr) \
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, \
+ sizeof (*ptr))
+
+/**
+ * Initializes @a ptr with zeros.
+ */
+#define ZR_BLK(ptr) \
+ memset (ptr, 0, sizeof (*ptr))
+
+
+/**
+ * Global result from the testcase.
+ */
+static int result = -1;
+
+/**
+ * Database plugin under test.
+ */
+static struct TALER_AUDITORDB_Plugin *plugin;
+
+
+/**
+ * Main function that will be run by the scheduler.
+ *
+ * @param cls closure with config
+ */
+static void
+run (void *cls)
+{
+ struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+ struct TALER_Amount a1;
+ struct TALER_Amount a2;
+ struct TALER_Amount a3;
+
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":11.245678",
+ &a1));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":2",
+ &a2));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":3",
+ &a3));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "loading database plugin\n");
+ if (NULL ==
+ (plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to connect to database\n");
+ result = 77;
+ return;
+ }
+
+ (void) plugin->drop_tables (plugin->cls,
+ GNUNET_YES);
+ if (GNUNET_OK !=
+ plugin->create_tables (plugin->cls,
+ false,
+ 0))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to 'create_tables'\n");
+ result = 77;
+ goto unload;
+ }
+ if (GNUNET_SYSERR ==
+ plugin->preflight (plugin->cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed preflight check\n");
+ result = 77;
+ goto drop;
+ }
+
+ FAILIF (GNUNET_OK !=
+ plugin->start (plugin->cls));
+
+ /* Test inserting a blank value, should tell us one result */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->insert_auditor_progress (plugin->cls,
+ "Test",
+ 69,
+ NULL)
+ );
+ /* Test re-inserting the same value; should yield no results */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
+ plugin->insert_auditor_progress (plugin->cls,
+ "Test",
+ 69,
+ NULL)
+ );
+ /* Test inserting multiple values, with one already existing */
+ GNUNET_assert (
+ 2 == plugin->insert_auditor_progress (plugin->cls,
+ "Test",
+ 69,
+ "Test2",
+ 123,
+ "Test3",
+ 245,
+ NULL)
+ );
+ /* Test re-re-inserting the same key with a different value; should also yield no results */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
+ plugin->insert_auditor_progress (plugin->cls,
+ "Test",
+ 42,
+ NULL)
+ );
+ /* Test updating the same key (again) with a different value; should yield a result */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->update_auditor_progress (plugin->cls,
+ "Test",
+ 42,
+ NULL)
+ );
+ /* Test updating a key that doesn't exist; should yield 0 */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
+ plugin->update_auditor_progress (plugin->cls,
+ "NonexistentTest",
+ 1,
+ NULL)
+ );
+
+ /* Right now, the state should look like this:
+ * Test = 42
+ * Test2 = 123
+ * Test3 = 245
+ * Let's make sure that's the case! */
+ uint64_t value;
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->get_auditor_progress (
+ plugin->cls,
+ "Test",
+ &value,
+ NULL)
+ );
+ GNUNET_assert (value == 42);
+
+ /* Ensure the rest are also at their expected values */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->get_auditor_progress (
+ plugin->cls,
+ "Test2",
+ &value,
+ NULL)
+ );
+ GNUNET_assert (value == 123);
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->get_auditor_progress (
+ plugin->cls,
+ "Test3",
+ &value,
+ NULL)
+ );
+ GNUNET_assert (value == 245);
+
+ /* Try fetching value that does not exist */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->get_auditor_progress (
+ plugin->cls,
+ "TestNX",
+ &value,
+ NULL)
+ );
+ GNUNET_assert (0 == value);
+
+
+ /* Test inserting a blank value, should tell us one result */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->insert_balance (plugin->cls,
+ "Test",
+ &a1,
+ NULL)
+ );
+ /* Test re-inserting the same value; should yield no results */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
+ plugin->insert_balance (plugin->cls,
+ "Test",
+ &a1,
+ NULL)
+ );
+ /* Test inserting multiple values, with one already existing */
+ GNUNET_assert (
+ 2 == plugin->insert_balance (plugin->cls,
+ "Test",
+ &a1,
+ "Test2",
+ &a2,
+ "Test3",
+ &a3,
+ NULL)
+ );
+ /* Test re-re-inserting the same key with a different value; should also yield no results */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
+ plugin->insert_balance (plugin->cls,
+ "Test",
+ &a2,
+ NULL)
+ );
+ /* Test updating the same key (again) with a different value; should yield a result */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->update_balance (plugin->cls,
+ "Test",
+ &a2,
+ NULL)
+ );
+ /* Test updating a key that doesn't exist; should yield 0 */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
+ plugin->update_balance (plugin->cls,
+ "NonexistentTest",
+ &a2,
+ NULL)
+ );
+
+ /* Right now, the state should look like this:
+ * Test = a2
+ * Test2 = a2
+ * Test3 = a3
+ * Let's make sure that's the case! */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->get_balance (
+ plugin->cls,
+ "Test",
+ &a1,
+ NULL)
+ );
+ GNUNET_assert (0 ==
+ TALER_amount_cmp (&a1,
+ &a2));
+
+ /* Ensure the rest are also at their expected values */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->get_balance (
+ plugin->cls,
+ "Test2",
+ &a1,
+ NULL)
+ );
+ GNUNET_assert (0 ==
+ TALER_amount_cmp (&a1,
+ &a2));
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->get_balance (
+ plugin->cls,
+ "Test3",
+ &a1,
+ NULL)
+ );
+ GNUNET_assert (0 ==
+ TALER_amount_cmp (&a1,
+ &a3));
+
+ /* Try fetching value that does not exist */
+ GNUNET_assert (
+ GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+ plugin->get_balance (
+ plugin->cls,
+ "TestNX",
+ &a1,
+ NULL)
+ );
+ GNUNET_assert (GNUNET_OK !=
+ TALER_amount_is_valid (&a1));
+
+ result = 0;
+ GNUNET_break (0 <=
+ plugin->commit (plugin->cls));
+drop:
+ GNUNET_break (GNUNET_OK ==
+ plugin->drop_tables (plugin->cls,
+ GNUNET_YES));
+unload:
+ TALER_AUDITORDB_plugin_unload (plugin);
+ plugin = NULL;
+}
+
+
+int
+main (int argc,
+ char *const argv[])
+{
+ const char *plugin_name;
+ char *config_filename;
+ char *testname;
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ (void) argc;
+ result = -1;
+ TALER_OS_init ();
+ GNUNET_log_setup (argv[0],
+ "INFO",
+ NULL);
+ if (NULL == (plugin_name = strrchr (argv[0],
+ (int) '-')))
+ {
+ GNUNET_break (0);
+ return -1;
+ }
+ plugin_name++;
+ (void) GNUNET_asprintf (&testname,
+ "test-auditor-db-%s",
+ plugin_name);
+ (void) GNUNET_asprintf (&config_filename,
+ "%s.conf",
+ testname);
+ cfg = GNUNET_CONFIGURATION_create ();
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_parse (cfg,
+ config_filename))
+ {
+ GNUNET_break (0);
+ GNUNET_free (config_filename);
+ GNUNET_free (testname);
+ return 2;
+ }
+ GNUNET_SCHEDULER_run (&run, cfg);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ GNUNET_free (config_filename);
+ GNUNET_free (testname);
+ return result;
+}