summaryrefslogtreecommitdiff
path: root/src
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
parentc6b14a97c57528cbcf5e23e20707e8ec50b7faec (diff)
parente0d46f96859b33b3f04791028e30bce4f0173567 (diff)
downloadexchange-97f3e30c3d4081a6765c914c94b6cbf3a75110f3.tar.gz
exchange-97f3e30c3d4081a6765c914c94b6cbf3a75110f3.tar.bz2
exchange-97f3e30c3d4081a6765c914c94b6cbf3a75110f3.zip
fixing merge conflict
Diffstat (limited to 'src')
-rw-r--r--src/auditor/Makefile.am10
-rw-r--r--src/auditor/report-lib.c65
-rw-r--r--src/auditor/report-lib.h48
-rw-r--r--src/auditor/taler-auditor-dbinit.c4
-rw-r--r--src/auditor/taler-auditor-exchange.c224
-rw-r--r--src/auditor/taler-auditor-httpd.c47
-rw-r--r--src/auditor/taler-auditor-httpd.h6
-rw-r--r--src/auditor/taler-auditor-httpd_deposit-confirmation-get.c46
-rw-r--r--src/auditor/taler-auditor-httpd_deposit-confirmation.c5
-rw-r--r--src/auditor/taler-helper-auditor-aggregation.c81
-rw-r--r--src/auditor/taler-helper-auditor-coins.c407
-rw-r--r--src/auditor/taler-helper-auditor-deposits.c48
-rw-r--r--src/auditor/taler-helper-auditor-purses.c169
-rw-r--r--src/auditor/taler-helper-auditor-reserves.c320
-rw-r--r--src/auditor/taler-helper-auditor-wire.c244
-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_aggregation.h)23
-rw-r--r--src/auditordb/pg_get_auditor_progress_aggregation.c56
-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_deposit_confirmation.h43
-rw-r--r--src/auditordb/pg_get_auditor_progress_purse.c68
-rw-r--r--src/auditordb/pg_get_auditor_progress_purse.h44
-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_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_reserve_summary.h)26
-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
-rw-r--r--src/exchange/taler-exchange-httpd.c9
-rw-r--r--src/exchangedb/test_exchangedb.c1
-rw-r--r--src/include/taler_auditor_service.h5
-rw-r--r--src/include/taler_auditordb_plugin.h1151
-rw-r--r--src/lib/auditor_api_get_config.c4
-rw-r--r--src/pq/pq_common.h15
-rw-r--r--src/pq/pq_result_helper.c41
-rwxr-xr-xsrc/testing/taler-unified-setup.sh4
158 files changed, 2956 insertions, 6607 deletions
diff --git a/src/auditor/Makefile.am b/src/auditor/Makefile.am
index 36b540c03..381c0b115 100644
--- a/src/auditor/Makefile.am
+++ b/src/auditor/Makefile.am
@@ -16,7 +16,6 @@ clean-local:
bin_PROGRAMS = \
taler-auditor-dbinit \
- taler-auditor-exchange \
taler-auditor-httpd \
taler-auditor-sync \
taler-helper-auditor-aggregation \
@@ -179,15 +178,6 @@ taler_auditor_httpd_LDADD = \
-lz \
$(XLIB)
-taler_auditor_exchange_SOURCES = \
- taler-auditor-exchange.c
-taler_auditor_exchange_LDADD = \
- $(LIBGCRYPT_LIBS) \
- $(top_builddir)/src/util/libtalerutil.la \
- $(top_builddir)/src/auditordb/libtalerauditordb.la \
- -lgnunetutil \
- $(XLIB)
-
taler_auditor_sync_SOURCES = \
taler-auditor-sync.c
taler_auditor_sync_LDADD = \
diff --git a/src/auditor/report-lib.c b/src/auditor/report-lib.c
index bee7ec0f6..d0e1325ea 100644
--- a/src/auditor/report-lib.c
+++ b/src/auditor/report-lib.c
@@ -361,31 +361,6 @@ TALER_ARL_setup_sessions_and_run (TALER_ARL_Analysis ana,
}
-/**
- * Test if the given @a mpub matches the #TALER_ARL_master_pub.
- * If so, set "found" to GNUNET_YES.
- *
- * @param cls a `int *` pointing to "found"
- * @param mpub exchange master public key to compare
- * @param exchange_url URL of the exchange (ignored)
- */
-static void
-test_master_present (void *cls,
- const struct TALER_MasterPublicKeyP *mpub,
- const char *exchange_url)
-{
- int *found = cls;
-
- if (0 == GNUNET_memcmp (mpub,
- &TALER_ARL_master_pub))
- {
- *found = GNUNET_YES;
- GNUNET_free (TALER_ARL_exchange_url);
- TALER_ARL_exchange_url = GNUNET_strdup (exchange_url);
- }
-}
-
-
void
TALER_ARL_amount_add_ (struct TALER_Amount *sum,
const struct TALER_Amount *a1,
@@ -557,6 +532,18 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c)
"BASE_URL");
return GNUNET_SYSERR;
}
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (TALER_ARL_cfg,
+ "exchange",
+ "BASE_URL",
+ &TALER_ARL_exchange_url))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "exchange",
+ "BASE_URL");
+ return GNUNET_SYSERR;
+ }
+
if (GNUNET_is_zero (&TALER_ARL_master_pub))
{
/* -m option not given, try configuration */
@@ -716,29 +703,13 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c)
TALER_ARL_done (NULL);
return GNUNET_SYSERR;
}
+ if (GNUNET_SYSERR ==
+ TALER_ARL_adb->preflight (TALER_ARL_adb->cls))
{
- int found;
-
- if (GNUNET_SYSERR ==
- TALER_ARL_adb->preflight (TALER_ARL_adb->cls))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to start session with auditor database.\n");
- TALER_ARL_done (NULL);
- return GNUNET_SYSERR;
- }
- found = GNUNET_NO;
- (void) TALER_ARL_adb->list_exchanges (TALER_ARL_adb->cls,
- &test_master_present,
- &found);
- if (GNUNET_NO == found)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Exchange's master public key `%s' not known to auditor DB. Did you forget to run `taler-auditor-exchange`?\n",
- GNUNET_p2s (&TALER_ARL_master_pub.eddsa_pub));
- TALER_ARL_done (NULL);
- return GNUNET_SYSERR;
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to start session with auditor database.\n");
+ TALER_ARL_done (NULL);
+ return GNUNET_SYSERR;
}
return GNUNET_OK;
}
diff --git a/src/auditor/report-lib.h b/src/auditor/report-lib.h
index db15494cd..db29abc3a 100644
--- a/src/auditor/report-lib.h
+++ b/src/auditor/report-lib.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2016-2020 Taler Systems SA
+ 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 Affero Public License as published by the Free Software
@@ -28,6 +28,52 @@
#include "taler_bank_service.h"
#include "taler_signatures.h"
+/**
+ * Macro to use to access progress point value @a name.
+ */
+#define TALER_ARL_USE_PP(name) TAC_ ## name
+
+/**
+ * Macro to use to declare progress point value @a name.
+ */
+#define TALER_ARL_DEF_PP(name) \
+ uint64_t TALER_ARL_USE_PP (name) = 0
+
+/**
+ * Macro to use to GET progress point value @a name from DB.
+ */
+#define TALER_ARL_GET_PP(name) \
+ TALER_S (name), &TALER_ARL_USE_PP (name)
+
+/**
+ * Macro to use to SET progress point value @a name in DB.
+ */
+#define TALER_ARL_SET_PP(name) \
+ TALER_S (name), TALER_ARL_USE_PP (name)
+
+/**
+ * Macro to use to access amount balance @a name.
+ */
+#define TALER_ARL_USE_AB(name) TAC_ ## name
+
+/**
+ * Macro to use to declare amount balance @a name.
+ */
+#define TALER_ARL_DEF_AB(name) \
+ struct TALER_Amount TALER_ARL_USE_AB (name)
+
+/**
+ * Macro to use to GET amount balance @a name from DB.
+ */
+#define TALER_ARL_GET_AB(name) \
+ TALER_S (name), &TALER_ARL_USE_AB (name)
+
+/**
+ * Macro to use to SET amount balance @a name in DB.
+ */
+#define TALER_ARL_SET_AB(name) \
+ TALER_S (name), &TALER_ARL_USE_AB (name)
+
/**
* Command-line option "-r": restart audit from scratch
diff --git a/src/auditor/taler-auditor-dbinit.c b/src/auditor/taler-auditor-dbinit.c
index 54f8152a5..4cb46f470 100644
--- a/src/auditor/taler-auditor-dbinit.c
+++ b/src/auditor/taler-auditor-dbinit.c
@@ -90,7 +90,9 @@ run (void *cls,
"Failed to restart audits\n");
}
if (GNUNET_OK !=
- plugin->create_tables (plugin->cls))
+ plugin->create_tables (plugin->cls,
+ false,
+ 0))
{
fprintf (stderr,
"Failed to initialize database.\n");
diff --git a/src/auditor/taler-auditor-exchange.c b/src/auditor/taler-auditor-exchange.c
deleted file mode 100644
index b34d14842..000000000
--- a/src/auditor/taler-auditor-exchange.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014-2021 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 taler-auditor-exchange.c
- * @brief Tool used by the auditor to add or remove the exchange's master key
- * to its database.
- * @author Christian Grothoff
- */
-#include <platform.h>
-#include "taler_exchangedb_lib.h"
-#include "taler_auditordb_lib.h"
-
-
-/**
- * URL of the exchange.
- */
-static char *exchange_url;
-
-/**
- * Master public key of the exchange.
- */
-static struct TALER_MasterPublicKeyP master_public_key;
-
-/**
- * Our configuration.
- */
-static struct GNUNET_CONFIGURATION_Handle *cfg;
-
-/**
- * Handle to access the auditor's database.
- */
-static struct TALER_AUDITORDB_Plugin *adb;
-
-/**
- * -r option given.
- */
-static int remove_flag;
-
-
-/**
- * The main function of the taler-auditor-exchange tool. This tool is used
- * to add (or remove) an exchange's master key and base URL to the auditor's
- * database.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, non-zero on error
- */
-int
-main (int argc,
- char *const *argv)
-{
- char *cfgfile = NULL;
- const struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_cfgfile (&cfgfile),
- GNUNET_GETOPT_option_help (
- "Add or remove exchange to list of audited exchanges"),
- GNUNET_GETOPT_option_mandatory
- (GNUNET_GETOPT_option_base32_auto ('m',
- "exchange-key",
- "KEY",
- "public key of the exchange (Crockford base32 encoded)",
- &master_public_key)),
- GNUNET_GETOPT_option_string ('u',
- "exchange-url",
- "URL",
- "base URL of the exchange",
- &exchange_url),
- GNUNET_GETOPT_option_flag ('r',
- "remove",
- "remove the exchange's key (default is to add)",
- &remove_flag),
- GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION),
- GNUNET_GETOPT_OPTION_END
- };
-
- TALER_gcrypt_init (); /* must trigger initialization manually at this point! */
- GNUNET_assert (GNUNET_OK ==
- GNUNET_log_setup ("taler-auditor-exchange",
- "WARNING",
- NULL));
- {
- int ret;
-
- ret = GNUNET_GETOPT_run ("taler-auditor-exchange",
- options,
- argc, argv);
- if (GNUNET_NO == ret)
- return EXIT_SUCCESS;
- if (GNUNET_SYSERR == ret)
- return EXIT_INVALIDARGUMENT;
- }
- if (NULL == cfgfile)
- cfgfile = GNUNET_CONFIGURATION_default_filename ();
- if (NULL == cfgfile)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Can't find default configuration file.\n");
- return EXIT_NOTCONFIGURED;
- }
- cfg = GNUNET_CONFIGURATION_create ();
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Loading config file: %s\n",
- cfgfile);
-
- if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_load (cfg,
- cfgfile))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Malformed configuration file `%s', exit ...\n",
- cfgfile);
- GNUNET_free (cfgfile);
- return EXIT_NOTCONFIGURED;
- }
- GNUNET_free (cfgfile);
-
- if (! remove_flag)
- {
- if (NULL == exchange_url)
- {
- fprintf (stderr,
- _ ("Missing either `%s' or `%s'.\n"),
- "-u URL",
- "--remove");
- return EXIT_INVALIDARGUMENT;
- }
- if ( (0 == strlen (exchange_url)) ||
- ( (0 != strncasecmp ("http://",
- exchange_url,
- strlen ("http://"))) &&
- (0 != strncasecmp ("https://",
- exchange_url,
- strlen ("https://"))) ) ||
- ('/' != exchange_url[strlen (exchange_url) - 1]) )
- {
- fprintf (stderr,
- "Exchange URL must begin with `http://` or `https://` and end with `/'\n");
- return EXIT_INVALIDARGUMENT;
- }
- }
-
-
- if (NULL ==
- (adb = TALER_AUDITORDB_plugin_load (cfg)))
- {
- fprintf (stderr,
- "Failed to initialize auditor database plugin.\n");
- return EXIT_NOTINSTALLED;
- }
-
- /* Create required tables */
- if (GNUNET_OK !=
- adb->create_tables (adb->cls))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to create tables in auditor's database\n");
- TALER_AUDITORDB_plugin_unload (adb);
- return EXIT_NOPERMISSION;
- }
-
- /* Update DB */
- {
- enum GNUNET_DB_QueryStatus qs;
-
- if (GNUNET_SYSERR ==
- adb->preflight (adb->cls))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to initialize database connection\n");
- TALER_AUDITORDB_plugin_unload (adb);
- return EXIT_FAILURE;
- }
-
- if (remove_flag)
- {
- qs = adb->delete_exchange (adb->cls,
- &master_public_key);
- }
- else
- {
- qs = adb->insert_exchange (adb->cls,
- &master_public_key,
- exchange_url);
- }
- if (0 > qs)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to update auditor database (status code: %d)\n",
- qs);
- TALER_AUDITORDB_plugin_unload (adb);
- return EXIT_FAILURE;
- }
- if (0 == qs)
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_WARNING,
- (remove_flag)
- ? "Could not remove exchange from database: entry already absent\n"
- : "Could not add exchange to database: entry already exists\n");
- TALER_AUDITORDB_plugin_unload (adb);
- return EXIT_SUCCESS;
- }
- }
- TALER_AUDITORDB_plugin_unload (adb);
- return EXIT_SUCCESS;
-}
-
-
-/* end of taler-auditor-exchange.c */
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c
index be6d74be6..d9cdff8d2 100644
--- a/src/auditor/taler-auditor-httpd.c
+++ b/src/auditor/taler-auditor-httpd.c
@@ -48,7 +48,8 @@
* release version, and the format is NOT the same that semantic
* versioning uses either.
*/
-#define AUDITOR_PROTOCOL_VERSION "0:1:0"
+#define AUDITOR_PROTOCOL_VERSION "1:0:1"
+
/**
* Backlog for listen operation on unix domain sockets.
@@ -81,6 +82,12 @@ struct TALER_EXCHANGEDB_Plugin *TAH_eplugin;
static struct TALER_AuditorPublicKeyP auditor_pub;
/**
+ * Exchange master public key (according to the
+ * configuration). (global)
+ */
+struct TALER_MasterPublicKeyP TAH_master_public_key;
+
+/**
* Default timeout in seconds for HTTP requests.
*/
static unsigned int connection_timeout = 30;
@@ -166,7 +173,9 @@ handle_config (struct TAH_RequestHandler *rh,
GNUNET_JSON_pack_string ("currency",
TAH_currency),
GNUNET_JSON_pack_data_auto ("auditor_public_key",
- &auditor_pub));
+ &auditor_pub),
+ GNUNET_JSON_pack_data_auto ("exchange_master_public_key",
+ &TAH_master_public_key));
}
if (NULL == ver)
{
@@ -305,6 +314,40 @@ auditor_serve_process_config (void)
{
return GNUNET_SYSERR;
}
+
+ {
+ char *master_public_key_str;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "exchange",
+ "MASTER_PUBLIC_KEY",
+ &master_public_key_str))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "exchange",
+ "MASTER_PUBLIC_KEY");
+ return GNUNET_SYSERR;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_public_key_from_string (
+ master_public_key_str,
+ strlen (master_public_key_str),
+ &TAH_master_public_key.eddsa_pub))
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ "exchange",
+ "MASTER_PUBLIC_KEY",
+ "invalid base32 encoding for a master public key");
+ GNUNET_free (master_public_key_str);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Launching auditor for exchange `%s'...\n",
+ master_public_key_str);
+ GNUNET_free (master_public_key_str);
+ }
+
{
char *pub;
diff --git a/src/auditor/taler-auditor-httpd.h b/src/auditor/taler-auditor-httpd.h
index 79e56ff55..853722f09 100644
--- a/src/auditor/taler-auditor-httpd.h
+++ b/src/auditor/taler-auditor-httpd.h
@@ -39,6 +39,12 @@ extern struct TALER_AUDITORDB_Plugin *TAH_plugin;
extern struct TALER_EXCHANGEDB_Plugin *TAH_eplugin;
/**
+ * Exchange master public key (according to the
+ * configuration). (global)
+ */
+extern struct TALER_MasterPublicKeyP TAH_master_public_key;
+
+/**
* Our currency.
*/
extern char *TAH_currency;
diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c b/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c
index 5caff7aba..265d625c4 100644
--- a/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c
+++ b/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c
@@ -75,18 +75,6 @@ struct ExchangeSigningKeyDataP
GNUNET_NETWORK_STRUCT_END
-/**
- * Cache of already verified exchange signing keys. Maps the hash of the
- * `struct TALER_ExchangeSigningKeyValidityPS` to the (static) string
- * "verified" or "revoked". Access to this map is guarded by the #lock.
- */
-static struct GNUNET_CONTAINER_MultiHashMap *cache;
-
-/**
- * Lock for operations on #cache.
- */
-static pthread_mutex_t lock;
-
/**
* Add deposit confirmation to the list.
@@ -149,11 +137,10 @@ TAH_DEPOSIT_CONFIRMATION_handler_get (struct TAH_RequestHandler *rh,
ja = json_array ();
GNUNET_break (NULL != ja);
// TODO correct below
- struct TALER_AUDITORDB_ProgressPointDepositConfirmation ppdc = { 0 }; // FIXME: initialize...
-
qs = TAH_plugin->get_deposit_confirmations (
TAH_plugin->cls,
- ppdc.last_deposit_confirmation_serial_id,
+ 0, /* FIXME: get from query parameters! */
+ false, /* FIXME: get from query parameters! */
&add_deposit_confirmation,
ja);
@@ -176,31 +163,4 @@ TAH_DEPOSIT_CONFIRMATION_handler_get (struct TAH_RequestHandler *rh,
}
-void
-TEAH_DEPOSIT_CONFIRMATION_GET_init (void)
-{
- cache = GNUNET_CONTAINER_multihashmap_create (32,
- GNUNET_NO);
- GNUNET_assert (0 == pthread_mutex_init (&lock, NULL));
-}
-
-
-void
-TEAH_DEPOSIT_CONFIRMATION_GET_done (void)
-{
- if (NULL != cache)
- {
- GNUNET_CONTAINER_multihashmap_destroy (cache);
- cache = NULL;
- GNUNET_assert (0 == pthread_mutex_destroy (&lock));
- }
-}
-
-
-/*MHD_RESULT
-TAH_DEPOSIT_CONFIRMATION_delete(struct TEH_RequestContext *rc,
- const char *const args[1]) {
-}*/
-
-
-/* end of taler-auditor-httpd_deposit-confirmation.c */
+/* end of taler-auditor-httpd_deposit-confirmation-get.c */
diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c
index 10243eafc..8b449bf47 100644
--- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c
+++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c
@@ -157,7 +157,7 @@ verify_and_execute_deposit_confirmation (
es->ep_start,
es->ep_expire,
es->ep_end,
- &es->master_public_key,
+ &TAH_master_public_key,
&es->master_sig))
{
TALER_LOG_WARNING ("Invalid signature on exchange signing key\n");
@@ -311,8 +311,6 @@ TAH_DEPOSIT_CONFIRMATION_handler (
&dc.exchange_sig),
GNUNET_JSON_spec_fixed_auto ("exchange_pub",
&dc.exchange_pub),
- GNUNET_JSON_spec_fixed_auto ("master_pub",
- &es.master_public_key),
GNUNET_JSON_spec_timestamp ("ep_start",
&es.ep_start),
GNUNET_JSON_spec_timestamp ("ep_expire",
@@ -423,7 +421,6 @@ TAH_DEPOSIT_CONFIRMATION_handler (
dc.coin_pubs = coin_pubs;
dc.coin_sigs = coin_sigs;
es.exchange_pub = dc.exchange_pub; /* used twice! */
- dc.master_public_key = es.master_public_key;
res = verify_and_execute_deposit_confirmation (connection,
&dc,
&es);
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c
index 8b2808401..6838ff3ba 100644
--- a/src/auditor/taler-helper-auditor-aggregation.c
+++ b/src/auditor/taler-helper-auditor-aggregation.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2016-2022 Taler Systems SA
+ 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 Affero Public License as published by the Free Software
@@ -36,12 +36,13 @@ static int global_ret;
/**
* Checkpointing our progress for aggregations.
*/
-static struct TALER_AUDITORDB_ProgressPointAggregation ppa;
+static TALER_ARL_DEF_PP (aggregation_last_wire_out_serial_id);
/**
- * Checkpointing our progress for aggregations.
+ * Total aggregation fees (wire fees) earned.
*/
-static struct TALER_AUDITORDB_ProgressPointAggregation ppa_start;
+static TALER_ARL_DEF_AB (aggregation_total_wire_fee_revenue);
+
/**
* Array of reports about row inconsistencies.
@@ -102,11 +103,6 @@ static struct TALER_Amount total_arithmetic_delta_plus;
static struct TALER_Amount total_arithmetic_delta_minus;
/**
- * Total aggregation fees (wire fees) earned.
- */
-static struct TALER_Amount total_aggregation_fee_income;
-
-/**
* Array of reports about coin operations with bad signatures.
*/
static json_t *report_bad_sig_losses;
@@ -1095,8 +1091,9 @@ check_wire_out_cb (void *cls,
char *method;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppa.last_wire_out_serial_id);
- ppa.last_wire_out_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (aggregation_last_wire_out_serial_id));
+ TALER_ARL_USE_PP (aggregation_last_wire_out_serial_id) = rowid + 1;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking wire transfer %s over %s performed on %s\n",
@@ -1183,8 +1180,8 @@ check_wire_out_cb (void *cls,
&wcc.total_deposits,
&final_amount);
/* Sum up aggregation fees (we simply include the rounding gains) */
- TALER_ARL_amount_add (&total_aggregation_fee_income,
- &total_aggregation_fee_income,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (aggregation_total_wire_fee_revenue),
+ &TALER_ARL_USE_AB (aggregation_total_wire_fee_revenue),
&exchange_gain);
/* Check that calculated amount matches actual amount */
@@ -1256,9 +1253,10 @@ analyze_aggregations (void *cls)
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Analyzing aggregations\n");
- qsp = TALER_ARL_adb->get_auditor_progress_aggregation (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppa);
+ qsp = TALER_ARL_adb->get_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_PP (aggregation_last_wire_out_serial_id),
+ NULL);
if (0 > qsp)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp);
@@ -1271,18 +1269,19 @@ analyze_aggregations (void *cls)
}
else
{
- ppa_start = ppa;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming aggregation audit at %llu\n",
- (unsigned long long) ppa.last_wire_out_serial_id);
+ (unsigned long long) TALER_ARL_USE_PP (
+ aggregation_last_wire_out_serial_id));
}
memset (&ac,
0,
sizeof (ac));
- qsx = TALER_ARL_adb->get_wire_fee_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &total_aggregation_fee_income);
+ qsx = TALER_ARL_adb->get_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_AB (aggregation_total_wire_fee_revenue),
+ NULL);
if (0 > qsx)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
@@ -1291,7 +1290,7 @@ analyze_aggregations (void *cls)
ac.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
qs = TALER_ARL_edb->select_wire_out_above_serial_id (
TALER_ARL_edb->cls,
- ppa.last_wire_out_serial_id,
+ TALER_ARL_USE_PP (aggregation_last_wire_out_serial_id),
&check_wire_out_cb,
&ac);
if (0 > qs)
@@ -1317,30 +1316,30 @@ analyze_aggregations (void *cls)
return ac.qs;
}
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx)
- ac.qs = TALER_ARL_adb->insert_wire_fee_summary (
+ ac.qs = TALER_ARL_adb->insert_balance (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &total_aggregation_fee_income);
+ TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
+ NULL);
else
- ac.qs = TALER_ARL_adb->update_wire_fee_summary (
+ ac.qs = TALER_ARL_adb->update_balance (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &total_aggregation_fee_income);
+ TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
+ NULL);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != ac.qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == ac.qs);
return ac.qs;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
- qs = TALER_ARL_adb->update_auditor_progress_aggregation (
+ qs = TALER_ARL_adb->update_auditor_progress (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppa);
+ TALER_ARL_SET_PP (aggregation_last_wire_out_serial_id),
+ NULL);
else
- qs = TALER_ARL_adb->insert_auditor_progress_aggregation (
+ qs = TALER_ARL_adb->insert_auditor_progress (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppa);
+ TALER_ARL_SET_PP (aggregation_last_wire_out_serial_id),
+ NULL);
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1350,7 +1349,8 @@ analyze_aggregations (void *cls)
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Concluded aggregation audit step at %llu\n",
- (unsigned long long) ppa.last_wire_out_serial_id);
+ (unsigned long long) TALER_ARL_USE_PP (
+ aggregation_last_wire_out_serial_id));
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
}
@@ -1385,7 +1385,8 @@ run (void *cls,
"Starting audit\n");
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_aggregation_fee_income));
+ &TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
&total_wire_out_delta_plus));
@@ -1479,14 +1480,14 @@ run (void *cls,
"total_arithmetic_delta_minus",
&total_arithmetic_delta_minus),
TALER_JSON_pack_amount (
- "total_aggregation_fee_income",
- &total_aggregation_fee_income),
+ "aggregation_total_wire_fee_revenue",
+ &TALER_ARL_USE_AB (aggregation_total_wire_fee_revenue)),
GNUNET_JSON_pack_uint64 (
"start_ppa_wire_out_serial_id",
- ppa_start.last_wire_out_serial_id),
+ 0 /* defunct */),
GNUNET_JSON_pack_uint64 (
"end_ppa_wire_out_serial_id",
- ppa.last_wire_out_serial_id),
+ TALER_ARL_USE_PP (aggregation_last_wire_out_serial_id)),
/* block #4 */
TALER_JSON_pack_time_abs_human (
"auditor_start_time",
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c
index 23233dc7c..0eaa8ceaa 100644
--- a/src/auditor/taler-helper-auditor-coins.c
+++ b/src/auditor/taler-helper-auditor-coins.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2016-2022 Taler Systems SA
+ 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 Affero Public License as published by the Free Software
@@ -47,12 +47,27 @@ static int global_ret;
/**
* Checkpointing our progress for coins.
*/
-static struct TALER_AUDITORDB_ProgressPointCoin ppc;
+static TALER_ARL_DEF_PP (coins_withdraw_serial_id);
+static TALER_ARL_DEF_PP (coins_deposit_serial_id);
+static TALER_ARL_DEF_PP (coins_melt_serial_id);
+static TALER_ARL_DEF_PP (coins_refund_serial_id);
+static TALER_ARL_DEF_PP (coins_recoup_serial_id);
+static TALER_ARL_DEF_PP (coins_recoup_refresh_serial_id);
+static TALER_ARL_DEF_PP (coins_purse_deposits_serial_id);
+static TALER_ARL_DEF_PP (coins_purse_refunds_serial_id);
+
/**
- * Checkpointing our progress for coins.
+ * Global coin balance sheet (for coins).
*/
-static struct TALER_AUDITORDB_ProgressPointCoin ppc_start;
+static TALER_ARL_DEF_AB (coin_balance_risk);
+static TALER_ARL_DEF_AB (total_escrowed);
+static TALER_ARL_DEF_AB (coin_irregular_loss);
+static TALER_ARL_DEF_AB (coin_melt_fee_revenue);
+static TALER_ARL_DEF_AB (coin_deposit_fee_revenue);
+static TALER_ARL_DEF_AB (coin_refund_fee_revenue);
+static TALER_ARL_DEF_AB (total_recoup_loss);
+
/**
* Array of reports about denomination keys with an
@@ -112,10 +127,6 @@ static struct TALER_Amount reported_emergency_loss;
*/
static struct TALER_Amount reported_emergency_loss_by_count;
-/**
- * Global coin balance sheet (for coins).
- */
-static struct TALER_AUDITORDB_GlobalCoinBalance balance;
/**
* Array of reports about coin operations with bad signatures.
@@ -798,8 +809,8 @@ sync_denomination (void *cls,
/* The denomination expired and carried a balance; we can now
book the remaining balance as profit, and reduce our risk
exposure by the accumulated risk of the denomination. */
- TALER_ARL_amount_subtract (&balance.risk,
- &balance.risk,
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
&ds->dcd.denom_risk);
/* If the above fails, our risk assessment is inconsistent!
This is really, really bad (auditor-internal invariant
@@ -818,7 +829,6 @@ sync_denomination (void *cls,
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
(qs = TALER_ARL_adb->insert_historic_denom_revenue (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
&denom_h,
expire_deposit,
&ds->dcd.denom_balance,
@@ -938,8 +948,9 @@ withdraw_cb (void *cls,
(void) execution_date;
(void) amount_with_fee;
- GNUNET_assert (rowid >= ppc.last_withdraw_serial_id); /* should be monotonically increasing */
- ppc.last_withdraw_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_withdraw_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_withdraw_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
@@ -977,11 +988,11 @@ withdraw_cb (void *cls,
"New balance of denomination `%s' is %s\n",
GNUNET_h2s (&dh.hash),
TALER_amount2s (&ds->dcd.denom_balance));
- TALER_ARL_amount_add (&balance.total_escrowed,
- &balance.total_escrowed,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
&issue->value);
- TALER_ARL_amount_add (&balance.risk,
- &balance.risk,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
&issue->value);
ds->dcd.num_issued++;
TALER_ARL_amount_add (&ds->dcd.denom_balance,
@@ -1142,8 +1153,8 @@ check_known_coin (
loss_potential),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
- TALER_ARL_amount_add (&balance.irregular_loss,
- &balance.irregular_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
loss_potential);
}
TALER_denom_sig_free (&ci.denom_sig);
@@ -1154,7 +1165,7 @@ check_known_coin (
/**
* Update the denom balance in @a dso reducing it by
* @a amount_with_fee. If this is not possible, report
- * an emergency. Also updates the #balance.
+ * an emergency. Also updates the balance.
*
* @param dso denomination summary to update
* @param rowid responsible row (for logging)
@@ -1181,7 +1192,7 @@ reduce_denom_balance (struct DenominationSummary *dso,
{
dso->dcd.denom_balance = tmp;
}
- if (-1 == TALER_amount_cmp (&balance.total_escrowed,
+ if (-1 == TALER_amount_cmp (&TALER_ARL_USE_AB (total_escrowed),
amount_with_fee))
{
/* This can theoretically happen if for example the exchange
@@ -1193,14 +1204,14 @@ reduce_denom_balance (struct DenominationSummary *dso,
report_amount_arithmetic_inconsistency (
"subtracting amount from escrow balance",
rowid,
- &balance.total_escrowed,
+ &TALER_ARL_USE_AB (total_escrowed),
amount_with_fee,
0);
}
else
{
- TALER_ARL_amount_subtract (&balance.total_escrowed,
- &balance.total_escrowed,
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
amount_with_fee);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1246,8 +1257,9 @@ refresh_session_cb (void *cls,
enum GNUNET_DB_QueryStatus qs;
(void) noreveal_index;
- GNUNET_assert (rowid >= ppc.last_melt_serial_id); /* should be monotonically increasing */
- ppc.last_melt_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_melt_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_melt_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
@@ -1306,8 +1318,8 @@ refresh_session_cb (void *cls,
amount_with_fee),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
- TALER_ARL_amount_add (&balance.irregular_loss,
- &balance.irregular_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount_with_fee);
}
}
@@ -1453,11 +1465,11 @@ refresh_session_cb (void *cls,
"New balance of denomination `%s' is %s\n",
GNUNET_h2s (&ni->denom_hash.hash),
TALER_amount2s (&dsi->dcd.denom_balance));
- TALER_ARL_amount_add (&balance.total_escrowed,
- &balance.total_escrowed,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
&ni->value);
- TALER_ARL_amount_add (&balance.risk,
- &balance.risk,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
&ni->value);
}
}
@@ -1482,8 +1494,8 @@ refresh_session_cb (void *cls,
}
/* update global melt fees */
- TALER_ARL_amount_add (&balance.melt_fee_balance,
- &balance.melt_fee_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_melt_fee_revenue),
+ &TALER_ARL_USE_AB (coin_melt_fee_revenue),
&issue->fees.refresh);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1518,8 +1530,9 @@ deposit_cb (void *cls,
(void) done;
(void) exchange_timestamp;
- GNUNET_assert (rowid >= ppc.last_deposit_serial_id); /* should be monotonically increasing */
- ppc.last_deposit_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_deposit_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_deposit_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
@@ -1601,8 +1614,8 @@ deposit_cb (void *cls,
&deposit->amount_with_fee),
GNUNET_JSON_pack_data_auto ("coin_pub",
&deposit->coin.coin_pub)));
- TALER_ARL_amount_add (&balance.irregular_loss,
- &balance.irregular_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
&deposit->amount_with_fee);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1633,8 +1646,8 @@ deposit_cb (void *cls,
}
/* update global deposit fees */
- TALER_ARL_amount_add (&balance.deposit_fee_balance,
- &balance.deposit_fee_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_deposit_fee_revenue),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue),
&issue->fees.deposit);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1678,8 +1691,8 @@ refund_cb (void *cls,
struct TALER_Amount amount_without_fee;
enum GNUNET_DB_QueryStatus qs;
- GNUNET_assert (rowid >= ppc.last_refund_serial_id); /* should be monotonically increasing */
- ppc.last_refund_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (coins_refund_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_refund_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
@@ -1718,8 +1731,8 @@ refund_cb (void *cls,
amount_with_fee),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
- TALER_ARL_amount_add (&balance.irregular_loss,
- &balance.irregular_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount_with_fee);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1765,11 +1778,11 @@ refund_cb (void *cls,
TALER_ARL_amount_add (&ds->dcd.denom_risk,
&ds->dcd.denom_risk,
&amount_without_fee);
- TALER_ARL_amount_add (&balance.total_escrowed,
- &balance.total_escrowed,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
&amount_without_fee);
- TALER_ARL_amount_add (&balance.risk,
- &balance.risk,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
&amount_without_fee);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' after refund is %s\n",
@@ -1777,13 +1790,13 @@ refund_cb (void *cls,
TALER_amount2s (&ds->dcd.denom_balance));
}
/* update total refund fee balance */
- TALER_ARL_amount_add (&balance.refund_fee_balance,
- &balance.refund_fee_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_refund_fee_revenue),
+ &TALER_ARL_USE_AB (coin_refund_fee_revenue),
&issue->fees.refund);
if (full_refund)
{
- TALER_ARL_amount_subtract (&balance.deposit_fee_balance,
- &balance.deposit_fee_balance,
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (coin_deposit_fee_revenue),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue),
&issue->fees.deposit);
}
if (TALER_ARL_do_abort ())
@@ -1857,11 +1870,11 @@ purse_refund_coin_cb (
TALER_ARL_amount_add (&ds->dcd.denom_risk,
&ds->dcd.denom_risk,
amount_with_fee);
- TALER_ARL_amount_add (&balance.total_escrowed,
- &balance.total_escrowed,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
amount_with_fee);
- TALER_ARL_amount_add (&balance.risk,
- &balance.risk,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
amount_with_fee);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' after purse-refund is %s\n",
@@ -1869,8 +1882,8 @@ purse_refund_coin_cb (
TALER_amount2s (&ds->dcd.denom_balance));
}
/* update total deposit fee balance */
- TALER_ARL_amount_subtract (&balance.deposit_fee_balance,
- &balance.deposit_fee_balance,
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (coin_deposit_fee_revenue),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue),
&issue->fees.deposit);
return GNUNET_OK;
@@ -1901,8 +1914,9 @@ purse_refund_cb (void *cls,
(void) val; /* irrelevant on refund */
(void) reserve_pub; /* irrelevant, may even be NULL */
- GNUNET_assert (rowid >= ppc.last_purse_refunds_serial_id); /* should be monotonically increasing */
- ppc.last_purse_refunds_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_purse_refunds_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_purse_refunds_serial_id) = rowid + 1;
qs = TALER_ARL_edb->select_purse_deposits_by_purse (TALER_ARL_edb->cls,
purse_pub,
&purse_refund_coin_cb,
@@ -1970,8 +1984,8 @@ check_recoup (struct CoinContext *cc,
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->denom_pub_hash)));
- TALER_ARL_amount_add (&balance.irregular_loss,
- &balance.irregular_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount);
}
qs = TALER_ARL_get_denomination_info_by_hash (&coin->denom_pub_hash,
@@ -2031,15 +2045,15 @@ check_recoup (struct CoinContext *cc,
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->coin_pub)));
- TALER_ARL_amount_add (&balance.irregular_loss,
- &balance.irregular_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount);
}
TALER_ARL_amount_add (&ds->dcd.recoup_loss,
&ds->dcd.recoup_loss,
amount);
- TALER_ARL_amount_add (&balance.loss,
- &balance.loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_recoup_loss),
+ &TALER_ARL_USE_AB (total_recoup_loss),
amount);
}
if (TALER_ARL_do_abort ())
@@ -2075,8 +2089,8 @@ recoup_cb (void *cls,
{
struct CoinContext *cc = cls;
- GNUNET_assert (rowid >= ppc.last_recoup_serial_id); /* should be monotonically increasing */
- ppc.last_recoup_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (coins_recoup_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_recoup_serial_id) = rowid + 1;
(void) timestamp;
(void) reserve_pub;
if (GNUNET_OK !=
@@ -2095,8 +2109,8 @@ recoup_cb (void *cls,
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->coin_pub)));
- TALER_ARL_amount_add (&balance.irregular_loss,
- &balance.irregular_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -2147,8 +2161,8 @@ recoup_refresh_cb (void *cls,
(void) timestamp;
(void) old_coin_pub;
- GNUNET_assert (rowid >= ppc.last_recoup_refresh_serial_id); /* should be monotonically increasing */
- ppc.last_recoup_refresh_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (coins_recoup_refresh_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_recoup_refresh_serial_id) = rowid + 1;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Recoup-refresh amount is %s\n",
TALER_amount2s (amount));
@@ -2209,8 +2223,8 @@ recoup_refresh_cb (void *cls,
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->coin_pub)));
- TALER_ARL_amount_add (&balance.irregular_loss,
- &balance.irregular_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -2333,8 +2347,9 @@ purse_deposit_cb (
(void) auditor_balance;
(void) purse_total;
(void) reserve_pub;
- GNUNET_assert (rowid >= ppc.last_purse_deposits_serial_id);
- ppc.last_purse_deposits_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_purse_deposits_serial_id));
+ TALER_ARL_USE_PP (coins_purse_deposits_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
&dh);
@@ -2382,8 +2397,8 @@ purse_deposit_cb (
&deposit->amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&deposit->coin_pub)));
- TALER_ARL_amount_add (&balance.irregular_loss,
- &balance.irregular_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
&deposit->amount);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -2408,8 +2423,8 @@ purse_deposit_cb (
}
/* update global deposit fees */
- TALER_ARL_amount_add (&balance.deposit_fee_balance,
- &balance.deposit_fee_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_deposit_fee_revenue),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue),
&issue->fees.deposit);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -2444,9 +2459,17 @@ analyze_coins (void *cls)
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Analyzing coins\n");
- qsp = TALER_ARL_adb->get_auditor_progress_coin (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppc);
+ qsp = TALER_ARL_adb->get_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_PP (coins_withdraw_serial_id),
+ TALER_ARL_GET_PP (coins_deposit_serial_id),
+ TALER_ARL_GET_PP (coins_melt_serial_id),
+ TALER_ARL_GET_PP (coins_refund_serial_id),
+ TALER_ARL_GET_PP (coins_recoup_serial_id),
+ TALER_ARL_GET_PP (coins_recoup_refresh_serial_id),
+ TALER_ARL_GET_PP (coins_purse_deposits_serial_id),
+ TALER_ARL_GET_PP (coins_purse_refunds_serial_id),
+ NULL);
if (0 > qsp)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp);
@@ -2459,26 +2482,39 @@ analyze_coins (void *cls)
}
else
{
- ppc_start = ppc;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Resuming coin audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
- (unsigned long long) ppc.last_deposit_serial_id,
- (unsigned long long) ppc.last_melt_serial_id,
- (unsigned long long) ppc.last_refund_serial_id,
- (unsigned long long) ppc.last_withdraw_serial_id,
- (unsigned long long) ppc.last_recoup_refresh_serial_id,
- (unsigned long long) ppc.last_open_deposits_serial_id,
- (unsigned long long) ppc.last_purse_deposits_serial_id,
- (unsigned long long) ppc.last_purse_refunds_serial_id);
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_INFO,
+ "Resuming coin audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_deposit_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_melt_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_refund_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_withdraw_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_recoup_refresh_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_purse_deposits_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_purse_refunds_serial_id));
}
/* setup 'cc' */
cc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
cc.denom_summaries = GNUNET_CONTAINER_multihashmap_create (256,
GNUNET_NO);
- qsx = TALER_ARL_adb->get_balance_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &balance);
+ qsx = TALER_ARL_adb->get_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_AB (coin_balance_risk),
+ TALER_ARL_GET_AB (total_escrowed),
+ TALER_ARL_GET_AB (coin_irregular_loss),
+ TALER_ARL_GET_AB (coin_melt_fee_revenue),
+ TALER_ARL_GET_AB (coin_deposit_fee_revenue),
+ TALER_ARL_GET_AB (coin_refund_fee_revenue),
+ TALER_ARL_GET_AB (total_recoup_loss),
+ NULL);
if (0 > qsx)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
@@ -2489,7 +2525,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_withdrawals_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_withdraw_serial_id,
+ TALER_ARL_USE_PP (coins_withdraw_serial_id),
&withdraw_cb,
&cc)) )
{
@@ -2503,7 +2539,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_refunds_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_refund_serial_id,
+ TALER_ARL_USE_PP (coins_refund_serial_id),
&refund_cb,
&cc)))
{
@@ -2517,7 +2553,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_purse_decisions_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_purse_refunds_serial_id,
+ TALER_ARL_USE_PP (coins_purse_refunds_serial_id),
true, /* only go for refunds! */
&purse_refund_cb,
&cc)))
@@ -2532,7 +2568,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_recoup_refresh_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_recoup_refresh_serial_id,
+ TALER_ARL_USE_PP (coins_recoup_refresh_serial_id),
&recoup_refresh_cb,
&cc)))
{
@@ -2544,7 +2580,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_recoup_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_recoup_serial_id,
+ TALER_ARL_USE_PP (coins_recoup_serial_id),
&recoup_cb,
&cc)))
{
@@ -2558,7 +2594,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_refreshes_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_melt_serial_id,
+ TALER_ARL_USE_PP (coins_melt_serial_id),
&refresh_session_cb,
&cc)))
{
@@ -2572,7 +2608,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_coin_deposits_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_deposit_serial_id,
+ TALER_ARL_USE_PP (coins_deposit_serial_id),
&deposit_cb,
&cc)))
{
@@ -2586,7 +2622,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_purse_deposits_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_purse_deposits_serial_id,
+ TALER_ARL_USE_PP (coins_purse_deposits_serial_id),
&purse_deposit_cb,
&cc)))
{
@@ -2608,13 +2644,27 @@ analyze_coins (void *cls)
return cc.qs;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx)
- qs = TALER_ARL_adb->update_balance_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &balance);
+ qs = TALER_ARL_adb->update_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (coin_balance_risk),
+ TALER_ARL_SET_AB (total_escrowed),
+ TALER_ARL_SET_AB (coin_irregular_loss),
+ TALER_ARL_SET_AB (coin_melt_fee_revenue),
+ TALER_ARL_SET_AB (coin_deposit_fee_revenue),
+ TALER_ARL_SET_AB (coin_refund_fee_revenue),
+ TALER_ARL_SET_AB (total_recoup_loss),
+ NULL);
else
- qs = TALER_ARL_adb->insert_balance_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &balance);
+ qs = TALER_ARL_adb->insert_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (coin_balance_risk),
+ TALER_ARL_SET_AB (total_escrowed),
+ TALER_ARL_SET_AB (coin_irregular_loss),
+ TALER_ARL_SET_AB (coin_melt_fee_revenue),
+ TALER_ARL_SET_AB (coin_deposit_fee_revenue),
+ TALER_ARL_SET_AB (coin_refund_fee_revenue),
+ TALER_ARL_SET_AB (total_recoup_loss),
+ NULL);
if (0 >= qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
@@ -2622,13 +2672,29 @@ analyze_coins (void *cls)
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
- qs = TALER_ARL_adb->update_auditor_progress_coin (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppc);
+ qs = TALER_ARL_adb->update_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (coins_withdraw_serial_id),
+ TALER_ARL_SET_PP (coins_deposit_serial_id),
+ TALER_ARL_SET_PP (coins_melt_serial_id),
+ TALER_ARL_SET_PP (coins_refund_serial_id),
+ TALER_ARL_SET_PP (coins_recoup_serial_id),
+ TALER_ARL_SET_PP (coins_recoup_refresh_serial_id),
+ TALER_ARL_SET_PP (coins_purse_deposits_serial_id),
+ TALER_ARL_SET_PP (coins_purse_refunds_serial_id),
+ NULL);
else
- qs = TALER_ARL_adb->insert_auditor_progress_coin (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppc);
+ qs = TALER_ARL_adb->insert_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (coins_withdraw_serial_id),
+ TALER_ARL_SET_PP (coins_deposit_serial_id),
+ TALER_ARL_SET_PP (coins_melt_serial_id),
+ TALER_ARL_SET_PP (coins_refund_serial_id),
+ TALER_ARL_SET_PP (coins_recoup_serial_id),
+ TALER_ARL_SET_PP (coins_recoup_refresh_serial_id),
+ TALER_ARL_SET_PP (coins_purse_deposits_serial_id),
+ TALER_ARL_SET_PP (coins_purse_refunds_serial_id),
+ NULL);
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -2637,15 +2703,17 @@ analyze_coins (void *cls)
return qs;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Concluded coin audit step at %llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
- (unsigned long long) ppc.last_deposit_serial_id,
- (unsigned long long) ppc.last_melt_serial_id,
- (unsigned long long) ppc.last_refund_serial_id,
- (unsigned long long) ppc.last_withdraw_serial_id,
- (unsigned long long) ppc.last_recoup_refresh_serial_id,
- (unsigned long long) ppc.last_open_deposits_serial_id,
- (unsigned long long) ppc.last_purse_deposits_serial_id,
- (unsigned long long) ppc.last_purse_refunds_serial_id);
+ "Concluded coin audit step at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
+ (unsigned long long) TALER_ARL_USE_PP (coins_deposit_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (coins_melt_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (coins_refund_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (coins_withdraw_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_recoup_refresh_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_purse_deposits_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_purse_refunds_serial_id));
return qs;
}
@@ -2691,31 +2759,29 @@ run (void *cls,
&reported_emergency_loss_by_count));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.total_escrowed));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &balance.deposit_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &balance.melt_fee_balance));
+ &TALER_ARL_USE_AB (total_escrowed)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.refund_fee_balance));
+ &TALER_ARL_USE_AB (
+ coin_deposit_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.purse_fee_balance));
+ &TALER_ARL_USE_AB (
+ coin_melt_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.open_deposit_fee_balance));
+ &TALER_ARL_USE_AB (
+ coin_refund_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.risk));
+ &TALER_ARL_USE_AB (coin_balance_risk)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.loss));
+ &TALER_ARL_USE_AB (total_recoup_loss)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.irregular_loss));
+ &TALER_ARL_USE_AB (
+ coin_irregular_loss)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
&total_arithmetic_delta_plus));
@@ -2752,24 +2818,20 @@ run (void *cls,
TALER_ARL_done (
GNUNET_JSON_PACK (
TALER_JSON_pack_amount ("total_escrow_balance",
- &balance.total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed)),
TALER_JSON_pack_amount ("total_deposit_fee_income",
- &balance.deposit_fee_balance),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue)),
TALER_JSON_pack_amount ("total_melt_fee_income",
- &balance.melt_fee_balance),
+ &TALER_ARL_USE_AB (coin_melt_fee_revenue)),
TALER_JSON_pack_amount ("total_refund_fee_income",
- &balance.refund_fee_balance),
- TALER_JSON_pack_amount ("total_purse_fee_income",
- &balance.purse_fee_balance),
- TALER_JSON_pack_amount ("total_open_deposit_fee_income",
- &balance.open_deposit_fee_balance),
+ &TALER_ARL_USE_AB (coin_refund_fee_revenue)),
TALER_JSON_pack_amount ("total_active_risk",
- &balance.risk),
+ &TALER_ARL_USE_AB (coin_balance_risk)),
TALER_JSON_pack_amount ("total_recoup_loss",
- &balance.loss),
+ &TALER_ARL_USE_AB (total_recoup_loss)),
/* Tested in test-auditor.sh #4/#5/#6/#13/#26 */
TALER_JSON_pack_amount ("irregular_loss",
- &balance.irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss)),
/* Tested in test-auditor.sh #18 */
GNUNET_JSON_pack_array_steal ("emergencies",
report_emergencies),
@@ -2806,43 +2868,48 @@ run (void *cls,
TALER_JSON_pack_amount ("emergencies_loss_by_count",
&reported_emergency_loss_by_count),
GNUNET_JSON_pack_uint64 ("start_ppc_withdraw_serial_id",
- ppc_start.last_withdraw_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_deposit_serial_id",
- ppc_start.last_deposit_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_melt_serial_id",
- ppc_start.last_melt_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_refund_serial_id",
- ppc_start.last_refund_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_recoup_serial_id",
- ppc_start.last_recoup_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_recoup_refresh_serial_id",
- ppc_start.last_recoup_refresh_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_purse_deposits_serial_id",
- ppc_start.last_purse_deposits_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_purse_refunds_serial_id",
- ppc_start.last_purse_refunds_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("end_ppc_withdraw_serial_id",
- ppc.last_withdraw_serial_id),
+ TALER_ARL_USE_PP (coins_withdraw_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_deposit_serial_id",
- ppc.last_deposit_serial_id),
+ TALER_ARL_USE_PP (coins_deposit_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_melt_serial_id",
- ppc.last_melt_serial_id),
+ TALER_ARL_USE_PP (coins_melt_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_refund_serial_id",
- ppc.last_refund_serial_id),
+ TALER_ARL_USE_PP (coins_refund_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_recoup_serial_id",
- ppc.last_recoup_serial_id),
+ TALER_ARL_USE_PP (coins_recoup_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_recoup_refresh_serial_id",
- ppc.last_recoup_refresh_serial_id),
+ TALER_ARL_USE_PP (
+ coins_recoup_refresh_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_purse_deposits_serial_id",
- ppc.last_purse_deposits_serial_id),
+ TALER_ARL_USE_PP (
+ coins_purse_deposits_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_purse_refunds_serial_id",
- ppc.last_purse_refunds_serial_id),
- TALER_JSON_pack_time_abs_human ("auditor_start_time",
- start_time),
+ TALER_ARL_USE_PP (
+ coins_purse_refunds_serial_id)),
+ TALER_JSON_pack_time_abs_human (
+ "auditor_start_time",
+ start_time),
TALER_JSON_pack_time_abs_human ("auditor_end_time",
GNUNET_TIME_absolute_get ()),
- GNUNET_JSON_pack_array_steal ("unsigned_denominations",
- report_denominations_without_sigs)));
+ GNUNET_JSON_pack_array_steal (
+ "unsigned_denominations",
+ report_denominations_without_sigs)));
}
diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c
index 271f1c363..25697bbbc 100644
--- a/src/auditor/taler-helper-auditor-deposits.c
+++ b/src/auditor/taler-helper-auditor-deposits.c
@@ -218,18 +218,17 @@ test_dc (void *cls,
static enum GNUNET_DB_QueryStatus
analyze_deposit_confirmations (void *cls)
{
- struct TALER_AUDITORDB_ProgressPointDepositConfirmation ppdc;
+ TALER_ARL_DEF_PP (deposit_confirmation_serial_id);
struct DepositConfirmationContext dcc;
enum GNUNET_DB_QueryStatus qs;
enum GNUNET_DB_QueryStatus qsx;
enum GNUNET_DB_QueryStatus qsp;
(void) cls;
- ppdc.last_deposit_confirmation_serial_id = 0;
- qsp = TALER_ARL_adb->get_auditor_progress_deposit_confirmation (
+ qsp = TALER_ARL_adb->get_auditor_progress (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppdc);
+ TALER_ARL_GET_PP (deposit_confirmation_serial_id),
+ NULL);
if (0 > qsp)
{
@@ -245,7 +244,8 @@ analyze_deposit_confirmations (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming deposit confirmation audit at %llu\n",
- (unsigned long long) ppdc.last_deposit_confirmation_serial_id);
+ (unsigned long long) TALER_ARL_USE_PP (
+ deposit_confirmation_serial_id));
}
/* setup 'cc' */
@@ -255,11 +255,13 @@ analyze_deposit_confirmations (void *cls)
dcc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
dcc.missed_count = 0LLU;
dcc.first_missed_coin_serial = UINT64_MAX;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "lastdepconfserialid %lu\n",
- ppdc.last_deposit_confirmation_serial_id);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "lastdepconfserialid %lu\n",
+ TALER_ARL_USE_PP (deposit_confirmation_serial_id));
qsx = TALER_ARL_adb->get_deposit_confirmations (
TALER_ARL_adb->cls,
- ppdc.last_deposit_confirmation_serial_id,
+ TALER_ARL_USE_PP (deposit_confirmation_serial_id),
+ true, /* return suppressed */
&test_dc,
&dcc);
if (0 > qsx)
@@ -270,29 +272,30 @@ analyze_deposit_confirmations (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Analyzed %d deposit confirmations (above serial ID %llu)\n",
(int) qsx,
- (unsigned long long) ppdc.last_deposit_confirmation_serial_id);
+ (unsigned long long) TALER_ARL_USE_PP (
+ deposit_confirmation_serial_id));
if (0 > dcc.qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == dcc.qs);
return dcc.qs;
}
- if (UINT64_MAX == dcc.first_missed_coin_serial)
- ppdc.last_deposit_confirmation_serial_id = dcc.last_seen_coin_serial;
- else
- ppdc.last_deposit_confirmation_serial_id = dcc.first_missed_coin_serial - 1;
-
+ /* if (UINT64_MAX == dcc.first_missed_coin_serial)
+ ppdc.last_deposit_confirmation_serial_id = dcc.last_seen_coin_serial;
+ else
+ ppdc.last_deposit_confirmation_serial_id = dcc.first_missed_coin_serial - 1;
+ */
/* sync 'cc' back to disk */
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
- qs = TALER_ARL_adb->update_auditor_progress_deposit_confirmation (
+ qs = TALER_ARL_adb->update_auditor_progress (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppdc);
+ TALER_ARL_SET_PP (deposit_confirmation_serial_id),
+ NULL);
else
- qs = TALER_ARL_adb->insert_auditor_progress_deposit_confirmation (
+ qs = TALER_ARL_adb->insert_auditor_progress (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppdc);
+ TALER_ARL_SET_PP (deposit_confirmation_serial_id),
+ NULL);
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -306,7 +309,8 @@ analyze_deposit_confirmations (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Concluded deposit confirmation audit step at %llu\n",
- (unsigned long long) ppdc.last_deposit_confirmation_serial_id);
+ (unsigned long long) TALER_ARL_USE_PP (
+ deposit_confirmation_serial_id));
return qs;
}
diff --git a/src/auditor/taler-helper-auditor-purses.c b/src/auditor/taler-helper-auditor-purses.c
index 81291f97d..74cfb2075 100644
--- a/src/auditor/taler-helper-auditor-purses.c
+++ b/src/auditor/taler-helper-auditor-purses.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2016-2022 Taler Systems SA
+ 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 Affero Public License as published by the Free Software
@@ -41,17 +41,13 @@ static int global_ret;
/**
* Checkpointing our progress for purses.
*/
-static struct TALER_AUDITORDB_ProgressPointPurse ppp;
-
-/**
- * Checkpointing our progress for purses.
- */
-static struct TALER_AUDITORDB_ProgressPointPurse ppp_start;
-
-/**
- * Global statistics about purses.
- */
-static struct TALER_AUDITORDB_PurseBalance balance;
+static TALER_ARL_DEF_PP (purse_account_merge_serial_id);
+static TALER_ARL_DEF_PP (purse_decision_serial_id);
+static TALER_ARL_DEF_PP (purse_deposits_serial_id);
+static TALER_ARL_DEF_PP (purse_merges_serial_id);
+static TALER_ARL_DEF_PP (purse_request_serial_id);
+static TALER_ARL_DEF_PP (purse_open_counter);
+static TALER_ARL_DEF_AB (purse_global_balance);
/**
* Array of reports about row inconsistencies.
@@ -338,7 +334,6 @@ load_auditor_purse_summary (struct PurseSummary *ps)
qs = TALER_ARL_adb->get_purse_info (TALER_ARL_adb->cls,
&ps->purse_pub,
- &TALER_ARL_master_pub,
&rowid,
&ps->balance,
&ps->expiration_date);
@@ -476,6 +471,7 @@ handle_purse_requested (
struct PurseSummary *ps;
struct GNUNET_HashCode key;
+ TALER_ARL_USE_PP (purse_request_serial_id) = rowid;
if (GNUNET_OK !=
TALER_wallet_purse_create_verify (purse_expiration,
h_contract_terms,
@@ -556,8 +552,8 @@ handle_purse_deposits (
struct TALER_DenominationHashP h_denom_pub;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppp.last_purse_deposits_serial_id);
- ppp.last_purse_deposits_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (purse_deposits_serial_id));
+ TALER_ARL_USE_PP (purse_deposits_serial_id) = rowid + 1;
{
const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
@@ -635,8 +631,8 @@ handle_purse_deposits (
TALER_ARL_amount_add (&ps->balance,
&ps->balance,
&amount_minus_fee);
- TALER_ARL_amount_add (&balance.balance,
- &balance.balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (purse_global_balance),
+ &TALER_ARL_USE_AB (purse_global_balance),
&amount_minus_fee);
return GNUNET_OK;
}
@@ -677,8 +673,8 @@ handle_purse_merged (
struct PurseSummary *ps;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppp.last_purse_merge_serial_id);
- ppp.last_purse_merge_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (purse_merges_serial_id));
+ TALER_ARL_USE_PP (purse_merges_serial_id) = rowid + 1;
{
char *reserve_url;
@@ -779,8 +775,8 @@ handle_account_merged (
struct PurseSummary *ps;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppp.last_account_merge_serial_id);
- ppp.last_account_merge_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (purse_account_merge_serial_id));
+ TALER_ARL_USE_PP (purse_account_merge_serial_id) = rowid + 1;
if (GNUNET_OK !=
TALER_wallet_account_merge_verify (merge_timestamp,
purse_pub,
@@ -825,8 +821,8 @@ handle_account_merged (
}
return GNUNET_SYSERR;
}
- TALER_ARL_amount_add (&balance.balance,
- &balance.balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (purse_global_balance),
+ &TALER_ARL_USE_AB (purse_global_balance),
purse_fee);
TALER_ARL_amount_add (&ps->balance,
&ps->balance,
@@ -858,6 +854,7 @@ handle_purse_decision (
struct TALER_Amount purse_fee;
struct TALER_Amount balance_without_purse_fee;
+ TALER_ARL_USE_PP (purse_decision_serial_id) = rowid;
ps = setup_purse (pc,
purse_pub);
if (NULL == ps)
@@ -925,8 +922,7 @@ handle_purse_decision (
}
qs = TALER_ARL_adb->delete_purse_info (TALER_ARL_adb->cls,
- purse_pub,
- &TALER_ARL_master_pub);
+ purse_pub);
GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
if (qs < 0)
{
@@ -1047,12 +1043,10 @@ verify_purse_balance (void *cls,
if (ps->had_pi)
qs = TALER_ARL_adb->update_purse_info (TALER_ARL_adb->cls,
&ps->purse_pub,
- &TALER_ARL_master_pub,
&ps->balance);
else
qs = TALER_ARL_adb->insert_purse_info (TALER_ARL_adb->cls,
&ps->purse_pub,
- &TALER_ARL_master_pub,
&ps->balance,
ps->expiration_date);
GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
@@ -1090,9 +1084,15 @@ analyze_purses (void *cls)
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Analyzing purses\n");
- qsp = TALER_ARL_adb->get_auditor_progress_purse (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppp);
+ qsp = TALER_ARL_adb->get_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_PP (purse_account_merge_serial_id),
+ TALER_ARL_GET_PP (purse_decision_serial_id),
+ TALER_ARL_GET_PP (purse_deposits_serial_id),
+ TALER_ARL_GET_PP (purse_merges_serial_id),
+ TALER_ARL_GET_PP (purse_request_serial_id),
+ TALER_ARL_GET_PP (purse_open_counter),
+ NULL);
if (0 > qsp)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp);
@@ -1105,19 +1105,24 @@ analyze_purses (void *cls)
}
else
{
- ppp_start = ppp;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming purse audit at %llu/%llu/%llu/%llu/%llu\n",
- (unsigned long long) ppp.last_purse_request_serial_id,
- (unsigned long long) ppp.last_purse_decision_serial_id,
- (unsigned long long) ppp.last_purse_merge_serial_id,
- (unsigned long long) ppp.last_purse_deposits_serial_id,
- (unsigned long long) ppp.last_account_merge_serial_id);
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_request_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_decision_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_merges_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_deposits_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_account_merge_serial_id));
}
pc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
- qsx = TALER_ARL_adb->get_purse_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &balance);
+ qsx = TALER_ARL_adb->get_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_AB (purse_global_balance),
+ NULL);
if (qsx < 0)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
@@ -1128,7 +1133,7 @@ analyze_purses (void *cls)
qs = TALER_ARL_edb->select_purse_requests_above_serial_id (
TALER_ARL_edb->cls,
- ppp.last_purse_request_serial_id,
+ TALER_ARL_USE_PP (purse_request_serial_id),
&handle_purse_requested,
&pc);
if (qs < 0)
@@ -1139,7 +1144,7 @@ analyze_purses (void *cls)
qs = TALER_ARL_edb->select_purse_merges_above_serial_id (
TALER_ARL_edb->cls,
- ppp.last_purse_merge_serial_id,
+ TALER_ARL_USE_PP (purse_merges_serial_id),
&handle_purse_merged,
&pc);
if (qs < 0)
@@ -1149,7 +1154,7 @@ analyze_purses (void *cls)
}
qs = TALER_ARL_edb->select_purse_deposits_above_serial_id (
TALER_ARL_edb->cls,
- ppp.last_purse_deposits_serial_id,
+ TALER_ARL_USE_PP (purse_deposits_serial_id),
&handle_purse_deposits,
&pc);
if (qs < 0)
@@ -1160,7 +1165,7 @@ analyze_purses (void *cls)
/* Charge purse fee! */
qs = TALER_ARL_edb->select_account_merges_above_serial_id (
TALER_ARL_edb->cls,
- ppp.last_account_merge_serial_id,
+ TALER_ARL_USE_PP (purse_account_merge_serial_id),
&handle_account_merged,
&pc);
if (qs < 0)
@@ -1171,7 +1176,7 @@ analyze_purses (void *cls)
qs = TALER_ARL_edb->select_all_purse_decisions_above_serial_id (
TALER_ARL_edb->cls,
- ppp.last_purse_decision_serial_id,
+ TALER_ARL_USE_PP (purse_decision_serial_id),
&handle_purse_decision,
&pc);
if (qs < 0)
@@ -1182,7 +1187,6 @@ analyze_purses (void *cls)
qs = TALER_ARL_adb->select_purse_expired (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
&handle_purse_expired,
&pc);
if (qs < 0)
@@ -1201,15 +1205,17 @@ analyze_purses (void *cls)
return qs;
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx)
{
- qs = TALER_ARL_adb->insert_purse_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &balance);
+ qs = TALER_ARL_adb->insert_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (purse_global_balance),
+ NULL);
}
else
{
- qs = TALER_ARL_adb->update_purse_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &balance);
+ qs = TALER_ARL_adb->update_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (purse_global_balance),
+ NULL);
}
if (0 >= qs)
{
@@ -1217,13 +1223,25 @@ analyze_purses (void *cls)
return qs;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
- qs = TALER_ARL_adb->update_auditor_progress_purse (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppp);
+ qs = TALER_ARL_adb->update_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (purse_account_merge_serial_id),
+ TALER_ARL_SET_PP (purse_decision_serial_id),
+ TALER_ARL_SET_PP (purse_deposits_serial_id),
+ TALER_ARL_SET_PP (purse_merges_serial_id),
+ TALER_ARL_SET_PP (purse_request_serial_id),
+ TALER_ARL_SET_PP (purse_open_counter),
+ NULL);
else
- qs = TALER_ARL_adb->insert_auditor_progress_purse (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppp);
+ qs = TALER_ARL_adb->insert_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (purse_account_merge_serial_id),
+ TALER_ARL_SET_PP (purse_decision_serial_id),
+ TALER_ARL_SET_PP (purse_deposits_serial_id),
+ TALER_ARL_SET_PP (purse_merges_serial_id),
+ TALER_ARL_SET_PP (purse_request_serial_id),
+ TALER_ARL_SET_PP (purse_open_counter),
+ NULL);
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1233,11 +1251,16 @@ analyze_purses (void *cls)
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Concluded purse audit step at %llu/%llu/%llu/%llu/%llu\n",
- (unsigned long long) ppp.last_purse_request_serial_id,
- (unsigned long long) ppp.last_purse_decision_serial_id,
- (unsigned long long) ppp.last_purse_merge_serial_id,
- (unsigned long long) ppp.last_purse_deposits_serial_id,
- (unsigned long long) ppp.last_account_merge_serial_id);
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_request_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_decision_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_merges_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_deposits_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ purse_account_merge_serial_id));
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
}
@@ -1269,7 +1292,8 @@ run (void *cls,
}
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.balance));
+ &TALER_ARL_USE_AB (
+ purse_global_balance)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
&total_balance_insufficient_loss));
@@ -1330,9 +1354,9 @@ run (void *cls,
/* Global 'balances' */
TALER_JSON_pack_amount ("total_purse_balance",
- &balance.balance),
+ &TALER_ARL_USE_AB (purse_global_balance)),
GNUNET_JSON_pack_uint64 ("total_purse_count",
- balance.open_purses),
+ TALER_ARL_USE_PP (purse_open_counter)),
GNUNET_JSON_pack_array_steal ("purse_not_closed_inconsistencies",
report_purse_not_closed_inconsistencies),
@@ -1348,17 +1372,20 @@ run (void *cls,
TALER_JSON_pack_time_abs_human ("auditor_end_time",
GNUNET_TIME_absolute_get ()),
GNUNET_JSON_pack_uint64 ("start_ppp_purse_merges_serial_id",
- ppp_start.last_purse_merge_serial_id),
+ 0 /* not supported anymore */),
GNUNET_JSON_pack_uint64 ("start_ppp_purse_deposits_serial_id",
- ppp_start.last_purse_deposits_serial_id),
+ 0 /* not supported anymore */),
GNUNET_JSON_pack_uint64 ("start_ppp_account_merge_serial_id",
- ppp_start.last_account_merge_serial_id),
+ 0 /* not supported anymore */),
GNUNET_JSON_pack_uint64 ("end_ppp_purse_merges_serial_id",
- ppp.last_purse_merge_serial_id),
+ TALER_ARL_USE_PP (
+ purse_merges_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppp_purse_deposits_serial_id",
- ppp.last_purse_deposits_serial_id),
+ TALER_ARL_USE_PP (
+ purse_deposits_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppp_account_merge_serial_id",
- ppp.last_account_merge_serial_id)));
+ TALER_ARL_USE_PP (
+ purse_account_merge_serial_id))));
}
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c
index 6bd550373..fc1827e99 100644
--- a/src/auditor/taler-helper-auditor-reserves.c
+++ b/src/auditor/taler-helper-auditor-reserves.c
@@ -46,12 +46,26 @@ static struct GNUNET_TIME_Relative idle_reserve_expiration_time;
/**
* Checkpointing our progress for reserves.
*/
-static struct TALER_AUDITORDB_ProgressPointReserve ppr;
+static TALER_ARL_DEF_PP (reserves_reserve_in_serial_id);
+static TALER_ARL_DEF_PP (reserves_reserve_out_serial_id);
+static TALER_ARL_DEF_PP (reserves_reserve_recoup_serial_id);
+static TALER_ARL_DEF_PP (reserves_reserve_open_serial_id);
+static TALER_ARL_DEF_PP (reserves_reserve_close_serial_id);
+static TALER_ARL_DEF_PP (reserves_purse_decisions_serial_id);
+static TALER_ARL_DEF_PP (reserves_account_merges_serial_id);
+static TALER_ARL_DEF_PP (reserves_history_requests_serial_id);
/**
- * Checkpointing our progress for reserves.
+ * Tracked global reserve balances.
*/
-static struct TALER_AUDITORDB_ProgressPointReserve ppr_start;
+static TALER_ARL_DEF_AB (reserves_reserve_total_balance);
+static TALER_ARL_DEF_AB (reserves_reserve_loss);
+static TALER_ARL_DEF_AB (reserves_withdraw_fee_revenue);
+static TALER_ARL_DEF_AB (reserves_close_fee_revenue);
+static TALER_ARL_DEF_AB (reserves_purse_fee_revenue);
+static TALER_ARL_DEF_AB (reserves_open_fee_revenue);
+static TALER_ARL_DEF_AB (reserves_history_fee_revenue);
+
/**
* Array of reports about row inconsistencies.
@@ -120,11 +134,6 @@ static struct TALER_Amount total_arithmetic_delta_plus;
static struct TALER_Amount total_arithmetic_delta_minus;
/**
- * Expected reserve balances.
- */
-static struct TALER_AUDITORDB_ReserveFeeBalance balance;
-
-/**
* Array of reports about coin operations with bad signatures.
*/
static json_t *report_bad_sig_losses;
@@ -304,7 +313,6 @@ load_auditor_reserve_summary (struct ReserveSummary *rs)
qs = TALER_ARL_adb->get_reserve_info (TALER_ARL_adb->cls,
&rs->reserve_pub,
- &TALER_ARL_master_pub,
&rowid,
&rs->prev_balance,
&rs->a_expiration_date,
@@ -471,8 +479,8 @@ handle_reserve_in (void *cls,
(void) wire_reference;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppr.last_reserve_in_serial_id);
- ppr.last_reserve_in_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_in_serial_id));
+ TALER_ARL_USE_PP (reserves_reserve_in_serial_id) = rowid + 1;
rs = setup_reserve (rc,
reserve_pub);
if (NULL == rs)
@@ -532,8 +540,8 @@ handle_reserve_out (void *cls,
struct TALER_DenominationHashP h_denom_pub;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppr.last_reserve_out_serial_id);
- ppr.last_reserve_out_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_out_serial_id));
+ TALER_ARL_USE_PP (reserves_reserve_out_serial_id) = rowid + 1;
/* lookup denomination pub data (make sure denom_pub is valid, establish fees);
initializes wsrd.h_denomination_pub! */
@@ -640,8 +648,8 @@ handle_reserve_out (void *cls,
TALER_ARL_amount_add (&rs->curr_balance.withdraw_fee_balance,
&rs->curr_balance.withdraw_fee_balance,
&issue->fees.withdraw);
- TALER_ARL_amount_add (&balance.withdraw_fee_balance,
- &balance.withdraw_fee_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_withdraw_fee_revenue),
+ &TALER_ARL_USE_AB (reserves_withdraw_fee_revenue),
&issue->fees.withdraw);
TALER_ARL_amount_add (&rs->total_out,
&rs->total_out,
@@ -690,8 +698,8 @@ handle_recoup_by_reserve (
(void) denom_pub;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppr.last_reserve_recoup_serial_id);
- ppr.last_reserve_recoup_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_recoup_serial_id));
+ TALER_ARL_USE_PP (reserves_reserve_recoup_serial_id) = rowid + 1;
/* We know that denom_pub matches denom_pub_hash because this
is how the SQL statement joined the tables. */
if (GNUNET_OK !=
@@ -735,8 +743,8 @@ handle_recoup_by_reserve (
report_row_inconsistency ("recoup",
rowid,
"denomination key not in revocation set");
- TALER_ARL_amount_add (&balance.reserve_loss,
- &balance.reserve_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_reserve_loss),
+ &TALER_ARL_USE_AB (reserves_reserve_loss),
amount);
}
else
@@ -892,8 +900,8 @@ handle_reserve_open (
struct ReserveSummary *rs;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppr.last_reserve_open_serial_id);
- ppr.last_reserve_open_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_open_serial_id));
+ TALER_ARL_USE_PP (reserves_reserve_open_serial_id) = rowid + 1;
rs = setup_reserve (rc,
reserve_pub);
@@ -928,8 +936,8 @@ handle_reserve_open (
TALER_ARL_amount_add (&rs->curr_balance.open_fee_balance,
&rs->curr_balance.open_fee_balance,
reserve_payment);
- TALER_ARL_amount_add (&balance.open_fee_balance,
- &balance.open_fee_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_open_fee_revenue),
+ &TALER_ARL_USE_AB (reserves_open_fee_revenue),
reserve_payment);
TALER_ARL_amount_add (&rs->total_out,
&rs->total_out,
@@ -977,8 +985,8 @@ handle_reserve_closed (
(void) transfer_details;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppr.last_reserve_close_serial_id);
- ppr.last_reserve_close_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_close_serial_id));
+ TALER_ARL_USE_PP (reserves_reserve_close_serial_id) = rowid + 1;
rs = setup_reserve (rc,
reserve_pub);
@@ -1013,8 +1021,8 @@ handle_reserve_closed (
TALER_ARL_amount_add (&rs->curr_balance.close_fee_balance,
&rs->curr_balance.close_fee_balance,
closing_fee);
- TALER_ARL_amount_add (&balance.close_fee_balance,
- &balance.close_fee_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_close_fee_revenue),
+ &TALER_ARL_USE_AB (reserves_close_fee_revenue),
closing_fee);
TALER_ARL_amount_add (&rs->total_out,
&rs->total_out,
@@ -1168,8 +1176,8 @@ handle_account_merged (
struct ReserveSummary *rs;
/* should be monotonically increasing */
- GNUNET_assert (rowid >= ppr.last_account_merges_serial_id);
- ppr.last_account_merges_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_account_merges_serial_id));
+ TALER_ARL_USE_PP (reserves_account_merges_serial_id) = rowid + 1;
if (GNUNET_OK !=
TALER_wallet_account_merge_verify (merge_timestamp,
purse_pub,
@@ -1207,8 +1215,8 @@ handle_account_merged (
GNUNET_break (0);
return GNUNET_SYSERR;
}
- TALER_ARL_amount_add (&balance.purse_fee_balance,
- &balance.purse_fee_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_purse_fee_revenue),
+ &TALER_ARL_USE_AB (reserves_purse_fee_revenue),
purse_fee);
TALER_ARL_amount_add (&rs->curr_balance.purse_fee_balance,
&rs->curr_balance.purse_fee_balance,
@@ -1242,8 +1250,9 @@ purse_decision_cb (void *cls,
struct ReserveContext *rc = cls;
struct ReserveSummary *rs;
- GNUNET_assert (rowid >= ppr.last_purse_decisions_serial_id); /* should be monotonically increasing */
- ppr.last_purse_decisions_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (
+ reserves_purse_decisions_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (reserves_purse_decisions_serial_id) = rowid + 1;
rs = setup_reserve (rc,
reserve_pub);
if (NULL == rs)
@@ -1302,8 +1311,8 @@ verify_reserve_balance (void *cls,
TALER_ARL_amount_add (&rs->curr_balance.reserve_loss,
&rs->prev_balance.reserve_loss,
&loss);
- TALER_ARL_amount_add (&balance.reserve_loss,
- &balance.reserve_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_reserve_loss),
+ &TALER_ARL_USE_AB (reserves_reserve_loss),
&loss);
TALER_ARL_report (report_reserve_balance_insufficient_inconsistencies,
GNUNET_JSON_PACK (
@@ -1478,15 +1487,16 @@ verify_reserve_balance (void *cls,
/* Update global balance: add incoming first, then try
to subtract outgoing... */
- TALER_ARL_amount_add (&balance.reserve_balance,
- &balance.reserve_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_reserve_total_balance),
+ &TALER_ARL_USE_AB (reserves_reserve_total_balance),
&rs->total_in);
{
struct TALER_Amount r;
if (TALER_ARL_SR_INVALID_NEGATIVE ==
TALER_ARL_amount_subtract_neg (&r,
- &balance.reserve_balance,
+ &TALER_ARL_USE_AB (
+ reserves_reserve_total_balance),
&rs->total_out))
{
/* We could not reduce our total balance, i.e. exchange allowed IN TOTAL (!)
@@ -1494,18 +1504,20 @@ verify_reserve_balance (void *cls,
went negative!). Woopsie. Calculate how badly it went and log. */
report_amount_arithmetic_inconsistency ("global escrow balance",
0,
- &balance.reserve_balance, /* what we had */
+ &TALER_ARL_USE_AB (
+ reserves_reserve_total_balance), /* what we had */
&rs->total_out, /* what we needed */
0 /* specific profit/loss does not apply to the total summary */);
/* We unexpectedly went negative, so a sane value to continue from
would be zero. */
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.reserve_balance));
+ &TALER_ARL_USE_AB (
+ reserves_reserve_total_balance)));
}
else
{
- balance.reserve_balance = r;
+ TALER_ARL_USE_AB (reserves_reserve_total_balance) = r;
}
}
@@ -1518,8 +1530,7 @@ verify_reserve_balance (void *cls,
"Final balance of reserve `%s' is zero, dropping it\n",
TALER_B2S (&rs->reserve_pub));
qs = TALER_ARL_adb->del_reserve_info (TALER_ARL_adb->cls,
- &rs->reserve_pub,
- &TALER_ARL_master_pub);
+ &rs->reserve_pub);
if (0 >= qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
@@ -1544,13 +1555,11 @@ verify_reserve_balance (void *cls,
if (rs->had_ri)
qs = TALER_ARL_adb->update_reserve_info (TALER_ARL_adb->cls,
&rs->reserve_pub,
- &TALER_ARL_master_pub,
&rs->prev_balance,
rs->a_expiration_date);
else
qs = TALER_ARL_adb->insert_reserve_info (TALER_ARL_adb->cls,
&rs->reserve_pub,
- &TALER_ARL_master_pub,
&rs->prev_balance,
rs->a_expiration_date,
rs->sender_account);
@@ -1589,9 +1598,17 @@ analyze_reserves (void *cls)
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Analyzing reserves\n");
- qsp = TALER_ARL_adb->get_auditor_progress_reserve (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppr);
+ qsp = TALER_ARL_adb->get_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_PP (reserves_reserve_in_serial_id),
+ TALER_ARL_GET_PP (reserves_reserve_out_serial_id),
+ TALER_ARL_GET_PP (reserves_reserve_recoup_serial_id),
+ TALER_ARL_GET_PP (reserves_reserve_open_serial_id),
+ TALER_ARL_GET_PP (reserves_reserve_close_serial_id),
+ TALER_ARL_GET_PP (reserves_purse_decisions_serial_id),
+ TALER_ARL_GET_PP (reserves_account_merges_serial_id),
+ TALER_ARL_GET_PP (reserves_history_requests_serial_id),
+ NULL);
if (0 > qsp)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp);
@@ -1604,22 +1621,36 @@ analyze_reserves (void *cls)
}
else
{
- ppr_start = ppr;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming reserve audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
- (unsigned long long) ppr.last_reserve_in_serial_id,
- (unsigned long long) ppr.last_reserve_out_serial_id,
- (unsigned long long) ppr.last_reserve_recoup_serial_id,
- (unsigned long long) ppr.last_reserve_open_serial_id,
- (unsigned long long) ppr.last_reserve_close_serial_id,
- (unsigned long long) ppr.last_purse_decisions_serial_id,
- (unsigned long long) ppr.last_account_merges_serial_id,
- (unsigned long long) ppr.last_history_requests_serial_id);
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_in_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_out_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_recoup_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_open_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_close_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_purse_decisions_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_account_merges_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_history_requests_serial_id));
}
rc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
- qsx = TALER_ARL_adb->get_reserve_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &balance);
+ qsx = TALER_ARL_adb->get_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_AB (reserves_reserve_total_balance),
+ TALER_ARL_GET_AB (reserves_reserve_loss),
+ TALER_ARL_GET_AB (reserves_withdraw_fee_revenue),
+ TALER_ARL_GET_AB (reserves_close_fee_revenue),
+ TALER_ARL_GET_AB (reserves_purse_fee_revenue),
+ TALER_ARL_GET_AB (reserves_open_fee_revenue),
+ TALER_ARL_GET_AB (reserves_history_fee_revenue),
+ NULL);
if (qsx < 0)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
@@ -1631,7 +1662,7 @@ analyze_reserves (void *cls)
GNUNET_NO);
qs = TALER_ARL_edb->select_reserves_in_above_serial_id (
TALER_ARL_edb->cls,
- ppr.last_reserve_in_serial_id,
+ TALER_ARL_USE_PP (reserves_reserve_in_serial_id),
&handle_reserve_in,
&rc);
if (qs < 0)
@@ -1641,7 +1672,7 @@ analyze_reserves (void *cls)
}
qs = TALER_ARL_edb->select_withdrawals_above_serial_id (
TALER_ARL_edb->cls,
- ppr.last_reserve_out_serial_id,
+ TALER_ARL_USE_PP (reserves_reserve_out_serial_id),
&handle_reserve_out,
&rc);
if (qs < 0)
@@ -1651,7 +1682,7 @@ analyze_reserves (void *cls)
}
qs = TALER_ARL_edb->select_recoup_above_serial_id (
TALER_ARL_edb->cls,
- ppr.last_reserve_recoup_serial_id,
+ TALER_ARL_USE_PP (reserves_reserve_recoup_serial_id),
&handle_recoup_by_reserve,
&rc);
if (qs < 0)
@@ -1661,7 +1692,7 @@ analyze_reserves (void *cls)
}
qs = TALER_ARL_edb->select_reserve_open_above_serial_id (
TALER_ARL_edb->cls,
- ppr.last_reserve_open_serial_id,
+ TALER_ARL_USE_PP (reserves_reserve_open_serial_id),
&handle_reserve_open,
&rc);
if (qs < 0)
@@ -1671,7 +1702,7 @@ analyze_reserves (void *cls)
}
qs = TALER_ARL_edb->select_reserve_closed_above_serial_id (
TALER_ARL_edb->cls,
- ppr.last_reserve_close_serial_id,
+ TALER_ARL_USE_PP (reserves_reserve_close_serial_id),
&handle_reserve_closed,
&rc);
if (qs < 0)
@@ -1683,7 +1714,7 @@ analyze_reserves (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_purse_decisions_above_serial_id (
TALER_ARL_edb->cls,
- ppr.last_purse_decisions_serial_id,
+ TALER_ARL_USE_PP (reserves_purse_decisions_serial_id),
false, /* only go for merged purses! */
&purse_decision_cb,
&rc)))
@@ -1696,7 +1727,7 @@ analyze_reserves (void *cls)
/* Charge purse fee! */
qs = TALER_ARL_edb->select_account_merges_above_serial_id (
TALER_ARL_edb->cls,
- ppr.last_account_merges_serial_id,
+ TALER_ARL_USE_PP (reserves_account_merges_serial_id),
&handle_account_merged,
&rc);
if (qs < 0)
@@ -1715,15 +1746,29 @@ analyze_reserves (void *cls)
return qs;
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx)
{
- qs = TALER_ARL_adb->insert_reserve_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &balance);
+ qs = TALER_ARL_adb->insert_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (reserves_reserve_total_balance),
+ TALER_ARL_SET_AB (reserves_reserve_loss),
+ TALER_ARL_SET_AB (reserves_withdraw_fee_revenue),
+ TALER_ARL_SET_AB (reserves_close_fee_revenue),
+ TALER_ARL_SET_AB (reserves_purse_fee_revenue),
+ TALER_ARL_SET_AB (reserves_open_fee_revenue),
+ TALER_ARL_SET_AB (reserves_history_fee_revenue),
+ NULL);
}
else
{
- qs = TALER_ARL_adb->update_reserve_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &balance);
+ qs = TALER_ARL_adb->update_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (reserves_reserve_total_balance),
+ TALER_ARL_SET_AB (reserves_reserve_loss),
+ TALER_ARL_SET_AB (reserves_withdraw_fee_revenue),
+ TALER_ARL_SET_AB (reserves_close_fee_revenue),
+ TALER_ARL_SET_AB (reserves_purse_fee_revenue),
+ TALER_ARL_SET_AB (reserves_open_fee_revenue),
+ TALER_ARL_SET_AB (reserves_history_fee_revenue),
+ NULL);
}
if (0 >= qs)
{
@@ -1731,13 +1776,29 @@ analyze_reserves (void *cls)
return qs;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
- qs = TALER_ARL_adb->update_auditor_progress_reserve (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppr);
+ qs = TALER_ARL_adb->update_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (reserves_reserve_in_serial_id),
+ TALER_ARL_SET_PP (reserves_reserve_out_serial_id),
+ TALER_ARL_SET_PP (reserves_reserve_recoup_serial_id),
+ TALER_ARL_SET_PP (reserves_reserve_open_serial_id),
+ TALER_ARL_SET_PP (reserves_reserve_close_serial_id),
+ TALER_ARL_SET_PP (reserves_purse_decisions_serial_id),
+ TALER_ARL_SET_PP (reserves_account_merges_serial_id),
+ TALER_ARL_SET_PP (reserves_history_requests_serial_id),
+ NULL);
else
- qs = TALER_ARL_adb->insert_auditor_progress_reserve (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppr);
+ qs = TALER_ARL_adb->insert_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (reserves_reserve_in_serial_id),
+ TALER_ARL_SET_PP (reserves_reserve_out_serial_id),
+ TALER_ARL_SET_PP (reserves_reserve_recoup_serial_id),
+ TALER_ARL_SET_PP (reserves_reserve_open_serial_id),
+ TALER_ARL_SET_PP (reserves_reserve_close_serial_id),
+ TALER_ARL_SET_PP (reserves_purse_decisions_serial_id),
+ TALER_ARL_SET_PP (reserves_account_merges_serial_id),
+ TALER_ARL_SET_PP (reserves_history_requests_serial_id),
+ NULL);
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1747,14 +1808,22 @@ analyze_reserves (void *cls)
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Concluded reserve audit step at %llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
- (unsigned long long) ppr.last_reserve_in_serial_id,
- (unsigned long long) ppr.last_reserve_out_serial_id,
- (unsigned long long) ppr.last_reserve_recoup_serial_id,
- (unsigned long long) ppr.last_reserve_open_serial_id,
- (unsigned long long) ppr.last_reserve_close_serial_id,
- (unsigned long long) ppr.last_purse_decisions_serial_id,
- (unsigned long long) ppr.last_account_merges_serial_id,
- (unsigned long long) ppr.last_history_requests_serial_id);
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_in_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_out_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_recoup_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_open_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_reserve_close_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_purse_decisions_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_account_merges_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ reserves_history_requests_serial_id));
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
}
@@ -1800,25 +1869,32 @@ run (void *cls,
"Starting audit\n");
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.reserve_balance));
+ &TALER_ARL_USE_AB (
+ reserves_reserve_total_balance)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.reserve_loss));
+ &TALER_ARL_USE_AB (
+ reserves_reserve_loss)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.withdraw_fee_balance));
+ &TALER_ARL_USE_AB (
+ reserves_withdraw_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.close_fee_balance));
+ &TALER_ARL_USE_AB (
+ reserves_close_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.purse_fee_balance));
+ &TALER_ARL_USE_AB (
+ reserves_purse_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.open_fee_balance));
+ &TALER_ARL_USE_AB (
+ reserves_open_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &balance.history_fee_balance));
+ &TALER_ARL_USE_AB (
+ reserves_history_fee_revenue)));
// REVIEW:
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
@@ -1891,20 +1967,22 @@ run (void *cls,
/* Global 'balances' */
TALER_JSON_pack_amount ("total_escrow_balance",
- &balance.reserve_balance),
+ &TALER_ARL_USE_AB (
+ reserves_reserve_total_balance)),
/* Tested in test-auditor.sh #3 */
TALER_JSON_pack_amount ("total_irregular_loss",
- &balance.reserve_loss),
+ &TALER_ARL_USE_AB (reserves_reserve_loss)),
TALER_JSON_pack_amount ("total_withdraw_fee_income",
- &balance.withdraw_fee_balance),
+ &TALER_ARL_USE_AB (
+ reserves_withdraw_fee_revenue)),
TALER_JSON_pack_amount ("total_close_fee_income",
- &balance.close_fee_balance),
+ &TALER_ARL_USE_AB (reserves_close_fee_revenue)),
TALER_JSON_pack_amount ("total_purse_fee_income",
- &balance.purse_fee_balance),
+ &TALER_ARL_USE_AB (reserves_purse_fee_revenue)),
TALER_JSON_pack_amount ("total_open_fee_income",
- &balance.open_fee_balance),
+ &TALER_ARL_USE_AB (reserves_open_fee_revenue)),
TALER_JSON_pack_amount ("total_history_fee_income",
- &balance.history_fee_balance),
+ &TALER_ARL_USE_AB (reserves_history_fee_revenue)),
/* Detailed report tables */
GNUNET_JSON_pack_array_steal (
@@ -1935,37 +2013,45 @@ run (void *cls,
TALER_JSON_pack_time_abs_human ("auditor_end_time",
GNUNET_TIME_absolute_get ()),
GNUNET_JSON_pack_uint64 ("start_ppr_reserve_in_serial_id",
- ppr_start.last_reserve_in_serial_id),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("start_ppr_reserve_out_serial_id",
- ppr_start.last_reserve_out_serial_id),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("start_ppr_reserve_recoup_serial_id",
- ppr_start.last_reserve_recoup_serial_id),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("start_ppr_reserve_open_serial_id",
- ppr_start.last_reserve_open_serial_id),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("start_ppr_reserve_close_serial_id",
- ppr_start.last_reserve_close_serial_id),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("start_ppr_purse_decisions_serial_id",
- ppr_start.last_purse_decisions_serial_id),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("start_ppr_account_merges_serial_id",
- ppr_start.last_account_merges_serial_id),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("start_ppr_history_requests_serial_id",
- ppr_start.last_history_requests_serial_id),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("end_ppr_reserve_in_serial_id",
- ppr.last_reserve_in_serial_id),
+ TALER_ARL_USE_PP (
+ reserves_reserve_in_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppr_reserve_out_serial_id",
- ppr.last_reserve_out_serial_id),
+ TALER_ARL_USE_PP (
+ reserves_reserve_out_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppr_reserve_recoup_serial_id",
- ppr.last_reserve_recoup_serial_id),
+ TALER_ARL_USE_PP (
+ reserves_reserve_recoup_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppr_reserve_open_serial_id",
- ppr.last_reserve_open_serial_id),
+ TALER_ARL_USE_PP (
+ reserves_reserve_open_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppr_reserve_close_serial_id",
- ppr.last_reserve_close_serial_id),
+ TALER_ARL_USE_PP (
+ reserves_reserve_close_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppr_purse_decisions_serial_id",
- ppr.last_purse_decisions_serial_id),
+ TALER_ARL_USE_PP (
+ reserves_purse_decisions_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppr_account_merges_serial_id",
- ppr.last_account_merges_serial_id),
+ TALER_ARL_USE_PP (
+ reserves_account_merges_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppr_history_requests_serial_id",
- ppr.last_history_requests_serial_id)));
+ TALER_ARL_USE_PP (
+ reserves_history_requests_serial_id))));
}
diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c
index babf4bf28..fd920e87e 100644
--- a/src/auditor/taler-helper-auditor-wire.c
+++ b/src/auditor/taler-helper-auditor-wire.c
@@ -52,6 +52,12 @@
15)
+struct TALER_AUDITORDB_WireAccountProgressPoint
+{
+ uint64_t last_reserve_in_serial_id;
+ uint64_t last_wire_out_serial_id;
+};
+
/**
* Information we keep for each supported account.
*/
@@ -93,9 +99,34 @@ struct WireAccount
struct TALER_AUDITORDB_WireAccountProgressPoint start_pp;
/**
- * Where we are in the transaction history.
+ * Where we are in the inbound transaction history.
+ */
+ uint64_t wire_off_in;
+
+ /**
+ * Where we are in the outbound transaction history.
*/
- struct TALER_AUDITORDB_BankAccountProgressPoint wire_off;
+ uint64_t wire_off_out;
+
+ /**
+ * Label under which we store our pp's reserve_in_serial_id.
+ */
+ char *label_reserve_in_serial_id;
+
+ /**
+ * Label under which we store our pp's reserve_in_serial_id.
+ */
+ char *label_wire_out_serial_id;
+
+ /**
+ * Label under which we store our wire_off_in.
+ */
+ char *label_wire_off_in;
+
+ /**
+ * Label under which we store our wire_off_out.
+ */
+ char *label_wire_off_out;
/**
* Return value when we got this account's progress point.
@@ -178,12 +209,9 @@ static enum GNUNET_DB_QueryStatus qsx_gwap;
/**
* Last reserve_in / wire_out serial IDs seen.
*/
-static struct TALER_AUDITORDB_WireProgressPoint pp;
-
-/**
- * Last reserve_in / wire_out serial IDs seen.
- */
-static struct TALER_AUDITORDB_WireProgressPoint start_pp;
+static TALER_ARL_DEF_PP (wire_reserve_close_id);
+static TALER_ARL_DEF_PP (wire_batch_deposit_id);
+static TALER_ARL_DEF_PP (wire_aggregation_id);
/**
* Array of reports about row inconsistencies in wire_out table.
@@ -302,17 +330,17 @@ static struct TALER_Amount total_wire_out;
/**
* Total amount of profits drained.
*/
-static struct TALER_Amount total_drained;
+static TALER_ARL_DEF_AB (total_drained);
/**
- * Starting balance at the beginning of this iteration.
+ * Final balance at the end of this iteration.
*/
-static struct TALER_Amount start_balance;
+static TALER_ARL_DEF_AB (final_balance);
/**
- * Final balance at the end of this iteration.
+ * Starting balance at the beginning of this iteration.
*/
-static struct TALER_Amount final_balance;
+static struct TALER_Amount start_balance;
/**
* True if #start_balance was initialized.
@@ -525,9 +553,9 @@ do_shutdown (void *cls)
TALER_JSON_pack_amount ("total_wire_out",
&total_wire_out),
TALER_JSON_pack_amount ("total_drained",
- &total_drained),
+ &TALER_ARL_USE_AB (total_drained)),
TALER_JSON_pack_amount ("final_balance",
- &final_balance),
+ &TALER_ARL_USE_AB (final_balance)),
/* Tested in test-auditor.sh #1 */
TALER_JSON_pack_amount ("total_amount_lag",
&total_amount_lag),
@@ -549,17 +577,17 @@ do_shutdown (void *cls)
TALER_JSON_pack_time_abs_human ("wire_auditor_end_time",
GNUNET_TIME_absolute_get ()),
GNUNET_JSON_pack_uint64 ("start_pp_reserve_close_id",
- start_pp.last_reserve_close_uuid),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("end_pp_reserve_close_id",
- pp.last_reserve_close_uuid),
+ TALER_ARL_USE_PP (wire_reserve_close_id)),
GNUNET_JSON_pack_uint64 ("start_pp_last_batch_deposit_id",
- start_pp.last_batch_deposit_uuid),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("end_pp_last_batch_deposit_id",
- pp.last_batch_deposit_uuid),
+ TALER_ARL_USE_PP (wire_batch_deposit_id)),
GNUNET_JSON_pack_uint64 ("start_pp_last_aggregation_serial_id",
- start_pp.last_aggregation_serial),
+ 0 /* no longer supported */),
GNUNET_JSON_pack_uint64 ("end_pp_last_aggregation_serial_id",
- pp.last_aggregation_serial),
+ TALER_ARL_USE_PP (wire_aggregation_id)),
GNUNET_JSON_pack_array_steal ("account_progress",
report_account_progress)));
report_wire_out_inconsistencies = NULL;
@@ -617,6 +645,10 @@ do_shutdown (void *cls)
GNUNET_CONTAINER_DLL_remove (wa_head,
wa_tail,
wa);
+ GNUNET_free (wa->label_reserve_in_serial_id);
+ GNUNET_free (wa->label_wire_out_serial_id);
+ GNUNET_free (wa->label_wire_off_in);
+ GNUNET_free (wa->label_wire_off_out);
GNUNET_free (wa);
}
if (NULL != ctx)
@@ -671,8 +703,8 @@ check_pending_rc (void *cls,
&rc->wtid),
GNUNET_JSON_pack_string ("account",
rc->receiver_account)));
- pp.last_reserve_close_uuid
- = GNUNET_MIN (pp.last_reserve_close_uuid,
+ TALER_ARL_USE_PP (wire_reserve_close_id)
+ = GNUNET_MIN (TALER_ARL_USE_PP (wire_reserve_close_id),
rc->rowid);
return GNUNET_OK;
}
@@ -724,30 +756,32 @@ commit (enum GNUNET_DB_QueryStatus qs)
TALER_ARL_amount_add (&sum,
&total_wire_in,
&start_balance);
- TALER_ARL_amount_subtract (&final_balance,
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (final_balance),
&sum,
&total_wire_out);
- qs = TALER_ARL_adb->update_predicted_result (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &final_balance,
- &total_drained);
+ qs = TALER_ARL_adb->update_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (total_drained),
+ TALER_ARL_SET_AB (final_balance),
+ NULL);
}
else
{
- TALER_ARL_amount_subtract (&final_balance,
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (final_balance),
&total_wire_in,
&total_wire_out);
- qs = TALER_ARL_adb->insert_predicted_result (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &final_balance,
- &total_drained);
+ qs = TALER_ARL_adb->insert_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (total_drained),
+ TALER_ARL_SET_AB (final_balance),
+ NULL);
}
}
else
{
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &final_balance));
+ &TALER_ARL_USE_AB (final_balance)));
}
if (0 > qs)
{
@@ -781,19 +815,29 @@ commit (enum GNUNET_DB_QueryStatus qs)
GNUNET_JSON_pack_uint64 ("end_wire_out",
wa->pp.last_wire_out_serial_id))));
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == wa->qsx)
- qs = TALER_ARL_adb->update_wire_auditor_account_progress (
+ qs = TALER_ARL_adb->update_auditor_progress (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- wa->ai->section_name,
- &wa->pp,
- &wa->wire_off);
+ wa->label_reserve_in_serial_id,
+ wa->pp.last_reserve_in_serial_id,
+ wa->label_wire_out_serial_id,
+ wa->pp.last_wire_out_serial_id,
+ wa->label_wire_off_in,
+ wa->wire_off_in,
+ wa->label_wire_off_out,
+ wa->wire_off_out,
+ NULL);
else
- qs = TALER_ARL_adb->insert_wire_auditor_account_progress (
+ qs = TALER_ARL_adb->insert_auditor_progress (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- wa->ai->section_name,
- &wa->pp,
- &wa->wire_off);
+ wa->label_reserve_in_serial_id,
+ wa->pp.last_reserve_in_serial_id,
+ wa->label_wire_out_serial_id,
+ wa->pp.last_wire_out_serial_id,
+ wa->label_wire_off_in,
+ wa->wire_off_in,
+ wa->label_wire_off_out,
+ wa->wire_off_out,
+ NULL);
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -806,13 +850,19 @@ commit (enum GNUNET_DB_QueryStatus qs)
&check_pending_rc,
NULL);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx_gwap)
- qs = TALER_ARL_adb->update_wire_auditor_progress (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &pp);
+ qs = TALER_ARL_adb->update_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (wire_reserve_close_id),
+ TALER_ARL_SET_PP (wire_batch_deposit_id),
+ TALER_ARL_SET_PP (wire_aggregation_id),
+ NULL);
else
- qs = TALER_ARL_adb->insert_wire_auditor_progress (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &pp);
+ qs = TALER_ARL_adb->insert_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (wire_reserve_close_id),
+ TALER_ARL_SET_PP (wire_batch_deposit_id),
+ TALER_ARL_SET_PP (wire_aggregation_id),
+ NULL);
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -822,8 +872,8 @@ commit (enum GNUNET_DB_QueryStatus qs)
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Concluded audit step at %llu/%llu\n",
- (unsigned long long) pp.last_aggregation_serial,
- (unsigned long long) pp.last_batch_deposit_uuid);
+ (unsigned long long) TALER_ARL_USE_PP (wire_aggregation_id),
+ (unsigned long long) TALER_ARL_USE_PP (wire_batch_deposit_id));
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
{
@@ -902,7 +952,6 @@ import_wire_missing_cb (void *cls,
wc->max_batch_deposit_uuid = batch_deposit_serial_id;
qs = TALER_ARL_adb->insert_pending_deposit (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
batch_deposit_serial_id,
wire_target_h_payto,
total_amount,
@@ -1187,7 +1236,6 @@ clear_finished_transfer_cb (
ac->max_aggregation_serial = tracking_serial_id;
qs = TALER_ARL_adb->delete_pending_deposit (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
batch_deposit_serial_id);
if (0 == qs)
{
@@ -1208,7 +1256,7 @@ static void
check_for_required_transfers (void)
{
struct ImportMissingWireContext wc = {
- .max_batch_deposit_uuid = pp.last_batch_deposit_uuid,
+ .max_batch_deposit_uuid = TALER_ARL_USE_PP (wire_batch_deposit_id),
.err = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT
};
struct GNUNET_TIME_Absolute deadline;
@@ -1217,13 +1265,13 @@ check_for_required_transfers (void)
.err = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT
};
struct AggregationContext ac = {
- .max_aggregation_serial = pp.last_aggregation_serial,
+ .max_aggregation_serial = TALER_ARL_USE_PP (wire_aggregation_id),
.err = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT
};
qs = TALER_ARL_edb->select_batch_deposits_missing_wire (
TALER_ARL_edb->cls,
- pp.last_batch_deposit_uuid,
+ TALER_ARL_USE_PP (wire_batch_deposit_id),
&import_wire_missing_cb,
&wc);
if ( (0 > qs) || (0 > wc.err) )
@@ -1235,10 +1283,10 @@ check_for_required_transfers (void)
GNUNET_SCHEDULER_shutdown ();
return;
}
- pp.last_batch_deposit_uuid = wc.max_batch_deposit_uuid;
+ TALER_ARL_USE_PP (wire_batch_deposit_id) = wc.max_batch_deposit_uuid;
qs = TALER_ARL_edb->select_aggregations_above_serial (
TALER_ARL_edb->cls,
- pp.last_aggregation_serial,
+ TALER_ARL_USE_PP (wire_aggregation_id),
&clear_finished_transfer_cb,
&ac);
if ( (0 > qs) || (0 > ac.err) )
@@ -1250,7 +1298,7 @@ check_for_required_transfers (void)
GNUNET_SCHEDULER_shutdown ();
return;
}
- pp.last_aggregation_serial = ac.max_aggregation_serial;
+ TALER_ARL_USE_PP (wire_aggregation_id) = ac.max_aggregation_serial;
/* Subtract #GRACE_PERIOD, so we can be a bit behind in processing
without immediately raising undue concern */
deadline = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (),
@@ -1259,7 +1307,6 @@ check_for_required_transfers (void)
GNUNET_NO);
qs = TALER_ARL_adb->select_pending_deposits (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
deadline,
&report_wire_missing_cb,
&rc);
@@ -1735,8 +1782,8 @@ complain_out_not_found (void *cls,
GNUNET_free (account_section);
GNUNET_free (payto_uri);
/* profit drain was correct */
- TALER_ARL_amount_add (&total_drained,
- &total_drained,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_drained),
+ &TALER_ARL_USE_AB (total_drained),
&amount);
return GNUNET_OK;
}
@@ -1846,7 +1893,7 @@ history_debit_cb (void *cls,
TALER_amount2s (&dd->amount),
TALER_B2S (&dd->wtid));
/* Update offset */
- wa->wire_off.out_wire_off = dd->serial_id;
+ wa->wire_off_out = dd->serial_id;
slen = strlen (dd->credit_account_uri) + 1;
roi = GNUNET_malloc (sizeof (struct ReserveOutInfo)
+ slen);
@@ -1942,7 +1989,7 @@ process_debits (void *cls)
// (CG: used to be INT64_MAX, changed by MS to INT32_MAX, why? To be discussed with him!)
wa->dhh = TALER_BANK_debit_history (ctx,
wa->ai->auth,
- wa->wire_off.out_wire_off,
+ wa->wire_off_out,
INT32_MAX,
GNUNET_TIME_UNIT_ZERO,
&history_debit_cb,
@@ -2180,7 +2227,7 @@ analyze_credit (struct WireAccount *wa,
}
/* Update offset */
- wa->wire_off.in_wire_off = details->serial_id;
+ wa->wire_off_in = details->serial_id;
/* compare records with expected data */
if (0 != GNUNET_memcmp (&details->reserve_pub,
&rii->details.reserve_pub))
@@ -2419,7 +2466,7 @@ process_credits (void *cls)
// (CG: used to be INT64_MAX, changed by MS to INT32_MAX, why? To be discussed with him!)
wa->chh = TALER_BANK_credit_history (ctx,
wa->ai->auth,
- wa->wire_off.in_wire_off,
+ wa->wire_off_in,
INT32_MAX,
GNUNET_TIME_UNIT_ZERO,
&history_credit_cb,
@@ -2506,8 +2553,8 @@ reserve_closed_cb (void *cls,
return GNUNET_SYSERR;
return GNUNET_OK;
}
- pp.last_reserve_close_uuid
- = GNUNET_MAX (pp.last_reserve_close_uuid,
+ TALER_ARL_USE_PP (wire_reserve_close_id)
+ = GNUNET_MAX (TALER_ARL_USE_PP (wire_reserve_close_id),
rowid + 1);
rc->receiver_account = GNUNET_strdup (receiver_account);
rc->wtid = *wtid;
@@ -2566,18 +2613,18 @@ begin_transaction (void)
}
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_drained));
+ &TALER_ARL_USE_AB (total_drained)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
&total_wire_in));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
&total_wire_out));
- qs = TALER_ARL_adb->get_predicted_balance (
+ qs = TALER_ARL_adb->get_balance (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &start_balance,
- &total_drained);
+ TALER_ARL_GET_AB (total_drained),
+ TALER_ARL_GET_AB (final_balance),
+ NULL);
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
@@ -2597,12 +2644,33 @@ begin_transaction (void)
NULL != wa;
wa = wa->next)
{
- wa->qsx = TALER_ARL_adb->get_wire_auditor_account_progress (
+ GNUNET_asprintf (&wa->label_reserve_in_serial_id,
+ "wire-%s-%s",
+ wa->ai->section_name,
+ "reserve_in_serial_id");
+ GNUNET_asprintf (&wa->label_wire_out_serial_id,
+ "wire-%s-%s",
+ wa->ai->section_name,
+ "wire_out_serial_id");
+ GNUNET_asprintf (&wa->label_wire_off_in,
+ "wire-%s-%s",
+ wa->ai->section_name,
+ "wire_off_in");
+ GNUNET_asprintf (&wa->label_wire_off_out,
+ "wire-%s-%s",
+ wa->ai->section_name,
+ "wire_off_out");
+ wa->qsx = TALER_ARL_adb->get_auditor_progress (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- wa->ai->section_name,
- &wa->pp,
- &wa->wire_off);
+ wa->label_reserve_in_serial_id,
+ &wa->pp.last_reserve_in_serial_id,
+ wa->label_wire_out_serial_id,
+ &wa->pp.last_wire_out_serial_id,
+ wa->label_wire_off_in,
+ &wa->wire_off_in,
+ wa->label_wire_off_out,
+ &wa->wire_off_out,
+ NULL);
if (0 > wa->qsx)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == wa->qsx);
@@ -2610,9 +2678,12 @@ begin_transaction (void)
}
wa->start_pp = wa->pp;
}
- qsx_gwap = TALER_ARL_adb->get_wire_auditor_progress (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &pp);
+ qsx_gwap = TALER_ARL_adb->get_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_PP (wire_reserve_close_id),
+ TALER_ARL_GET_PP (wire_batch_deposit_id),
+ TALER_ARL_GET_PP (wire_aggregation_id),
+ NULL);
if (0 > qsx_gwap)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx_gwap);
@@ -2625,12 +2696,11 @@ begin_transaction (void)
}
else
{
- start_pp = pp;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming wire audit at %llu / %llu / %llu\n",
- (unsigned long long) pp.last_reserve_close_uuid,
- (unsigned long long) pp.last_batch_deposit_uuid,
- (unsigned long long) pp.last_aggregation_serial);
+ (unsigned long long) TALER_ARL_USE_PP (wire_reserve_close_id),
+ (unsigned long long) TALER_ARL_USE_PP (wire_batch_deposit_id),
+ (unsigned long long) TALER_ARL_USE_PP (wire_aggregation_id));
}
{
@@ -2638,7 +2708,7 @@ begin_transaction (void)
qs = TALER_ARL_edb->select_reserve_closed_above_serial_id (
TALER_ARL_edb->cls,
- pp.last_reserve_close_uuid,
+ TALER_ARL_USE_PP (wire_reserve_close_id),
&reserve_closed_cb,
NULL);
if (0 > qs)
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_aggregation.h b/src/auditordb/pg_get_auditor_progress.h
index b20a00adf..fee7a4424 100644
--- a/src/auditordb/pg_get_auditor_progress_aggregation.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_aggregation.h
- * @brief implementation of the get_auditor_progress_aggregation function
+ * @file pg_get_auditor_progress.h
+ * @brief implementation of the get_auditor_progress function
* @author Christian Grothoff
*/
-#ifndef PG_GET_AUDITOR_PROGRESS_AGGREGATION_H
-#define PG_GET_AUDITOR_PROGRESS_AGGREGATION_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] ppa 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_aggregation (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
+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_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_deposit_confirmation.h b/src/auditordb/pg_get_auditor_progress_deposit_confirmation.h
deleted file mode 100644
index 3b558d0c6..000000000
--- a/src/auditordb/pg_get_auditor_progress_deposit_confirmation.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_deposit_confirmation.h
- * @brief implementation of the get_auditor_progress_deposit_confirmation function
- * @author Christian Grothoff
- */
-#ifndef PG_GET_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
-#define PG_GET_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_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] ppdc set to where the auditor is in processing
- * @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);
-
-#endif
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_purse.h b/src/auditordb/pg_get_auditor_progress_purse.h
deleted file mode 100644
index db8d48e8e..000000000
--- a/src/auditordb/pg_get_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_get_auditor_progress_purse.h
- * @brief implementation of the get_auditor_progress_purse function
- * @author Christian Grothoff
- */
-#ifndef PG_GET_AUDITOR_PROGRESS_PURSE_H
-#define PG_GET_AUDITOR_PROGRESS_PURSE_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] ppp set to where the auditor is in processing
- * @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);
-
-
-#endif
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_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_reserve_summary.h b/src/auditordb/pg_insert_balance.h
index d9a3ea5aa..19c7a8c6c 100644
--- a/src/auditordb/pg_get_reserve_summary.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,30 +14,32 @@
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
+ * @file pg_insert_balance.h
+ * @brief implementation of the insert_balance function
* @author Christian Grothoff
*/
-#ifndef PG_GET_RESERVE_SUMMARY_H
-#define PG_GET_RESERVE_SUMMARY_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 summary information about all reserves.
+ * 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 public key of the exchange
- * @param[out] rfb balances are returned here
+ * @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_reserve_summary (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
+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;
+}
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index e650b3fdd..21f2d080b 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -2238,11 +2238,10 @@ exchange_serve_process_config (void)
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_public_key_from_string (master_public_key_str,
- strlen (
- master_public_key_str),
- &TEH_master_public_key.
- eddsa_pub))
+ GNUNET_CRYPTO_eddsa_public_key_from_string (
+ master_public_key_str,
+ strlen (master_public_key_str),
+ &TEH_master_public_key.eddsa_pub))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"exchange",
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index d333a7ea0..22788a562 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -2476,6 +2476,7 @@ main (int argc,
GNUNET_log_setup (argv[0],
"INFO",
NULL);
+ TALER_OS_init ();
plugin_name++;
(void) GNUNET_asprintf (&testname,
"test-exchange-db-%s",
diff --git a/src/include/taler_auditor_service.h b/src/include/taler_auditor_service.h
index 0d4a9288f..36ea781b1 100644
--- a/src/include/taler_auditor_service.h
+++ b/src/include/taler_auditor_service.h
@@ -46,6 +46,11 @@ struct TALER_AUDITOR_ConfigInformation
struct TALER_AuditorPublicKeyP auditor_pub;
/**
+ * Master public key of the audited exchange.
+ */
+ struct TALER_MasterPublicKeyP exchange_master_public_key;
+
+ /**
* Supported Taler protocol version by the auditor.
* String in the format current:revision:age using the
* semantics of GNU libtool. See
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
index 6e0e97ca0..f66733f15 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -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
@@ -31,21 +31,6 @@
/**
- * Function called with information about exchanges this
- * auditor is monitoring.
- *
- * @param cls closure
- * @param master_pub master public key of the exchange
- * @param exchange_url base URL of the exchange's API
- */
-typedef void
-(*TALER_AUDITORDB_ExchangeCallback)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *exchange_url);
-
-
-/**
* Function called with the results of select_historic_denom_revenue()
*
* @param cls closure
@@ -91,263 +76,10 @@ typedef enum GNUNET_GenericReturnValue
/**
- * Structure for remembering the wire auditor's progress over the
- * various tables and (auditor) transactions.
- */
-struct TALER_AUDITORDB_WireProgressPoint
-{
-
- /**
- * reserves_close uuid until which we have checked
- * reserve closures.
- */
- uint64_t last_reserve_close_uuid;
-
- /**
- * batch_deposits serial until which we have imported
- * batch deposits into the auditor_pending_deposits table.
- */
- uint64_t last_batch_deposit_uuid;
-
- /**
- * Maximum number in the aggregations table that
- * we have processed so far.
- */
- uint64_t last_aggregation_serial;
-};
-
-
-/**
- * Structure for remembering the wire auditor's progress over the
- * various tables and (auditor) transactions per wire account.
- */
-struct TALER_AUDITORDB_WireAccountProgressPoint
-{
- /**
- * serial ID of the last reserve_in transfer the wire auditor processed
- */
- uint64_t last_reserve_in_serial_id;
-
- /**
- * serial ID of the last wire_out the wire auditor processed
- */
- uint64_t last_wire_out_serial_id;
-
-};
-
-
-/**
- * Structure for remembering the wire auditor's progress
- * with respect to the bank transaction histories.
- */
-struct TALER_AUDITORDB_BankAccountProgressPoint
-{
- /**
- * How far are we in the incoming wire transaction history
- */
- uint64_t in_wire_off;
-
- /**
- * How far are we in the outgoing wire transaction history
- */
- uint64_t out_wire_off;
-
-};
-
-
-/**
- * Structure for remembering the auditor's progress over the various
- * tables and (auditor) transactions when analyzing reserves.
- */
-struct TALER_AUDITORDB_ProgressPointReserve
-{
- /**
- * serial ID of the last reserve_in transfer the auditor processed
- */
- uint64_t last_reserve_in_serial_id;
-
- /**
- * serial ID of the last reserve_out (withdraw) the auditor processed
- */
- uint64_t last_reserve_out_serial_id;
-
- /**
- * serial ID of the last recoup entry the auditor processed when
- * considering reserves.
- */
- uint64_t last_reserve_recoup_serial_id;
-
- /**
- * serial ID of the last open_requests entry the auditor processed.
- */
- uint64_t last_reserve_open_serial_id;
-
- /**
- * serial ID of the last reserve_close entry the auditor processed.
- */
- uint64_t last_reserve_close_serial_id;
-
- /**
- * Serial ID of the last purse_decisions entry the auditor processed.
- */
- uint64_t last_purse_decisions_serial_id;
-
- /**
- * serial ID of the last account_merges entry the auditor processed.
- */
- uint64_t last_account_merges_serial_id;
-
- /**
- * serial ID of the last history_requests entry the auditor processed.
- */
- uint64_t last_history_requests_serial_id;
-
-};
-
-
-/**
- * Structure for remembering the auditor's progress over the various
- * tables and (auditor) transactions when analyzing purses.
- */
-struct TALER_AUDITORDB_ProgressPointPurse
-{
- /**
- * serial ID of the last purse_request transfer the auditor processed
- */
- uint64_t last_purse_request_serial_id;
-
- /**
- * serial ID of the last purse_decision the auditor processed
- */
- uint64_t last_purse_decision_serial_id;
-
- /**
- * serial ID of the last purse_merge entry the auditor processed when
- * considering reserves.
- */
- uint64_t last_purse_merge_serial_id;
-
- /**
- * serial ID of the last account_merge entry the auditor processed.
- */
- uint64_t last_account_merge_serial_id;
-
- /**
- * serial ID of the last purse_deposits entry the auditor processed.
- */
- uint64_t last_purse_deposits_serial_id;
-
-};
-
-
-/**
- * Global statistics about purses.
- */
-struct TALER_AUDITORDB_PurseBalance
-{
- /**
- * Balance in all unmerged and unexpired purses.
- */
- struct TALER_Amount balance;
-
- /**
- * Total number of open purses.
- */
- uint64_t open_purses;
-};
-
-
-/**
- * Structure for remembering the auditor's progress over the various
- * tables and (auditor) transactions when analyzing reserves.
- */
-struct TALER_AUDITORDB_ProgressPointDepositConfirmation
-{
- /**
- * serial ID of the last deposit_confirmation the auditor processed
- */
- uint64_t last_deposit_confirmation_serial_id;
-
-};
-
-
-/**
- * Structure for remembering the auditor's progress over the various
- * tables and (auditor) transactions when analyzing aggregations.
- */
-struct TALER_AUDITORDB_ProgressPointAggregation
-{
-
- /**
- * serial ID of the last prewire transfer the auditor processed
- */
- uint64_t last_wire_out_serial_id;
-};
-
-
-/**
- * Structure for remembering the auditor's progress over the various
- * tables and (auditor) transactions when analyzing coins.
- */
-struct TALER_AUDITORDB_ProgressPointCoin
-{
- /**
- * serial ID of the last withdraw the auditor processed
- */
- uint64_t last_withdraw_serial_id;
-
- /**
- * serial ID of the last deposit the auditor processed
- */
- uint64_t last_deposit_serial_id;
-
- /**
- * serial ID of the last refresh the auditor processed
- */
- uint64_t last_melt_serial_id;
-
- /**
- * serial ID of the last refund the auditor processed
- */
- uint64_t last_refund_serial_id;
-
- /**
- * Serial ID of the last recoup operation the auditor processed.
- */
- uint64_t last_recoup_serial_id;
-
- /**
- * Serial ID of the last recoup-of-refresh operation the auditor processed.
- */
- uint64_t last_recoup_refresh_serial_id;
-
- /**
- * Serial ID of the last reserve_open_deposits operation the auditor processed.
- */
- uint64_t last_open_deposits_serial_id;
-
- /**
- * Serial ID of the last purse_deposits operation the auditor processed.
- */
- uint64_t last_purse_deposits_serial_id;
-
- /**
- * Serial ID of the last purse_refunds operation the auditor processed.
- */
- uint64_t last_purse_refunds_serial_id;
-
-};
-
-
-/**
* Information about a signing key of an exchange.
*/
struct TALER_AUDITORDB_ExchangeSigningKey
{
- /**
- * Public master key of the exchange that certified @e master_sig.
- */
- struct TALER_MasterPublicKeyP master_public_key;
/**
* When does @e exchange_pub start to be used?
@@ -461,12 +193,6 @@ struct TALER_AUDITORDB_DepositConfirmation
*/
struct TALER_MasterSignatureP master_sig;
- /**
- * Master public key of the exchange corresponding to @e master_sig.
- * Identifies the exchange this is about.
- */
- struct TALER_MasterPublicKeyP master_public_key;
-
};
@@ -549,62 +275,6 @@ struct TALER_AUDITORDB_DenominationCirculationData
/**
- * Balance values for all denominations.
- */
-struct TALER_AUDITORDB_GlobalCoinBalance
-{
- /**
- * Amount of outstanding coins in circulation.
- */
- struct TALER_Amount total_escrowed;
-
- /**
- * Amount collected in deposit fees.
- */
- struct TALER_Amount deposit_fee_balance;
-
- /**
- * Amount collected in melt fees.
- */
- struct TALER_Amount melt_fee_balance;
-
- /**
- * Amount collected in refund fees.
- */
- struct TALER_Amount refund_fee_balance;
-
- /**
- * Amount collected in purse fees from coins.
- */
- struct TALER_Amount purse_fee_balance;
-
- /**
- * Amount collected in reserve open deposit fees from coins.
- */
- struct TALER_Amount open_deposit_fee_balance;
-
- /**
- * Total amount that could still be theoretically
- * lost in the future due to recoup operations.
- * (Total put into circulation minus @e loss
- * and @e irregular_recoup.)
- */
- struct TALER_Amount risk;
-
- /**
- * Amount lost due to recoups.
- */
- struct TALER_Amount loss;
-
- /**
- * Amount lost due to coin operations that the exchange
- * should not have permitted.
- */
- struct TALER_Amount irregular_loss;
-};
-
-
-/**
* Function called with deposit confirmations stored in
* the auditor's database.
*
@@ -689,6 +359,7 @@ struct TALER_AUDITORDB_Plugin
enum GNUNET_GenericReturnValue
(*preflight)(void *cls);
+
/**
* Register callback to be invoked on events of type @a es.
*
@@ -751,10 +422,14 @@ struct TALER_AUDITORDB_Plugin
* Create the necessary tables if they are not present
*
* @param cls the @e cls of this struct 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
*/
enum GNUNET_GenericReturnValue
- (*create_tables)(void *cls);
+ (*create_tables)(void *cls,
+ bool support_partitions,
+ uint32_t num_partitions);
/**
@@ -799,195 +474,21 @@ struct TALER_AUDITORDB_Plugin
/**
- * 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
- (*insert_exchange)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *exchange_url);
-
-
- /**
- * 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
- (*delete_exchange)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub);
-
-
- /**
- * 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
- (*list_exchanges)(void *cls,
- TALER_AUDITORDB_ExchangeCallback cb,
- void *cb_cls);
-
- /**
- * Insert information about a signing key of the exchange.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param sk signing key information to store
- * @return query result status
- */
- enum GNUNET_DB_QueryStatus
- (*insert_exchange_signkey)(
- void *cls,
- const struct TALER_AUDITORDB_ExchangeSigningKey *sk);
-
-
- /**
- * Insert information about a deposit confirmation into the database.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param dc deposit confirmation information to store
- * @return query result status
- */
- enum GNUNET_DB_QueryStatus
- (*insert_deposit_confirmation)(
- void *cls,
- const struct TALER_AUDITORDB_DepositConfirmation *dc);
-
-
- /**
- * Get information about deposit confirmations from the database.
- *
- * @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 cb function to call with results
- * @param cb_cls closure for @a cb
- * @return query result status
- */
- enum GNUNET_DB_QueryStatus
- (*get_deposit_confirmations)(
- void *cls,
- uint64_t start_id,
- TALER_AUDITORDB_DepositConfirmationCallback cb,
- void *cb_cls);
-
-
- /**
- * 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
- (*insert_auditor_progress_coin)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointCoin *ppc);
-
-
- /**
- * 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
- (*update_auditor_progress_coin)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointCoin *ppc);
-
-
- /**
- * 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
- (*get_auditor_progress_coin)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointCoin *ppc);
-
- /**
- * 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
- (*insert_auditor_progress_reserve)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointReserve *ppr);
-
-
- /**
- * 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
- (*update_auditor_progress_reserve)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointReserve *ppr);
-
-
- /**
- * 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
- (*get_auditor_progress_reserve)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointReserve *ppr);
-
- /**
* 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
+ * @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
- (*insert_auditor_progress_purse)(
+ (*insert_auditor_progress)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointPurse *ppp);
+ const char *progress_key,
+ uint64_t progress_offset,
+ ...);
/**
@@ -995,233 +496,142 @@ struct TALER_AUDITORDB_Plugin
* 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
+ * @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
- (*update_auditor_progress_purse)(
+ (*update_auditor_progress)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointPurse *ppp);
+ const char *progress_key,
+ uint64_t progress_offset,
+ ...);
/**
* 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] ppp 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, set to 0 if key was not found
+ * @param ... NULL terminated list of additional key-value pairs to fetch
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
- (*get_auditor_progress_purse)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointPurse *ppp);
+ (*get_auditor_progress)(void *cls,
+ const char *progress_key,
+ uint64_t *progress_offset,
+ ...);
/**
- * Insert information about the auditor's progress with an exchange's
- * data.
+ * 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 ppdc where is the auditor 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
- (*insert_auditor_progress_deposit_confirmation)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc);
+ (*insert_balance)(void *cls,
+ const char *balance_key,
+ const struct TALER_Amount *balance_value,
+ ...);
/**
- * 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
- (*update_auditor_progress_deposit_confirmation)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc);
-
-
- /**
- * 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
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*get_auditor_progress_deposit_confirmation)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc);
-
-
- /**
- * 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
- (*insert_auditor_progress_aggregation)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
-
-
- /**
- * 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
- (*update_auditor_progress_aggregation)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
-
-
- /**
- * 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
- (*get_auditor_progress_aggregation)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
-
-
- /**
- * Insert information about the wire auditor's progress with an exchange's
- * data.
+ * 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 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
+ * @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
- (*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);
+ (*update_balance)(void *cls,
+ const char *balance_key,
+ const struct TALER_Amount *balance_value,
+ ...);
/**
- * Update information about the progress of the wire auditor. There
- * must be an existing record for the exchange.
+ * 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 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
+ * @param balance_key key of the blance to store
+ * @param[out] balance_value set to amount stored under @a balance_key, set to invalid amount (all zero) if key was not found
+ * @param ... NULL terminated list of additional key-value pairs to fetch
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
- (*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);
+ (*get_balance)(void *cls,
+ const char *balance_key,
+ struct TALER_Amount *balance_value,
+ ...);
/**
- * Get information about the progress of the wire auditor.
+ * Insert information about a signing key of 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[out] pp where is the auditor in processing
- * @param[out] bapp how far are we in the wire transaction histories
- * @return transaction status code
+ * @param sk signing key information to store
+ * @return query result status
*/
enum GNUNET_DB_QueryStatus
- (*get_wire_auditor_account_progress)(
+ (*insert_exchange_signkey)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *account_name,
- struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- struct TALER_AUDITORDB_BankAccountProgressPoint *bapp);
+ const struct TALER_AUDITORDB_ExchangeSigningKey *sk);
/**
- * Insert information about the wire auditor's progress with an exchange's
- * data.
+ * Insert information about a deposit confirmation into the database.
*
* @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
- * @return transaction status code
+ * @param dc deposit confirmation information to store
+ * @return query result status
*/
enum GNUNET_DB_QueryStatus
- (*insert_wire_auditor_progress)(
+ (*insert_deposit_confirmation)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_WireProgressPoint *pp);
+ const struct TALER_AUDITORDB_DepositConfirmation *dc);
/**
- * Update information about the progress of the wire auditor. There
- * must be an existing record for the exchange.
+ * Get information about deposit confirmations from the database.
*
* @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
- * @return transaction status code
+ * @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
*/
enum GNUNET_DB_QueryStatus
- (*update_wire_auditor_progress)(
+ (*get_deposit_confirmations)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_WireProgressPoint *pp);
+ uint64_t start_id,
+ bool return_suppressed,
+ TALER_AUDITORDB_DepositConfirmationCallback cb,
+ void *cb_cls);
/**
- * Get information about the progress of the wire auditor.
+ * Delete information about a deposit confirmation from the database.
*
* @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 set to where the auditor is in processing
- * @return transaction status code
+ * @param row_id row to delete
+ * @return query result status
*/
enum GNUNET_DB_QueryStatus
- (*get_wire_auditor_progress)(
+ (*delete_deposit_confirmation)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_WireProgressPoint *pp);
+ uint64_t row_id);
/**
@@ -1230,7 +640,6 @@ struct TALER_AUDITORDB_Plugin
*
* @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 expiration date of the reserve
* @param origin_account where did the money in the reserve originally come from
@@ -1240,7 +649,6 @@ struct TALER_AUDITORDB_Plugin
(*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);
@@ -1252,7 +660,6 @@ struct TALER_AUDITORDB_Plugin
*
* @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 expiration date of the reserve
* @return transaction status code
@@ -1261,7 +668,6 @@ struct TALER_AUDITORDB_Plugin
(*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);
@@ -1271,7 +677,6 @@ struct TALER_AUDITORDB_Plugin
*
* @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 set to balances associated with the reserve
* @param[out] expiration_date expiration date of the reserve
@@ -1282,7 +687,6 @@ struct TALER_AUDITORDB_Plugin
(*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,
@@ -1294,13 +698,62 @@ struct TALER_AUDITORDB_Plugin
*
* @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
(*del_reserve_info)(void *cls,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub);
+ const struct TALER_ReservePublicKeyP *reserve_pub);
+
+
+ /**
+ * Insert new row into the pending deposits table.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @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
+ * @param deadline what was the requested wire transfer deadline
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_pending_deposit)(
+ void *cls,
+ uint64_t batch_deposit_serial_id,
+ const struct TALER_PaytoHashP *wire_target_h_payto,
+ const struct TALER_Amount *total_amount,
+ struct GNUNET_TIME_Timestamp deadline);
+
+
+ /**
+ * Delete a row from the pending deposit table.
+ * Usually done when the respective wire transfer
+ * was finally detected.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param batch_deposit_serial_id which entry to delete
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_pending_deposit)(
+ void *cls,
+ uint64_t batch_deposit_serial_id);
+
+
+ /**
+ * Return (batch) deposits for which we have not yet
+ * seen the required wire transfer.
+ *
+ * @param deadline only return up to this deadline
+ * @param cb function to call on each entry
+ * @param cb_cls closure for @a cb
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_pending_deposits)(
+ void *cls,
+ struct GNUNET_TIME_Absolute deadline,
+ TALER_AUDITORDB_WireMissingCallback cb,
+ void *cb_cls);
/**
@@ -1309,7 +762,6 @@ struct TALER_AUDITORDB_Plugin
*
* @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
@@ -1318,7 +770,6 @@ struct TALER_AUDITORDB_Plugin
(*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);
@@ -1329,7 +780,6 @@ struct TALER_AUDITORDB_Plugin
*
* @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
*/
@@ -1337,7 +787,6 @@ struct TALER_AUDITORDB_Plugin
(*update_purse_info)(
void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_Amount *balance);
@@ -1346,7 +795,6 @@ struct TALER_AUDITORDB_Plugin
*
* @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
@@ -1356,7 +804,6 @@ struct TALER_AUDITORDB_Plugin
(*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);
@@ -1367,21 +814,18 @@ struct TALER_AUDITORDB_Plugin
*
* @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
(*delete_purse_info)(
void *cls,
- const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub);
+ const struct TALER_PurseContractPublicKeyP *purse_pub);
/**
* 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
@@ -1389,162 +833,11 @@ struct TALER_AUDITORDB_Plugin
enum GNUNET_DB_QueryStatus
(*select_purse_expired)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_ExpiredPurseCallback cb,
void *cb_cls);
/**
- * Delete information about a purse.
- *
- * @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
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*del_purse_info)(void *cls,
- const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_MasterPublicKeyP *master_pub);
-
-
- /**
- * 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 reserve balances summary to store
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*insert_reserve_summary)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
-
-
- /**
- * 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 reserve balances summary to store
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*update_reserve_summary)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
-
-
- /**
- * 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 reserve balances summary to initialize
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*get_reserve_summary)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
-
-
- /**
- * 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
- (*insert_purse_summary)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_PurseBalance *sum);
-
-
- /**
- * Update information about all purses. 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
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*update_purse_summary)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_PurseBalance *sum);
-
-
- /**
- * Get summary information about all purses.
- *
- * @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
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*get_purse_summary)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_PurseBalance *sum);
-
-
- /**
- * 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
- (*insert_wire_fee_summary)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *wire_fee_balance);
-
-
- /**
- * Insert information about exchange's wire fee balance. 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 wire_fee_balance amount the exchange gained in wire fees
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*update_wire_fee_summary)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *wire_fee_balance);
-
-
- /**
- * 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
- (*get_wire_fee_summary)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_Amount *wire_fee_balance);
-
-
- /**
* Insert information about a denomination key's balances. There
* must not be an existing record for the denomination key.
*
@@ -1575,22 +868,6 @@ struct TALER_AUDITORDB_Plugin
const struct TALER_DenominationHashP *denom_pub_hash,
const struct TALER_AUDITORDB_DenominationCirculationData *dcd);
-
- /**
- * Get information about a denomination key's balances.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param denom_pub_hash hash of the denomination public key
- * @param[out] dcd denomination circulation data to initialize
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*get_denomination_balance)(
- void *cls,
- const struct TALER_DenominationHashP *denom_pub_hash,
- struct TALER_AUDITORDB_DenominationCirculationData *dcd);
-
-
/**
* Delete information about a denomination key's balances.
*
@@ -1605,49 +882,18 @@ struct TALER_AUDITORDB_Plugin
/**
- * 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
- (*insert_balance_summary)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_GlobalCoinBalance *dfb);
-
-
- /**
- * Update information about an exchange's denomination balances. There
- * must be an existing record for the exchange.
+ * Get 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 dfb denomination balance data to store
+ * @param denom_pub_hash hash of the denomination public key
+ * @param[out] dcd denomination circulation data to initialize
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
- (*update_balance_summary)(
+ (*get_denomination_balance)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_AUDITORDB_GlobalCoinBalance *dfb);
-
-
- /**
- * Get information about an exchange's denomination 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
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*get_balance_summary)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_AUDITORDB_GlobalCoinBalance *dfb);
+ const struct TALER_DenominationHashP *denom_pub_hash,
+ struct TALER_AUDITORDB_DenominationCirculationData *dcd);
/**
@@ -1655,7 +901,6 @@ struct TALER_AUDITORDB_Plugin
* 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
@@ -1667,7 +912,6 @@ struct TALER_AUDITORDB_Plugin
enum GNUNET_DB_QueryStatus
(*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,
@@ -1675,11 +919,9 @@ struct TALER_AUDITORDB_Plugin
/**
- * Obtain all of the historic denomination key revenue
- * of the given @a master_pub.
+ * Obtain all of the historic denomination key revenue.
*
* @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
@@ -1687,7 +929,6 @@ struct TALER_AUDITORDB_Plugin
enum GNUNET_DB_QueryStatus
(*select_historic_denom_revenue)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb,
void *cb_cls);
@@ -1696,7 +937,6 @@ struct TALER_AUDITORDB_Plugin
* 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
@@ -1705,7 +945,6 @@ struct TALER_AUDITORDB_Plugin
enum GNUNET_DB_QueryStatus
(*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);
@@ -1715,7 +954,6 @@ struct TALER_AUDITORDB_Plugin
* Return information about an exchange's historic revenue from reserves.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param 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
@@ -1723,116 +961,9 @@ struct TALER_AUDITORDB_Plugin
enum GNUNET_DB_QueryStatus
(*select_historic_reserve_revenue)(
void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb,
void *cb_cls);
-
- /**
- * 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_profits total profits drained by the exchange so far
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*insert_predicted_result)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *balance,
- const struct TALER_Amount *drained_profits);
-
-
- /**
- * 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_profits total profits drained by the exchange so far
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*update_predicted_result)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *balance,
- const struct TALER_Amount *drained_profits);
-
-
- /**
- * 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_profits total profits drained by the exchange so far
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*get_predicted_balance)(void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_Amount *balance,
- struct TALER_Amount *drained_profits);
-
- /**
- * 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
- * @param deadline what was the requested wire transfer deadline
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*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,
- struct GNUNET_TIME_Timestamp deadline);
-
-
- /**
- * Delete a row from the pending deposit table.
- * Usually done when the respective wire transfer
- * 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
- (*delete_pending_deposit)(
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- uint64_t batch_deposit_serial_id);
-
-
- /**
- * Return (batch) deposits for which we have not yet
- * seen the required wire transfer.
- *
- * @param deadline only return up to this deadline
- * @param cb function to call on each entry
- * @param cb_cls closure for @a cb
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*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/lib/auditor_api_get_config.c b/src/lib/auditor_api_get_config.c
index 8f865a608..1e8e0bb30 100644
--- a/src/lib/auditor_api_get_config.c
+++ b/src/lib/auditor_api_get_config.c
@@ -33,7 +33,7 @@
* Which revision of the Taler auditor protocol is implemented
* by this library? Used to determine compatibility.
*/
-#define TALER_PROTOCOL_CURRENT 0
+#define TALER_PROTOCOL_CURRENT 1
/**
* How many revisions back are we compatible to?
@@ -111,6 +111,8 @@ decode_config_json (const json_t *resp_obj,
&pv),
GNUNET_JSON_spec_string ("version",
&ver),
+ GNUNET_JSON_spec_fixed_auto ("exchange_master_public_key",
+ &vi->exchange_master_public_key),
GNUNET_JSON_spec_fixed_auto ("auditor_public_key",
&vi->auditor_pub),
GNUNET_JSON_spec_end ()
diff --git a/src/pq/pq_common.h b/src/pq/pq_common.h
index 1562646ff..3248778a0 100644
--- a/src/pq/pq_common.h
+++ b/src/pq/pq_common.h
@@ -77,6 +77,21 @@ struct TALER_PQ_AmountP
/**
+ * Memory representation of an taler amount record for Postgres.
+ *
+ * All values need to be in network-byte-order.
+ */
+struct TALER_PQ_AmountNullP
+{
+ uint32_t cnt; /* # elements in the tuple (== 2) */
+ uint32_t oid_v; /* oid of .v */
+ uint32_t sz_v; /* size of .v */
+ uint32_t oid_f; /* oid of .f */
+ uint32_t sz_f; /* size of .f */
+} __attribute__((packed));
+
+
+/**
* Memory representation of an taler amount record with currency for Postgres.
*
* All values need to be in network-byte-order.
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c
index 915aad144..e81c78302 100644
--- a/src/pq/pq_result_helper.c
+++ b/src/pq/pq_result_helper.c
@@ -229,6 +229,30 @@ extract_amount_tuple (void *cls,
size = PQgetlength (result,
row,
col);
+ in = PQgetvalue (result,
+ row,
+ col);
+ if (sizeof(struct TALER_PQ_AmountNullP) == size)
+ {
+ struct TALER_PQ_AmountNullP apn;
+
+ memcpy (&apn,
+ in,
+ size);
+ if ( (2 == ntohl (apn.cnt)) &&
+ (-1 == (int32_t) ntohl (apn.sz_v)) &&
+ (-1 == (int32_t) ntohl (apn.sz_f)) )
+ {
+ /* is NULL! */
+ return GNUNET_NO;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Incorrect size of binary field `%s' and not NULL (got %zu, expected %zu)\n",
+ fname,
+ size,
+ sizeof(ap));
+ return GNUNET_SYSERR;
+ }
if (sizeof(ap) != size)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -239,9 +263,6 @@ extract_amount_tuple (void *cls,
return GNUNET_SYSERR;
}
- in = PQgetvalue (result,
- row,
- col);
memcpy (&ap,
in,
size);
@@ -1141,13 +1162,13 @@ extract_array_generic (
*((void **) dst) = NULL;
#define FAIL_IF(cond) \
- do { \
- if ((cond)) \
- { \
- GNUNET_break (! (cond)); \
- goto FAIL; \
- } \
- } while (0)
+ do { \
+ if ((cond)) \
+ { \
+ GNUNET_break (! (cond)); \
+ goto FAIL; \
+ } \
+ } while (0)
col_num = PQfnumber (result, fname);
FAIL_IF (0 > col_num);
diff --git a/src/testing/taler-unified-setup.sh b/src/testing/taler-unified-setup.sh
index e621567d9..e1fcc8015 100755
--- a/src/testing/taler-unified-setup.sh
+++ b/src/testing/taler-unified-setup.sh
@@ -684,10 +684,6 @@ then
taler-auditor-dbinit \
-c "$CONF" \
--reset
- taler-auditor-exchange \
- -c "$CONF" \
- -m "$MAPUB" \
- -u "$EXCHANGE_URL"
$USE_VALGRIND taler-auditor-httpd \
-L "$LOGLEVEL" \
-c "$CONF" 2> taler-auditor-httpd.log &