summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Zwahlen <cedric.zwahlen@students.bfh.ch>2024-05-06 01:59:33 +0200
committerCedric Zwahlen <cedric.zwahlen@students.bfh.ch>2024-05-06 01:59:33 +0200
commitdedb552db8a538b4444bd9bc6289a6885db43fd1 (patch)
tree64a454bb18b5a9a79cd81b9a83e509a70c047b3b
parent0a51cb50b363f999a6bdd2d4c3899aa7a0c240d0 (diff)
downloadexchange-dedb552db8a538b4444bd9bc6289a6885db43fd1.tar.gz
exchange-dedb552db8a538b4444bd9bc6289a6885db43fd1.tar.bz2
exchange-dedb552db8a538b4444bd9bc6289a6885db43fd1.zip
Experiment with triggers
-rw-r--r--src/auditor/taler-auditor-httpd.c4
-rw-r--r--src/auditor/taler-helper-auditor-aggregation.c225
-rw-r--r--src/auditor/taler-helper-auditor-coins.c295
-rw-r--r--src/auditor/taler-helper-auditor-purses.c205
-rw-r--r--src/auditor/taler-helper-auditor-reserves.c290
-rw-r--r--src/auditor/taler-helper-auditor-wire.c186
-rw-r--r--src/exchangedb/auditor-triggers-0001.sql461
-rw-r--r--src/exchangedb/procedures.sql.in1
-rwxr-xr-xsrc/testing/taler-unified-setup.sh4
9 files changed, 1663 insertions, 8 deletions
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c
index c7697cafd..9c02e6a49 100644
--- a/src/auditor/taler-auditor-httpd.c
+++ b/src/auditor/taler-auditor-httpd.c
@@ -1353,8 +1353,6 @@ run (void *cls,
tok = getenv ("TALER_AUDITOR_TOKEN");
- printf ("token: %s\n", tok);
-
if ( (NULL != tok) &&
(NULL == TMA_auth) )
TMA_auth = GNUNET_strdup (tok);
@@ -1434,6 +1432,8 @@ run (void *cls,
}
global_ret = EXIT_SUCCESS;
TALER_MHD_daemon_start (mhd);
+
+
}
}
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c
index d407ba76c..83011c83e 100644
--- a/src/auditor/taler-helper-auditor-aggregation.c
+++ b/src/auditor/taler-helper-auditor-aggregation.c
@@ -25,6 +25,7 @@
#include "taler_json_lib.h"
#include "taler_bank_service.h"
#include "taler_signatures.h"
+#include "taler_dbevents.h"
#include "report-lib.h"
#include <inttypes.h>
@@ -125,6 +126,17 @@ static struct TALER_Amount total_bad_sig_loss;
*/
static int internal_checks;
+static struct GNUNET_DB_EventHandler *eh;
+
+/**
+ * Our database plugin.
+ */
+static struct TALER_AUDITORDB_Plugin *db_plugin;
+
+/**
+ * The auditors's configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* Report a (serious) inconsistency in the exchange's database with
@@ -1643,6 +1655,180 @@ analyze_aggregations (void *cls)
/**
+ * Function called on events received from Postgres.
+ *
+ * @param cls closure, NULL
+ * @param extra additional event data provided
+ * @param extra_size number of bytes in @a extra
+ */
+static void
+db_notify (void *cls,
+ const void *extra,
+ size_t extra_size)
+{
+ if (test_mode != 1) // TODO: this if case might be obsolete, if condition is already checked in run
+
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Received notification to wake aggregatoin helper\n");
+
+ (void) cls;
+ (void) extra;
+ (void) extra_size;
+
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " 1checking agg wire fee revenue set zero %s\n\n",
+ TALER_amount_to_string (&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));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_wire_out_delta_minus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_arithmetic_delta_plus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_arithmetic_delta_minus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_coin_delta_plus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_coin_delta_minus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_bad_sig_loss));
+ GNUNET_assert (NULL !=
+ (report_row_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_wire_out_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_coin_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_amount_arithmetic_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_bad_sig_losses
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_fee_time_inconsistencies
+ = json_array ()));
+ if (GNUNET_OK !=
+ TALER_ARL_setup_sessions_and_run (&analyze_aggregations,
+ NULL))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Audit failed\n");
+ TALER_ARL_done (NULL);
+ global_ret = EXIT_FAILURE;
+
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Audit complete\n");
+
+ // TODO: might be unnecessary
+ TALER_ARL_done (GNUNET_JSON_PACK (
+ /* blocks #1 */
+ GNUNET_JSON_pack_array_steal (
+ "wire_out_inconsistencies",
+ report_wire_out_inconsistencies),
+ /* Tested in test-auditor.sh #23 */
+ TALER_JSON_pack_amount (
+ "total_wire_out_delta_plus",
+ &total_wire_out_delta_plus),
+ /* Tested in test-auditor.sh #23 */
+ TALER_JSON_pack_amount (
+ "total_wire_out_delta_minus",
+ &total_wire_out_delta_minus),
+ /* Tested in test-auditor.sh #28/32 */
+ GNUNET_JSON_pack_array_steal ("bad_sig_losses",
+ report_bad_sig_losses),
+ /* Tested in test-auditor.sh #28/32 */
+ TALER_JSON_pack_amount ("total_bad_sig_loss",
+ &total_bad_sig_loss),
+ /* block #2 */
+ /* Tested in test-auditor.sh #15 */
+ GNUNET_JSON_pack_array_steal (
+ "row_inconsistencies",
+ report_row_inconsistencies),
+ GNUNET_JSON_pack_array_steal (
+ "coin_inconsistencies",
+ report_coin_inconsistencies),
+ TALER_JSON_pack_amount ("total_coin_delta_plus",
+ &total_coin_delta_plus),
+ TALER_JSON_pack_amount ("total_coin_delta_minus",
+ &total_coin_delta_minus),
+ GNUNET_JSON_pack_array_steal (
+ "amount_arithmetic_inconsistencies",
+ report_amount_arithmetic_inconsistencies),
+ /* block #3 */
+ TALER_JSON_pack_amount (
+ "total_arithmetic_delta_plus",
+ &total_arithmetic_delta_plus),
+ TALER_JSON_pack_amount (
+ "total_arithmetic_delta_minus",
+ &total_arithmetic_delta_minus),
+ TALER_JSON_pack_amount (
+ "aggregation_total_wire_fee_revenue",
+ &TALER_ARL_USE_AB (aggregation_total_wire_fee_revenue)),
+ GNUNET_JSON_pack_uint64 (
+ "start_ppa_wire_out_serial_id",
+ 0 /* defunct */),
+ GNUNET_JSON_pack_uint64 (
+ "end_ppa_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",
+ start_time),
+ TALER_JSON_pack_time_abs_human (
+ "auditor_end_time",
+ GNUNET_TIME_absolute_get ()),
+ GNUNET_JSON_pack_array_steal (
+ "wire_fee_time_inconsistencies",
+ report_fee_time_inconsistencies)));
+ }
+}
+
+
+/**
+ * Function called on shutdown.
+ */
+static void
+do_shutdown (void *cls)
+{
+ (void) cls;
+
+ if (test_mode != 1)
+ {
+ db_plugin->event_listen_cancel (eh);
+ eh = NULL;
+ TALER_AUDITORDB_plugin_unload (db_plugin);
+ db_plugin = NULL;
+ TALER_ARL_done (NULL);
+ }
+}
+
+
+/**
* Main function that will be run.
*
* @param cls closure
@@ -1659,14 +1845,51 @@ run (void *cls,
(void) cls;
(void) args;
(void) cfgfile;
+
+ cfg = c;
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Launching auditor\n");
+ "Launching aggregation auditor\n");
if (GNUNET_OK !=
TALER_ARL_init (c))
{
global_ret = EXIT_FAILURE;
return;
}
+
+ if (test_mode != 1)
+ {
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ if (GNUNET_OK !=
+ db_plugin->preflight (db_plugin->cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to database\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
+
+ struct GNUNET_DB_EventHeaderP es = {
+ .size = htons (sizeof (es)),
+ .type = htons (TALER_DBEVENT_EXCHANGE_AUDITOR_WAKE_HELPER_AGGREGATION)
+ };
+ eh = db_plugin->event_listen (db_plugin->cls,
+ &es,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &db_notify,
+ NULL);
+ }
+
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting audit\n");
GNUNET_assert (GNUNET_OK ==
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c
index 69fbf8262..868e90ccf 100644
--- a/src/auditor/taler-helper-auditor-coins.c
+++ b/src/auditor/taler-helper-auditor-coins.c
@@ -25,6 +25,7 @@
#include "taler_json_lib.h"
#include "taler_bank_service.h"
#include "taler_signatures.h"
+#include "taler_dbevents.h"
#include "report-lib.h"
/**
@@ -179,6 +180,18 @@ static struct CoinHistory coin_histories[MAX_COIN_HISTORIES];
*/
static int internal_checks;
+static struct GNUNET_DB_EventHandler *eh;
+
+/**
+ * Our database plugin.
+ */
+static struct TALER_AUDITORDB_Plugin *db_plugin;
+
+/**
+ * The auditors's configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
/**
* Return the index we should use for @a coin_pub in #coin_histories.
@@ -2731,6 +2744,10 @@ analyze_coins (void *cls)
enum GNUNET_DB_QueryStatus qsp;
char progress_exists = 1;
char balance_exists = 1;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "reached this 10\n");
+
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking denominations...\n");
@@ -3045,6 +3062,242 @@ analyze_coins (void *cls)
/**
+ * Function called on events received from Postgres.
+ *
+ * @param cls closure, NULL
+ * @param extra additional event data provided
+ * @param extra_size number of bytes in @a extra
+ */
+static void
+db_notify (void *cls,
+ const void *extra,
+ size_t extra_size)
+{
+
+ if (test_mode != 1) // TODO: this if case might be obsolete, if condition is already checked in run
+
+ {
+ printf ("dbnotify coins is running!\n");
+
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Received notification to wake coins helper\n");
+
+ (void) cls;
+ (void) extra;
+ (void) extra_size;
+
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "reached this 1\n");
+
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &reported_emergency_loss));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &reported_emergency_risk_by_amount));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &reported_emergency_risk_by_count));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &reported_emergency_loss_by_count));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (total_escrowed)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ coin_deposit_fee_revenue)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ coin_melt_fee_revenue)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ coin_refund_fee_revenue)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ coin_balance_risk)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ total_recoup_loss)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ coin_irregular_loss)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_arithmetic_delta_plus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_arithmetic_delta_minus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_refresh_hanging));
+ GNUNET_assert (NULL !=
+ (report_emergencies = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_emergencies_by_count = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_row_inconsistencies = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_denominations_without_sigs = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_amount_arithmetic_inconsistencies =
+ json_array ()));
+ GNUNET_assert (NULL !=
+ (report_bad_sig_losses = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_refreshes_hanging = json_array ()));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "reached this 2\n");
+
+ if (GNUNET_OK !=
+ TALER_ARL_setup_sessions_and_run (&analyze_coins,
+ NULL))
+ {
+
+ global_ret = 1;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Audit complete\n");
+
+ // TODO: this might be obsolete in the real-time auditor
+ TALER_ARL_done (
+ GNUNET_JSON_PACK (
+ TALER_JSON_pack_amount ("total_escrow_balance",
+ &TALER_ARL_USE_AB (total_escrowed)),
+ TALER_JSON_pack_amount ("total_deposit_fee_income",
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue)),
+ TALER_JSON_pack_amount ("total_melt_fee_income",
+ &TALER_ARL_USE_AB (coin_melt_fee_revenue)),
+ TALER_JSON_pack_amount ("total_refund_fee_income",
+ &TALER_ARL_USE_AB (coin_refund_fee_revenue)),
+ TALER_JSON_pack_amount ("total_active_risk",
+ &TALER_ARL_USE_AB (coin_balance_risk)),
+ TALER_JSON_pack_amount ("total_recoup_loss",
+ &TALER_ARL_USE_AB (total_recoup_loss)),
+ /* Tested in test-auditor.sh #4/#5/#6/#13/#26 */
+ TALER_JSON_pack_amount ("irregular_loss",
+ &TALER_ARL_USE_AB (coin_irregular_loss)),
+ /* Tested in test-auditor.sh #18 */
+ GNUNET_JSON_pack_array_steal ("emergencies",
+ report_emergencies),
+ /* Tested in test-auditor.sh #18 */
+ TALER_JSON_pack_amount ("emergencies_risk_by_amount",
+ &reported_emergency_risk_by_amount),
+ /* Tested in test-auditor.sh #31 */
+ GNUNET_JSON_pack_array_steal ("row_inconsistencies",
+ report_row_inconsistencies),
+ /* Tested in test-auditor.sh #18 */
+ GNUNET_JSON_pack_array_steal ("amount_arithmetic_inconsistencies",
+ report_amount_arithmetic_inconsistencies),
+ TALER_JSON_pack_amount ("total_arithmetic_delta_plus",
+ &total_arithmetic_delta_plus),
+ TALER_JSON_pack_amount ("total_arithmetic_delta_minus",
+ &total_arithmetic_delta_minus),
+ TALER_JSON_pack_amount ("total_refresh_hanging",
+ &total_refresh_hanging),
+ GNUNET_JSON_pack_array_steal ("bad_sig_losses",
+ report_bad_sig_losses),
+ /* Tested in test-auditor.sh #12 */
+ GNUNET_JSON_pack_array_steal ("refresh_hanging",
+ report_refreshes_hanging),
+ /* Tested in test-auditor.sh #18 */
+ GNUNET_JSON_pack_array_steal ("emergencies_by_count",
+ report_emergencies_by_count),
+ /* Tested in test-auditor.sh #18 */
+ TALER_JSON_pack_amount ("emergencies_risk_by_count",
+ &reported_emergency_risk_by_count),
+ /* Tested in test-auditor.sh #18 */
+ TALER_JSON_pack_amount ("emergencies_loss",
+ &reported_emergency_loss),
+ /* Tested in test-auditor.sh #18 */
+ TALER_JSON_pack_amount ("emergencies_loss_by_count",
+ &reported_emergency_loss_by_count),
+ GNUNET_JSON_pack_uint64 ("start_ppc_withdraw_serial_id",
+ 0 /* not implemented */),
+ GNUNET_JSON_pack_uint64 ("start_ppc_deposit_serial_id",
+ 0 /* not implemented */),
+ GNUNET_JSON_pack_uint64 ("start_ppc_melt_serial_id",
+ 0 /* not implemented */),
+ GNUNET_JSON_pack_uint64 ("start_ppc_refund_serial_id",
+ 0 /* not implemented */),
+ GNUNET_JSON_pack_uint64 ("start_ppc_recoup_serial_id",
+ 0 /* not implemented */),
+ GNUNET_JSON_pack_uint64 ("start_ppc_recoup_refresh_serial_id",
+ 0 /* not implemented */),
+ GNUNET_JSON_pack_uint64 ("start_ppc_purse_deposits_serial_id",
+ 0 /* not implemented */),
+ GNUNET_JSON_pack_uint64 ("start_ppc_purse_refunds_serial_id",
+ 0 /* not implemented */),
+ GNUNET_JSON_pack_uint64 ("end_ppc_withdraw_serial_id",
+ TALER_ARL_USE_PP (coins_withdraw_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppc_deposit_serial_id",
+ TALER_ARL_USE_PP (coins_deposit_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppc_melt_serial_id",
+ TALER_ARL_USE_PP (coins_melt_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppc_refund_serial_id",
+ TALER_ARL_USE_PP (coins_refund_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppc_recoup_serial_id",
+ TALER_ARL_USE_PP (coins_recoup_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppc_recoup_refresh_serial_id",
+ TALER_ARL_USE_PP (
+ coins_recoup_refresh_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppc_purse_deposits_serial_id",
+ TALER_ARL_USE_PP (
+ coins_purse_deposits_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppc_purse_refunds_serial_id",
+ 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)));
+
+
+ }
+}
+
+
+/**
+ * Function called on shutdown.
+ */
+static void
+do_shutdown (void *cls)
+{
+ (void) cls;
+
+ if (test_mode != 1)
+ {
+ db_plugin->event_listen_cancel (eh);
+ eh = NULL;
+ TALER_AUDITORDB_plugin_unload (db_plugin);
+ db_plugin = NULL;
+ TALER_ARL_done (NULL);
+ }
+}
+
+
+/**
* Main function that will be run.
*
* @param cls closure
@@ -3061,14 +3314,54 @@ run (void *cls,
(void) cls;
(void) args;
(void) cfgfile;
+
+ cfg = c;
+
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+ NULL);
+
+ printf ("helper coins is alive\n");
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Launching auditor\n");
+ "Launching coins auditor\n");
if (GNUNET_OK !=
TALER_ARL_init (c))
{
global_ret = EXIT_FAILURE;
return;
}
+
+ if (test_mode != 1)
+ {
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ if (GNUNET_OK !=
+ db_plugin->preflight (db_plugin->cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to database\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
+
+ struct GNUNET_DB_EventHeaderP es = {
+ .size = htons (sizeof (es)),
+ .type = htons (TALER_DBEVENT_EXCHANGE_AUDITOR_WAKE_HELPER_COINS)
+ };
+ eh = db_plugin->event_listen (db_plugin->cls,
+ &es,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &db_notify,
+ NULL);
+ }
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting audit\n");
GNUNET_assert (GNUNET_OK ==
diff --git a/src/auditor/taler-helper-auditor-purses.c b/src/auditor/taler-helper-auditor-purses.c
index bc13a5fad..9a2f883a6 100644
--- a/src/auditor/taler-helper-auditor-purses.c
+++ b/src/auditor/taler-helper-auditor-purses.c
@@ -26,6 +26,7 @@
#include "taler_bank_service.h"
#include "taler_signatures.h"
#include "report-lib.h"
+#include "taler_dbevents.h"
/**
@@ -118,6 +119,18 @@ static struct TALER_Amount total_bad_sig_loss;
*/
static int internal_checks;
+static struct GNUNET_DB_EventHandler *eh;
+
+/**
+ * Our database plugin.
+ */
+static struct TALER_AUDITORDB_Plugin *db_plugin;
+
+/**
+ * The auditors's configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
/* ***************************** Report logic **************************** */
@@ -1402,6 +1415,157 @@ analyze_purses (void *cls)
/**
+ * Function called on events received from Postgres.
+ *
+ * @param cls closure, NULL
+ * @param extra additional event data provided
+ * @param extra_size number of bytes in @a extra
+ */
+static void
+db_notify (void *cls,
+ const void *extra,
+ size_t extra_size)
+{
+ if (test_mode != 1)
+ {
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Received notification to wake purses\n");
+
+ (void) cls;
+ (void) extra;
+ (void) extra_size;
+
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ purse_global_balance)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_balance_insufficient_loss));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_delayed_decisions));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_arithmetic_delta_plus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_arithmetic_delta_minus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_balance_purse_not_closed));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_bad_sig_loss));
+
+ GNUNET_assert (NULL !=
+ (report_row_inconsistencies = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_purse_balance_insufficient_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_purse_not_closed_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_amount_arithmetic_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_bad_sig_losses = json_array ()));
+ if (GNUNET_OK !=
+ TALER_ARL_setup_sessions_and_run (&analyze_purses,
+ NULL))
+ {
+ global_ret = EXIT_FAILURE;
+ }
+
+ // TODO: might not be necessary
+ TALER_ARL_done (
+ GNUNET_JSON_PACK (
+ /* Globals (REVIEW!) */
+ TALER_JSON_pack_amount ("total_balance_insufficient",
+ &total_balance_insufficient_loss),
+ TALER_JSON_pack_amount ("total_delayed_purse_decisions",
+ &total_delayed_decisions),
+ GNUNET_JSON_pack_array_steal (
+ "purse_balance_insufficient_inconsistencies",
+ report_purse_balance_insufficient_inconsistencies),
+ TALER_JSON_pack_amount ("total_balance_purse_not_closed",
+ &total_balance_purse_not_closed),
+ TALER_JSON_pack_amount ("total_bad_sig_loss",
+ &total_bad_sig_loss),
+ TALER_JSON_pack_amount ("total_arithmetic_delta_plus",
+ &total_arithmetic_delta_plus),
+ TALER_JSON_pack_amount ("total_arithmetic_delta_minus",
+ &total_arithmetic_delta_minus),
+
+ /* Global 'balances' */
+ TALER_JSON_pack_amount ("total_purse_balance",
+ &TALER_ARL_USE_AB (purse_global_balance)),
+ GNUNET_JSON_pack_uint64 ("total_purse_count",
+ TALER_ARL_USE_PP (purse_open_counter)),
+
+ GNUNET_JSON_pack_array_steal ("purse_not_closed_inconsistencies",
+ report_purse_not_closed_inconsistencies),
+ GNUNET_JSON_pack_array_steal ("bad_sig_losses",
+ report_bad_sig_losses),
+ GNUNET_JSON_pack_array_steal ("row_inconsistencies",
+ report_row_inconsistencies),
+ GNUNET_JSON_pack_array_steal ("amount_arithmetic_inconsistencies",
+ report_amount_arithmetic_inconsistencies),
+ /* Information about audited range ... */
+ 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_uint64 ("start_ppp_purse_merges_serial_id",
+ 0 /* not supported anymore */),
+ GNUNET_JSON_pack_uint64 ("start_ppp_purse_deposits_serial_id",
+ 0 /* not supported anymore */),
+ GNUNET_JSON_pack_uint64 ("start_ppp_account_merge_serial_id",
+ 0 /* not supported anymore */),
+ GNUNET_JSON_pack_uint64 ("end_ppp_purse_merges_serial_id",
+ TALER_ARL_USE_PP (
+ purse_merges_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppp_purse_deposits_serial_id",
+ TALER_ARL_USE_PP (
+ purse_deposits_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppp_account_merge_serial_id",
+ TALER_ARL_USE_PP (
+ purse_account_merge_serial_id))));
+
+ }
+}
+
+
+/**
+ * Function called on shutdown.
+ */
+static void
+do_shutdown (void *cls)
+{
+ (void) cls;
+
+ if (test_mode != 1)
+ {
+ db_plugin->event_listen_cancel (eh);
+ eh = NULL;
+ TALER_AUDITORDB_plugin_unload (db_plugin);
+ db_plugin = NULL;
+ TALER_ARL_done (NULL);
+ }
+}
+
+
+/**
* Main function that will be run.
*
* @param cls closure
@@ -1418,14 +1582,53 @@ run (void *cls,
(void) cls;
(void) args;
(void) cfgfile;
+
+ cfg = c;
+
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+ NULL);
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Launching auditor\n");
+ "Launching purses auditor\n");
if (GNUNET_OK !=
TALER_ARL_init (c))
{
global_ret = EXIT_FAILURE;
return;
}
+
+ if (test_mode != 1)
+ {
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ if (GNUNET_OK !=
+ db_plugin->preflight (db_plugin->cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to database\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
+
+ struct GNUNET_DB_EventHeaderP es = {
+ .size = htons (sizeof (es)),
+ .type = htons (TALER_DBEVENT_EXCHANGE_AUDITOR_WAKE_HELPER_PURSES)
+ };
+ eh = db_plugin->event_listen (db_plugin->cls,
+ &es,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &db_notify,
+ NULL);
+ }
+
+
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
&TALER_ARL_USE_AB (
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c
index d332290ea..45e47af43 100644
--- a/src/auditor/taler-helper-auditor-reserves.c
+++ b/src/auditor/taler-helper-auditor-reserves.c
@@ -26,6 +26,7 @@
#include "taler_bank_service.h"
#include "taler_signatures.h"
#include "report-lib.h"
+#include "taler_dbevents.h"
/**
@@ -156,6 +157,18 @@ static struct TALER_Amount total_bad_sig_loss;
*/
static int internal_checks;
+static struct GNUNET_DB_EventHandler *eh;
+
+/**
+ * Our database plugin.
+ */
+static struct TALER_AUDITORDB_Plugin *db_plugin;
+
+/**
+ * The auditors's configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
/* ***************************** Report logic **************************** */
@@ -2178,6 +2191,244 @@ analyze_reserves (void *cls)
/**
+ * Function called on events received from Postgres.
+ *
+ * @param cls closure, NULL
+ * @param extra additional event data provided
+ * @param extra_size number of bytes in @a extra
+ */
+static void
+db_notify (void *cls,
+ const void *extra,
+ size_t extra_size)
+{
+ if (test_mode != 1)
+ {
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Received notification for new deposit_confirmation\n");
+
+ (void) cls;
+ (void) extra;
+ (void) extra_size;
+
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ reserves_reserve_total_balance)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ reserves_reserve_loss)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ reserves_withdraw_fee_revenue)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ reserves_close_fee_revenue)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ reserves_purse_fee_revenue)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ reserves_open_fee_revenue)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ reserves_history_fee_revenue)));
+ // REVIEW:
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_balance_summary_delta_plus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_balance_summary_delta_minus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_arithmetic_delta_plus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_arithmetic_delta_minus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_balance_reserve_not_closed));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_bad_sig_loss));
+
+ GNUNET_assert (NULL !=
+ (report_row_inconsistencies = json_array ()));
+ GNUNET_assert (NULL !=
+ (denomination_key_validity_withdraw_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_reserve_balance_summary_wrong_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_reserve_balance_insufficient_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_purse_balance_insufficient_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_reserve_not_closed_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_amount_arithmetic_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_bad_sig_losses = json_array ()));
+ if (GNUNET_OK !=
+ TALER_ARL_setup_sessions_and_run (&analyze_reserves,
+ NULL))
+ {
+ global_ret = EXIT_FAILURE;
+ }
+ TALER_ARL_done ( // TODO: might be unnecessary
+ GNUNET_JSON_PACK (
+ /* Tested in test-auditor.sh #3 */
+ GNUNET_JSON_pack_array_steal (
+ "reserve_balance_summary_wrong_inconsistencies",
+ report_reserve_balance_summary_wrong_inconsistencies),
+ TALER_JSON_pack_amount ("total_balance_summary_delta_plus",
+ &total_balance_summary_delta_plus),
+ TALER_JSON_pack_amount ("total_balance_summary_delta_minus",
+ &total_balance_summary_delta_minus),
+ /* Tested in test-auditor.sh #21 */
+ TALER_JSON_pack_amount ("total_balance_reserve_not_closed",
+ &total_balance_reserve_not_closed),
+ /* Tested in test-auditor.sh #7 */
+ TALER_JSON_pack_amount ("total_bad_sig_loss",
+ &total_bad_sig_loss),
+ TALER_JSON_pack_amount ("total_arithmetic_delta_plus",
+ &total_arithmetic_delta_plus),
+ TALER_JSON_pack_amount ("total_arithmetic_delta_minus",
+ &total_arithmetic_delta_minus),
+
+ /* Global 'balances' */
+ TALER_JSON_pack_amount ("total_escrow_balance",
+ &TALER_ARL_USE_AB (
+ reserves_reserve_total_balance)),
+ /* Tested in test-auditor.sh #3 */
+ TALER_JSON_pack_amount ("total_irregular_loss",
+ &TALER_ARL_USE_AB (reserves_reserve_loss)),
+ TALER_JSON_pack_amount ("total_withdraw_fee_income",
+ &TALER_ARL_USE_AB (
+ reserves_withdraw_fee_revenue)),
+ TALER_JSON_pack_amount ("total_close_fee_income",
+ &TALER_ARL_USE_AB (reserves_close_fee_revenue)),
+ TALER_JSON_pack_amount ("total_purse_fee_income",
+ &TALER_ARL_USE_AB (reserves_purse_fee_revenue)),
+ TALER_JSON_pack_amount ("total_open_fee_income",
+ &TALER_ARL_USE_AB (reserves_open_fee_revenue)),
+ TALER_JSON_pack_amount ("total_history_fee_income",
+ &TALER_ARL_USE_AB (
+ reserves_history_fee_revenue)),
+
+ /* Detailed report tables */
+ GNUNET_JSON_pack_array_steal (
+ "reserve_balance_insufficient_inconsistencies",
+ report_reserve_balance_insufficient_inconsistencies),
+ GNUNET_JSON_pack_array_steal (
+ "purse_balance_insufficient_inconsistencies",
+ report_purse_balance_insufficient_inconsistencies),
+ /* Tested in test-auditor.sh #21 */
+ GNUNET_JSON_pack_array_steal ("reserve_not_closed_inconsistencies",
+ report_reserve_not_closed_inconsistencies),
+ /* Tested in test-auditor.sh #7 */
+ GNUNET_JSON_pack_array_steal ("bad_sig_losses",
+ report_bad_sig_losses),
+ /* Tested in test-revocation.sh #4 */
+ GNUNET_JSON_pack_array_steal ("row_inconsistencies",
+ report_row_inconsistencies),
+ /* Tested in test-auditor.sh #23 */
+ GNUNET_JSON_pack_array_steal (
+ "denomination_key_validity_withdraw_inconsistencies",
+ denomination_key_validity_withdraw_inconsistencies),
+ GNUNET_JSON_pack_array_steal ("amount_arithmetic_inconsistencies",
+ report_amount_arithmetic_inconsistencies),
+
+ /* Information about audited range ... */
+ 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_uint64 ("start_ppr_reserve_in_serial_id",
+ 0 /* no longer supported */),
+ GNUNET_JSON_pack_uint64 ("start_ppr_reserve_out_serial_id",
+ 0 /* no longer supported */),
+ GNUNET_JSON_pack_uint64 ("start_ppr_reserve_recoup_serial_id",
+ 0 /* no longer supported */),
+ GNUNET_JSON_pack_uint64 ("start_ppr_reserve_open_serial_id",
+ 0 /* no longer supported */),
+ GNUNET_JSON_pack_uint64 ("start_ppr_reserve_close_serial_id",
+ 0 /* no longer supported */),
+ GNUNET_JSON_pack_uint64 ("start_ppr_purse_decisions_serial_id",
+ 0 /* no longer supported */),
+ GNUNET_JSON_pack_uint64 ("start_ppr_account_merges_serial_id",
+ 0 /* no longer supported */),
+ GNUNET_JSON_pack_uint64 ("start_ppr_history_requests_serial_id",
+ 0 /* no longer supported */),
+ GNUNET_JSON_pack_uint64 ("end_ppr_reserve_in_serial_id",
+ TALER_ARL_USE_PP (
+ reserves_reserve_in_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppr_reserve_out_serial_id",
+ TALER_ARL_USE_PP (
+ reserves_reserve_out_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppr_reserve_recoup_serial_id",
+ TALER_ARL_USE_PP (
+ reserves_reserve_recoup_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppr_reserve_open_serial_id",
+ TALER_ARL_USE_PP (
+ reserves_reserve_open_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppr_reserve_close_serial_id",
+ TALER_ARL_USE_PP (
+ reserves_reserve_close_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppr_purse_decisions_serial_id",
+ TALER_ARL_USE_PP (
+ reserves_purse_decisions_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppr_account_merges_serial_id",
+ TALER_ARL_USE_PP (
+ reserves_account_merges_serial_id)),
+ GNUNET_JSON_pack_uint64 ("end_ppr_history_requests_serial_id",
+ TALER_ARL_USE_PP (
+ reserves_history_requests_serial_id))));
+ }
+}
+
+
+/**
+ * Function called on shutdown.
+ */
+static void
+do_shutdown (void *cls)
+{
+ (void) cls;
+
+ if (test_mode != 1)
+ {
+ db_plugin->event_listen_cancel (eh);
+ eh = NULL;
+ TALER_AUDITORDB_plugin_unload (db_plugin);
+ db_plugin = NULL;
+ TALER_ARL_done (NULL);
+ }
+}
+
+
+/**
* Main function that will be run.
*
* @param cls closure
@@ -2194,8 +2445,14 @@ run (void *cls,
(void) cls;
(void) args;
(void) cfgfile;
+
+ cfg = c;
+
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+ NULL);
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Launching auditor\n");
+ "Launching reserves auditor\n");
if (GNUNET_OK !=
TALER_ARL_init (c))
{
@@ -2294,6 +2551,37 @@ run (void *cls,
return;
}
+ if (test_mode != 1)
+ {
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ if (GNUNET_OK !=
+ db_plugin->preflight (db_plugin->cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to database\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
+
+ struct GNUNET_DB_EventHeaderP es = {
+ .size = htons (sizeof (es)),
+ .type = htons (TALER_DBEVENT_EXCHANGE_AUDITOR_WAKE_HELPER_RESERVES)
+ };
+ eh = db_plugin->event_listen (db_plugin->cls,
+ &es,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &db_notify,
+ NULL);
+ }
+
TALER_ARL_done (
GNUNET_JSON_PACK (
/* Tested in test-auditor.sh #3 */
diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c
index 3faf37f98..b5cc9eb13 100644
--- a/src/auditor/taler-helper-auditor-wire.c
+++ b/src/auditor/taler-helper-auditor-wire.c
@@ -34,6 +34,7 @@
#include "taler_bank_service.h"
#include "taler_signatures.h"
#include "report-lib.h"
+#include "taler_dbevents.h"
/**
@@ -386,6 +387,18 @@ static int internal_checks;
*/
static int ignore_account_404;
+static struct GNUNET_DB_EventHandler *eh;
+
+/**
+ * Our database plugin.
+ */
+static struct TALER_AUDITORDB_Plugin *db_plugin;
+
+/**
+ * The auditors's configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
/* ***************************** Shutdown **************************** */
/**
@@ -522,6 +535,16 @@ do_shutdown (void *cls)
struct WireAccount *wa;
(void) cls;
+
+ if (test_mode != 1)
+ {
+ db_plugin->event_listen_cancel (eh);
+ eh = NULL;
+ TALER_AUDITORDB_plugin_unload (db_plugin);
+ db_plugin = NULL;
+ TALER_ARL_done (NULL);
+ }
+
if (NULL != report_row_inconsistencies)
{
GNUNET_assert (NULL != report_row_minor_inconsistencies);
@@ -2777,6 +2800,136 @@ process_account_cb (void *cls,
/**
+ * Function called on events received from Postgres.
+ *
+ * @param cls closure, NULL
+ * @param extra additional event data provided
+ * @param extra_size number of bytes in @a extra
+ */
+static void
+db_notify (void *cls,
+ const void *extra,
+ size_t extra_size)
+{
+ if (test_mode != 1)
+ {
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Received notification to wake wire helper\n");
+
+ (void) cls;
+ (void) extra;
+ (void) extra_size;
+
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+
+
+ if (GNUNET_OK !=
+ TALER_config_get_amount (TALER_ARL_cfg,
+ "auditor",
+ "TINY_AMOUNT",
+ &tiny_amount))
+ {
+ global_ret = EXIT_NOTCONFIGURED;
+ return;
+ }
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+ NULL);
+ ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
+ &rc);
+ rc = GNUNET_CURL_gnunet_rc_create (ctx);
+ if (NULL == ctx)
+ {
+ GNUNET_break (0);
+ global_ret = EXIT_FAILURE;
+ return;
+ }
+ reserve_closures = GNUNET_CONTAINER_multihashmap_create (1024,
+ GNUNET_NO);
+ GNUNET_assert (NULL !=
+ (report_wire_out_inconsistencies = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_reserve_in_inconsistencies = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_row_minor_inconsistencies = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_wire_format_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_row_inconsistencies = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_misattribution_in_inconsistencies
+ = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_lags = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_aml_lags = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_kyc_lags = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_closure_lags = json_array ()));
+ GNUNET_assert (NULL !=
+ (report_account_progress = json_array ()));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_bad_amount_out_plus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_bad_amount_out_minus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_bad_amount_in_plus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_bad_amount_in_minus));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_misattribution_in));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_amount_lag));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_closure_amount_lag));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &total_wire_format_amount));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &zero));
+ if (GNUNET_OK !=
+ TALER_EXCHANGEDB_load_accounts (TALER_ARL_cfg,
+ TALER_EXCHANGEDB_ALO_DEBIT
+ | TALER_EXCHANGEDB_ALO_CREDIT
+ | TALER_EXCHANGEDB_ALO_AUTHDATA))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "No bank accounts configured\n");
+ global_ret = EXIT_NOTCONFIGURED;
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ TALER_EXCHANGEDB_find_accounts (&process_account_cb,
+ NULL);
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
+ begin_transaction ())
+ {
+ GNUNET_break (0);
+ global_ret = EXIT_FAILURE;
+ GNUNET_SCHEDULER_shutdown ();
+ }
+
+
+ }
+}
+
+
+/**
* Main function that will be run.
*
* @param cls closure
@@ -2801,6 +2954,39 @@ run (void *cls,
global_ret = EXIT_FAILURE;
return;
}
+
+ if (test_mode != 1)
+ {
+ if (NULL ==
+ (db_plugin = TALER_AUDITORDB_plugin_load (cfg)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize DB subsystem\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ if (GNUNET_OK !=
+ db_plugin->preflight (db_plugin->cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to database\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
+
+ struct GNUNET_DB_EventHeaderP es = {
+ .size = htons (sizeof (es)),
+ .type = htons (TALER_DBEVENT_EXCHANGE_AUDITOR_WAKE_HELPER_WIRE)
+ };
+ eh = db_plugin->event_listen (db_plugin->cls,
+ &es,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &db_notify,
+ NULL);
+ }
+
+
if (GNUNET_OK !=
TALER_config_get_amount (TALER_ARL_cfg,
"auditor",
diff --git a/src/exchangedb/auditor-triggers-0001.sql b/src/exchangedb/auditor-triggers-0001.sql
index 4e2ea66ce..5849b32a5 100644
--- a/src/exchangedb/auditor-triggers-0001.sql
+++ b/src/exchangedb/auditor-triggers-0001.sql
@@ -19,8 +19,7 @@ BEGIN;
SELECT _v.register_patch('auditor-triggers-0001');
-SET search_path TO exchange;
-
+/*
CREATE OR REPLACE FUNCTION auditor_new_deposits_trigger()
RETURNS trigger
LANGUAGE plpgsql
@@ -36,6 +35,464 @@ CREATE TRIGGER auditor_notify_helper_insert_deposits
AFTER INSERT
ON exchange.batch_deposits
EXECUTE PROCEDURE auditor_new_deposits_trigger();
+*/
+
+
+-- make 6 of these functions, one for each helper
+
+-- the coins helper listens to this trigger
+CREATE OR REPLACE FUNCTION auditor_wake_coins_helper_trigger()
+ RETURNS trigger
+ LANGUAGE plpgsql
+AS $$
+BEGIN
+ NOTIFY X5V5R0DDFMXS0R3W058R3W4RPDVMK35YZCS0S5VZS583J0NR0PE2G;
+RETURN NEW;
+END $$;
+COMMENT ON FUNCTION auditor_wake_coins_helper_trigger()
+ IS 'Call auditor_call_db_notify on new entry';
+
+
+-- the purses helper listens to this trigger
+CREATE OR REPLACE FUNCTION auditor_wake_purses_helper_trigger()
+ RETURNS trigger
+ LANGUAGE plpgsql
+AS $$
+BEGIN
+ NOTIFY X908G8PNPMJYA59YGGTJND1TKTBFNG8C7TREHG3X5SJ9EQAJY4Z00;
+RETURN NEW;
+END $$;
+COMMENT ON FUNCTION auditor_wake_purses_helper_trigger()
+ IS 'Call auditor_call_db_notify on new entry';
+
+
+-- the deposits helper listens to this trigger
+CREATE OR REPLACE FUNCTION auditor_wake_deposits_helper_trigger()
+ RETURNS trigger
+ LANGUAGE plpgsql
+AS $$
+BEGIN
+ NOTIFY XZD0FASMJD3XCY3Z0CGXNJQ8CMWSCW80JN6796098N71CXPH70TQ0;
+RETURN NEW;
+END $$;
+COMMENT ON FUNCTION auditor_wake_deposits_helper_trigger()
+ IS 'Call auditor_call_db_notify on new entry';
+
+-- the reserves helper listens to this trigger
+CREATE OR REPLACE FUNCTION auditor_wake_reserves_helper_trigger()
+ RETURNS trigger
+ LANGUAGE plpgsql
+AS $$
+BEGIN
+ NOTIFY XMF69RJQB7EN06KGSQ02VFD3723CE86VXA5GRE8H7XNNS6BDYF0G0;
+RETURN NEW;
+END $$;
+COMMENT ON FUNCTION auditor_wake_reserves_helper_trigger()
+ IS 'Call auditor_call_db_notify on new entry';
+
+-- the wire helper listens to this trigger
+CREATE OR REPLACE FUNCTION auditor_wake_wire_helper_trigger()
+ RETURNS trigger
+ LANGUAGE plpgsql
+AS $$
+BEGIN
+ NOTIFY X1RYYSTS139MBHVEXJ6CZZTY76MAMEEF87SRRWC8WM00HCCW6D12G;
+RETURN NEW;
+END $$;
+COMMENT ON FUNCTION auditor_wake_wire_helper_trigger()
+ IS 'Call auditor_call_db_notify on new entry';
+
+-- the wire aggregation listens to this trigger
+CREATE OR REPLACE FUNCTION auditor_wake_aggregation_helper_trigger()
+ RETURNS trigger
+ LANGUAGE plpgsql
+AS $$
+BEGIN
+ NOTIFY XWRPZ889FPA6TMGJ15JVTCMKEFVJEWCEKF1TEZHTDQHBYSV49M31G;
+RETURN NEW;
+END $$;
+COMMENT ON FUNCTION auditor_wake_aggregation_helper_trigger()
+ IS 'Call auditor_call_db_notify on new entry';
+
+
+-- call the functions in each table to call all relevant helpers
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation0
+ AFTER INSERT ON exchange.coin_history
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation1
+ AFTER INSERT ON exchange.refunds
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation2
+ AFTER INSERT ON exchange.recoup
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation3
+ AFTER INSERT ON exchange.wire_out
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation4
+ AFTER INSERT ON exchange.purse_decision
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation5
+ AFTER INSERT ON exchange.wire_targets
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation6
+ AFTER INSERT ON exchange.refresh_revealed_coins
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation7
+ AFTER INSERT ON exchange.reserves_open_deposits
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation8
+ AFTER INSERT ON exchange.coin_deposits
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation9
+ AFTER INSERT ON exchange.reserves_out
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation10
+ AFTER INSERT ON exchange.batch_deposits
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation11
+ AFTER INSERT ON exchange.reserves
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation12
+ AFTER INSERT ON exchange.purse_deposits
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation13
+ AFTER INSERT ON exchange.wire_targets
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation14
+ AFTER INSERT ON exchange.known_coins
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation15
+ AFTER INSERT ON exchange.purse_requests
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation16
+ AFTER INSERT ON exchange.aggregation_tracking
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation17
+ AFTER INSERT ON exchange.denominations
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation18
+ AFTER INSERT ON exchange.recoup_refresh
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation19
+ AFTER INSERT ON exchange.refresh_commitments
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_aggregation20
+ AFTER INSERT ON exchange.partners
+EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins0
+ AFTER INSERT ON exchange.refunds
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins1
+ AFTER INSERT ON exchange.recoup
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins2
+ AFTER INSERT ON exchange.auditors
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins3
+ AFTER INSERT ON exchange.purse_decision
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins4
+ AFTER INSERT ON exchange.wire_targets
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins5
+ AFTER INSERT ON exchange.refresh_revealed_coins
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins6
+ AFTER INSERT ON exchange.coin_deposits
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins7
+ AFTER INSERT ON exchange.reserves_out
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins8
+ AFTER INSERT ON exchange.denomination_revocations
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins9
+ AFTER INSERT ON exchange.batch_deposits
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins10
+ AFTER INSERT ON exchange.purse_merges
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins11
+ AFTER INSERT ON exchange.reserves
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins12
+ AFTER INSERT ON exchange.purse_deposits
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins13
+ AFTER INSERT ON exchange.known_coins
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins14
+ AFTER INSERT ON exchange.auditor_denom_sigs
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins15
+ AFTER INSERT ON exchange.purse_requests
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins16
+ AFTER INSERT ON exchange.denominations
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins17
+ AFTER INSERT ON exchange.recoup_refresh
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins18
+ AFTER INSERT ON exchange.refresh_commitments
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_coins19
+ AFTER INSERT ON exchange.partners
+EXECUTE FUNCTION auditor_wake_coins_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_purses0
+ AFTER INSERT ON exchange.purse_merges
+EXECUTE FUNCTION auditor_wake_purses_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_purses1
+ AFTER INSERT ON exchange.known_coins
+EXECUTE FUNCTION auditor_wake_purses_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_purses2
+ AFTER INSERT ON exchange.purse_decision
+EXECUTE FUNCTION auditor_wake_purses_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_purses3
+ AFTER INSERT ON exchange.purse_requests
+EXECUTE FUNCTION auditor_wake_purses_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_purses4
+ AFTER INSERT ON exchange.global_fee
+EXECUTE FUNCTION auditor_wake_purses_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_purses5
+ AFTER INSERT ON exchange.denominations
+EXECUTE FUNCTION auditor_wake_purses_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_purses6
+ AFTER INSERT ON exchange.purse_deposits
+EXECUTE FUNCTION auditor_wake_purses_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_purses7
+ AFTER INSERT ON exchange.account_merges
+EXECUTE FUNCTION auditor_wake_purses_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_purses8
+ AFTER INSERT ON exchange.partners
+EXECUTE FUNCTION auditor_wake_purses_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_deposits0
+ AFTER INSERT ON exchange.known_coins
+EXECUTE FUNCTION auditor_wake_deposits_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_deposits1
+ AFTER INSERT ON exchange.wire_targets
+EXECUTE FUNCTION auditor_wake_deposits_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_deposits2
+ AFTER INSERT ON exchange.denominations
+EXECUTE FUNCTION auditor_wake_deposits_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_deposits3
+ AFTER INSERT ON exchange.coin_deposits
+EXECUTE FUNCTION auditor_wake_deposits_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_deposits4
+ AFTER INSERT ON exchange.batch_deposits
+EXECUTE FUNCTION auditor_wake_deposits_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves0
+ AFTER INSERT ON exchange.purse_merges
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves1
+ AFTER INSERT ON exchange.recoup
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves2
+ AFTER INSERT ON exchange.known_coins
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves3
+ AFTER INSERT ON exchange.reserves_in
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves4
+ AFTER INSERT ON exchange.wire_fee
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves5
+ AFTER INSERT ON exchange.reserves
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves6
+ AFTER INSERT ON exchange.reserves_open_requests
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves7
+ AFTER INSERT ON exchange.purse_decision
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves8
+ AFTER INSERT ON exchange.wire_targets
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves9
+ AFTER INSERT ON exchange.purse_requests
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves10
+ AFTER INSERT ON exchange.reserves_out
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves11
+ AFTER INSERT ON exchange.reserves_close
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves12
+ AFTER INSERT ON exchange.denominations
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_reserves13
+ AFTER INSERT ON exchange.denomination_revocations
+EXECUTE FUNCTION auditor_wake_reserves_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_wire0
+ AFTER INSERT ON exchange.profit_drains
+EXECUTE FUNCTION auditor_wake_wire_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_wire1
+ AFTER INSERT ON exchange.reserves_in
+EXECUTE FUNCTION auditor_wake_wire_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_wire2
+ AFTER INSERT ON exchange.wire_out
+EXECUTE FUNCTION auditor_wake_wire_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_wire3
+ AFTER INSERT ON exchange.reserves
+EXECUTE FUNCTION auditor_wake_wire_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_wire4
+ AFTER INSERT ON exchange.wire_targets
+EXECUTE FUNCTION auditor_wake_wire_helper_trigger();
+
+
+CREATE TRIGGER auditor_exchange_notify_helper_wire5
+ AFTER INSERT ON exchange.aggregation_tracking
+EXECUTE FUNCTION auditor_wake_wire_helper_trigger();
+
+CREATE TRIGGER auditor_exchange_notify_helper_wire6
+ AFTER INSERT ON exchange.reserves_close
+EXECUTE FUNCTION auditor_wake_wire_helper_trigger();
COMMIT;
diff --git a/src/exchangedb/procedures.sql.in b/src/exchangedb/procedures.sql.in
index 7afb01f0b..eaafb4a21 100644
--- a/src/exchangedb/procedures.sql.in
+++ b/src/exchangedb/procedures.sql.in
@@ -45,5 +45,6 @@ SET search_path TO exchange;
#include "exchange_do_batch_reserves_update.sql"
#include "exchange_do_get_link_data.sql"
#include "exchange_do_batch_coin_known.sql"
+#include "auditor-triggers-0001.sql"
COMMIT;
diff --git a/src/testing/taler-unified-setup.sh b/src/testing/taler-unified-setup.sh
index a2fcc351e..811f2d3ce 100755
--- a/src/testing/taler-unified-setup.sh
+++ b/src/testing/taler-unified-setup.sh
@@ -915,6 +915,10 @@ fi
STAGE="ready"
+$USE_VALGRIND taler-helper-auditor-coins \
+ -L "$LOGLEVEL" \
+ -c "$CONF" 2> taler-helper-auditor.log &
+
# Signal caller that we are ready.
echo "<<READY>>"