aboutsummaryrefslogtreecommitdiff
path: root/src/auditor
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditor')
-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.c46
-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
15 files changed, 886 insertions, 837 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 94adb5471..7b7bf98a7 100644
--- a/src/auditor/taler-auditor-httpd.c
+++ b/src/auditor/taler-auditor-httpd.c
@@ -48,7 +48,7 @@
* release version, and the format is NOT the same that semantic
* versioning uses either.
*/
-#define AUDITOR_PROTOCOL_VERSION "0:0:0"
+#define AUDITOR_PROTOCOL_VERSION "1:0:1"
/**
* Backlog for listen operation on unix domain sockets.
@@ -81,6 +81,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;
@@ -164,7 +170,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)
{
@@ -303,6 +311,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 fea23131b..b5c4a386d 100644
--- a/src/auditor/taler-helper-auditor-deposits.c
+++ b/src/auditor/taler-helper-auditor-deposits.c
@@ -210,18 +210,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)
{
@@ -237,7 +236,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' */
@@ -247,11 +247,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)
@@ -262,17 +264,22 @@ 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;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "getting in here when i shouldnt\n");
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "lastseencoinserialid %lu\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "getting in here when i shouldnt\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "lastseencoinserialid %lu\n",
dcc.last_seen_coin_serial);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dcc.qs %u\n", dcc.qs);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "dcc.qs %u\n",
+ dcc.qs);
/* if (UINT64_MAX == dcc.first_missed_coin_serial)
ppdc.last_deposit_confirmation_serial_id = dcc.last_seen_coin_serial;
else
@@ -280,15 +287,15 @@ analyze_deposit_confirmations (void *cls)
*/
/* 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,
@@ -302,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)