diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-08-20 23:13:34 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-08-20 23:13:34 +0200 |
commit | d8129d34448d571975c26c96b4a640d58cfb1226 (patch) | |
tree | eed1c0165daa749c6f774d98ff9468097853a1d7 /src/auditor | |
parent | bb5a44b1b13f16db00a3b6f206e8a7fd8bfb58eb (diff) |
clean up auditor code more
Diffstat (limited to 'src/auditor')
-rw-r--r-- | src/auditor/report-lib.c | 80 | ||||
-rw-r--r-- | src/auditor/report-lib.h | 17 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-aggregation.c | 58 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-coins.c | 91 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-deposits.c | 98 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-purses.c | 342 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-reserves.c | 300 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-wire-credit.c | 49 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-wire-debit.c | 53 |
9 files changed, 252 insertions, 836 deletions
diff --git a/src/auditor/report-lib.c b/src/auditor/report-lib.c index 83846a73f..6dd20d677 100644 --- a/src/auditor/report-lib.c +++ b/src/auditor/report-lib.c @@ -77,29 +77,6 @@ struct GNUNET_TIME_Absolute start_time; */ static struct GNUNET_CONTAINER_MultiHashMap *denominations; -/** - * Flag that is raised to 'true' if the user - * presses CTRL-C to abort the audit. - */ -static volatile bool abort_flag; - -/** - * Context for the SIG-INT (ctrl-C) handler. - */ -static struct GNUNET_SIGNAL_Context *sig_int; - -/** - * Context for the SIGTERM handler. - */ -static struct GNUNET_SIGNAL_Context *sig_term; - - -bool -TALER_ARL_do_abort (void) -{ - return abort_flag; -} - /** * Function called with the results of iterate_denomination_info(), @@ -495,17 +472,6 @@ TALER_ARL_amount_subtract_neg_ (struct TALER_Amount *diff, } -/** - * Signal handler called for signals that should cause us to shutdown. - */ -/* -static void -handle_sigint (void) -{ - abort_flag = true; -} -*/ - enum GNUNET_GenericReturnValue TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c) { @@ -660,33 +626,12 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c) return GNUNET_SYSERR; } } -/* - sig_int = GNUNET_SIGNAL_handler_install (SIGINT, - &handle_sigint); - if (NULL == sig_int) - { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "signal"); - TALER_ARL_done (NULL); - return GNUNET_SYSERR; - } - - - sig_term = GNUNET_SIGNAL_handler_install (SIGTERM, - &handle_sigint); - if (NULL == sig_term) - { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "signal"); - TALER_ARL_done (NULL); - return GNUNET_SYSERR; - }*/ if (NULL == (TALER_ARL_edb = TALER_EXCHANGEDB_plugin_load (TALER_ARL_cfg))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize exchange database plugin.\n"); - TALER_ARL_done (NULL); + TALER_ARL_done (); return GNUNET_SYSERR; } if (NULL == @@ -694,7 +639,7 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize auditor database plugin.\n"); - TALER_ARL_done (NULL); + TALER_ARL_done (); return GNUNET_SYSERR; } if (GNUNET_SYSERR == @@ -702,7 +647,7 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start session with auditor database.\n"); - TALER_ARL_done (NULL); + TALER_ARL_done (); return GNUNET_SYSERR; } return GNUNET_OK; @@ -710,20 +655,10 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c) void -TALER_ARL_done (json_t *report) +TALER_ARL_done () { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audit complete\n"); - if (NULL != sig_int) - { - GNUNET_SIGNAL_handler_uninstall (sig_int); - sig_int = NULL; - } - if (NULL != sig_term) - { - GNUNET_SIGNAL_handler_uninstall (sig_term); - sig_term = NULL; - } if (NULL != TALER_ARL_adb) { TALER_AUDITORDB_plugin_unload (TALER_ARL_adb); @@ -734,13 +669,6 @@ TALER_ARL_done (json_t *report) TALER_EXCHANGEDB_plugin_unload (TALER_ARL_edb); TALER_ARL_edb = NULL; } - if (NULL != report) - { - json_dumpf (report, - stdout, - JSON_INDENT (2)); - json_decref (report); - } GNUNET_free (TALER_ARL_exchange_url); GNUNET_free (TALER_ARL_auditor_url); } diff --git a/src/auditor/report-lib.h b/src/auditor/report-lib.h index dc31ec552..bf2d63740 100644 --- a/src/auditor/report-lib.h +++ b/src/auditor/report-lib.h @@ -323,17 +323,6 @@ TALER_ARL_setup_sessions_and_run (TALER_ARL_Analysis ana, /** - * Test if the audit should be aborted because the user - * pressed CTRL-C. - * - * @return false to continue the audit, true to terminate - * cleanly as soon as possible - */ -bool -TALER_ARL_do_abort (void); - - -/** * Setup global variables based on configuration. * * @param c configuration to use @@ -344,11 +333,9 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c); /** - * Generate the report and close connectios to the database. - * - * @param report the report to output, may be NULL for no report + * Close connections to the database. */ void -TALER_ARL_done (json_t *report); +TALER_ARL_done (void); #endif diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c index 8f757fada..4353499fa 100644 --- a/src/auditor/taler-helper-auditor-aggregation.c +++ b/src/auditor/taler-helper-auditor-aggregation.c @@ -95,11 +95,6 @@ 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; @@ -1278,8 +1273,6 @@ check_wire_out_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Aggregation unit %s is OK\n", TALER_B2S (wtid)); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1499,8 +1492,9 @@ db_notify (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audit failed\n"); - TALER_ARL_done (NULL); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; + return; } } @@ -1512,15 +1506,12 @@ static void do_shutdown (void *cls) { (void) cls; - - if (test_mode != 1) + if (NULL != eh) { - db_plugin->event_listen_cancel (eh); + TALER_ARL_adb->event_listen_cancel (eh); eh = NULL; - TALER_AUDITORDB_plugin_unload (db_plugin); - db_plugin = NULL; - TALER_ARL_done (NULL); } + TALER_ARL_done (); } @@ -1543,8 +1534,8 @@ run (void *cls, (void) cfgfile; cfg = c; - GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); - + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, + NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Launching aggregation auditor\n"); if (GNUNET_OK != @@ -1554,38 +1545,20 @@ run (void *cls, return; } - 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; - } - if (test_mode != 1) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running helper indefinitely\n"); - 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); - return; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Running helper indefinitely\n"); + eh = TALER_ARL_adb->event_listen (TALER_ARL_adb->cls, + &es, + GNUNET_TIME_UNIT_FOREVER_REL, + &db_notify, + NULL); } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting audit\n"); @@ -1595,11 +1568,10 @@ run (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audit failed\n"); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Audit complete\n"); } diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index e9d0d5378..03878e5c1 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c @@ -140,11 +140,6 @@ 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; @@ -961,8 +956,6 @@ withdraw_cb (void *cls, report_row_inconsistency ("withdraw", rowid, "denomination key not found"); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) @@ -1002,8 +995,6 @@ withdraw_cb (void *cls, TALER_ARL_amount_add (&ds->dcd.denom_risk, &ds->dcd.denom_risk, &issue->value); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1272,8 +1263,6 @@ refresh_session_cb (void *cls, report_row_inconsistency ("melt", rowid, "denomination key not found"); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) @@ -1375,8 +1364,6 @@ refresh_session_cb (void *cls, TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_refresh_hanging), &TALER_ARL_USE_AB (total_refresh_hanging), amount_with_fee); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } if (GNUNET_SYSERR == reveal_ctx.err) @@ -1387,8 +1374,6 @@ refresh_session_cb (void *cls, GNUNET_free (reveal_ctx.new_issues); if (GNUNET_SYSERR == reveal_ctx.err) return GNUNET_SYSERR; - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1509,8 +1494,6 @@ refresh_session_cb (void *cls, 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; return GNUNET_OK; } @@ -1554,8 +1537,6 @@ deposit_cb (void *cls, report_row_inconsistency ("deposits", rowid, "denomination key not found"); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } if (GNUNET_TIME_timestamp_cmp (deposit->refund_deadline, @@ -1634,8 +1615,6 @@ deposit_cb (void *cls, 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; return GNUNET_OK; } } @@ -1666,8 +1645,6 @@ deposit_cb (void *cls, 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; return GNUNET_OK; } @@ -1719,8 +1696,6 @@ refund_cb (void *cls, report_row_inconsistency ("refunds", rowid, "denomination key not found"); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) @@ -1755,8 +1730,6 @@ refund_cb (void *cls, 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; return GNUNET_OK; } @@ -1770,8 +1743,6 @@ refund_cb (void *cls, &amount_without_fee, &issue->fees.refund, -1); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1820,8 +1791,6 @@ refund_cb (void *cls, &TALER_ARL_USE_AB (coin_deposit_fee_revenue), &issue->fees.deposit); } - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1858,8 +1827,6 @@ purse_refund_coin_cb ( report_row_inconsistency ("purse-refunds", rowid, "denomination key not found"); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) @@ -1947,8 +1914,6 @@ purse_refund_cb (void *cls, GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return GNUNET_SYSERR; } - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -2022,8 +1987,6 @@ check_recoup (struct CoinContext *cc, report_row_inconsistency (operation, rowid, "denomination key not found"); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) @@ -2086,8 +2049,6 @@ check_recoup (struct CoinContext *cc, &TALER_ARL_USE_AB (total_recoup_loss), amount); } - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -2148,8 +2109,6 @@ recoup_cb (void *cls, 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; return GNUNET_OK; } return check_recoup (cc, @@ -2267,8 +2226,6 @@ recoup_refresh_cb (void *cls, 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; return GNUNET_OK; } return check_recoup (cc, @@ -2404,8 +2361,6 @@ purse_deposit_cb ( report_row_inconsistency ("purse-deposits", rowid, "denomination key not found"); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } qs = check_known_coin ("purse-deposit", @@ -2451,8 +2406,6 @@ purse_deposit_cb ( 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; return GNUNET_OK; } @@ -2477,8 +2430,6 @@ purse_deposit_cb ( 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; return GNUNET_OK; } @@ -2884,8 +2835,9 @@ db_notify (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audit failed\n"); - TALER_ARL_done (NULL); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; + return; } } @@ -2897,11 +2849,12 @@ static void do_shutdown (void *cls) { (void) cls; - TALER_ARL_done (NULL); - db_plugin->event_listen_cancel (eh); - eh = NULL; - TALER_AUDITORDB_plugin_unload (db_plugin); - db_plugin = NULL; + if (NULL != eh) + { + TALER_ARL_adb->event_listen_cancel (eh); + eh = NULL; + } + TALER_ARL_done (); } @@ -2932,23 +2885,6 @@ run (void *cls, global_ret = EXIT_FAILURE; return; } - 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; - } - if (test_mode != 1) { struct GNUNET_DB_EventHeaderP es = { @@ -2958,11 +2894,11 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running helper indefinitely\n"); - eh = db_plugin->event_listen (db_plugin->cls, - &es, - GNUNET_TIME_UNIT_FOREVER_REL, - &db_notify, - NULL); + eh = TALER_ARL_adb->event_listen (TALER_ARL_adb->cls, + &es, + GNUNET_TIME_UNIT_FOREVER_REL, + &db_notify, + NULL); } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting audit\n"); @@ -2972,6 +2908,7 @@ run (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audit failed\n"); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c index a9f0712cf..e4a4dc597 100644 --- a/src/auditor/taler-helper-auditor-deposits.c +++ b/src/auditor/taler-helper-auditor-deposits.c @@ -26,7 +26,6 @@ #include <gnunet/gnunet_util_lib.h> #include "taler_auditordb_plugin.h" #include "taler_exchangedb_lib.h" -#include "taler_json_lib.h" #include "taler_bank_service.h" #include "taler_signatures.h" #include "report-lib.h" @@ -69,13 +68,9 @@ static int global_ret; static int test_mode; /** - * Array of reports about missing deposit confirmations. - */ -static json_t *report_deposit_confirmation_inconsistencies; - -/** * Total number of deposit confirmations that we did not get. */ +// FIXME: persist! static json_int_t number_missed_deposit_confirmations; /** @@ -91,11 +86,6 @@ 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; @@ -196,12 +186,6 @@ test_dc (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found deposit %s in exchange database\n", GNUNET_h2s (&dc->h_contract_terms.hash)); - - if (TALER_ARL_do_abort ()) - { - return GNUNET_SYSERR; - } - return GNUNET_OK; /* all coins found, all good */ } // dcc->first_missed_coin_serial = GNUNET_MIN (dcc->first_missed_coin_serial, serial_id); @@ -209,10 +193,6 @@ test_dc (void *cls, TALER_ARL_amount_add (&dcc->missed_amount, &dcc->missed_amount, &dc->total_without_fee); - if (TALER_ARL_do_abort ()) - { - return GNUNET_SYSERR; - } return GNUNET_OK; } @@ -264,7 +244,6 @@ analyze_deposit_confirmations (void *cls) dcc.missed_count = 0LLU; // dcc.first_missed_coin_serial = UINT64_MAX; - qsx = TALER_ARL_adb->get_deposit_confirmations ( TALER_ARL_adb->cls, INT64_MAX, @@ -336,22 +315,18 @@ db_notify (void *cls, const void *extra, size_t extra_size) { - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Received notification for new deposit_confirmation\n"); - (void) cls; (void) extra; (void) extra_size; - - GNUNET_assert (NULL != - (report_deposit_confirmation_inconsistencies = json_array ())); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Received notification for new deposit_confirmation\n"); if (GNUNET_OK != TALER_ARL_setup_sessions_and_run (&analyze_deposit_confirmations, NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audit failed\n"); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } @@ -365,15 +340,12 @@ static void do_shutdown (void *cls) { (void) cls; - - if (test_mode != 1) + if (NULL != eh) { - db_plugin->event_listen_cancel (eh); + TALER_ARL_adb->event_listen_cancel (eh); eh = NULL; - TALER_AUDITORDB_plugin_unload (db_plugin); - db_plugin = NULL; - TALER_ARL_done (NULL); } + TALER_ARL_done (); } @@ -407,71 +379,31 @@ run (void *cls, return; } - 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; - } - if (test_mode != 1) { - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running helper indefinitely\n"); - - struct GNUNET_DB_EventHeaderP es = { .size = htons (sizeof (es)), .type = htons (TALER_DBEVENT_EXCHANGE_AUDITOR_WAKE_HELPER_DEPOSITS) }; - eh = db_plugin->event_listen (db_plugin->cls, - &es, - GNUNET_TIME_UNIT_FOREVER_REL, - &db_notify, - NULL); - return; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Running helper indefinitely\n"); + eh = TALER_ARL_adb->event_listen (TALER_ARL_adb->cls, + &es, + GNUNET_TIME_UNIT_FOREVER_REL, + &db_notify, + NULL); } - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running helper in test mode\n"); - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting audit\n"); - GNUNET_assert (NULL != - (report_deposit_confirmation_inconsistencies = json_array ())); if (GNUNET_OK != TALER_ARL_setup_sessions_and_run (&analyze_deposit_confirmations, NULL)) { + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Deposit audit complete\n"); - TALER_ARL_done ( - GNUNET_JSON_PACK ( - GNUNET_JSON_pack_array_steal ("deposit_confirmation_inconsistencies", - report_deposit_confirmation_inconsistencies) - , - GNUNET_JSON_pack_uint64 ("missing_deposit_confirmation_count", - number_missed_deposit_confirmations), - TALER_JSON_pack_amount ("missing_deposit_confirmation_total", - &total_missed_deposit_confirmations), - TALER_JSON_pack_time_abs_human ("auditor_start_time", - start_time), - TALER_JSON_pack_time_abs_human ("auditor_end_time", - GNUNET_TIME_absolute_get ()))); } diff --git a/src/auditor/taler-helper-auditor-purses.c b/src/auditor/taler-helper-auditor-purses.c index 5152392ba..625dfb1a6 100644 --- a/src/auditor/taler-helper-auditor-purses.c +++ b/src/auditor/taler-helper-auditor-purses.c @@ -22,7 +22,6 @@ #include <gnunet/gnunet_util_lib.h> #include "taler_auditordb_plugin.h" #include "taler_exchangedb_lib.h" -#include "taler_json_lib.h" #include "taler_bank_service.h" #include "taler_signatures.h" #include "report-lib.h" @@ -42,8 +41,6 @@ static int global_ret; /** * Run in test mode. Exit when idle instead of * going to sleep and waiting for more work. - * - * FIXME: not yet implemented! */ static int test_mode; @@ -59,60 +56,34 @@ static TALER_ARL_DEF_PP (purse_open_counter); static TALER_ARL_DEF_AB (purse_global_balance); /** - * Array of reports about row inconsistencies. - */ -static json_t *report_row_inconsistencies; - -/** - * Array of reports about purse balance insufficient inconsistencies. - */ -static json_t *report_purse_balance_insufficient_inconsistencies; - -/** * Total amount purses were merged with insufficient balance. */ -static struct TALER_Amount total_balance_insufficient_loss; +static TALER_ARL_DEF_AB (purse_total_balance_insufficient_loss); /** * Total amount purse decisions are delayed past deadline. */ -static struct TALER_Amount total_delayed_decisions; - -/** - * Array of reports about purses's not being closed inconsistencies. - */ -static json_t *report_purse_not_closed_inconsistencies; +static TALER_ARL_DEF_AB (purse_total_delayed_decisions); /** * Total amount affected by purses not having been closed on time. */ -static struct TALER_Amount total_balance_purse_not_closed; - -/** - * Report about amount calculation differences (causing profit - * or loss at the exchange). - */ -static json_t *report_amount_arithmetic_inconsistencies; +static TALER_ARL_DEF_AB (purse_total_balance_purse_not_closed); /** * Profits the exchange made by bad amount calculations. */ -static struct TALER_Amount total_arithmetic_delta_plus; +static TALER_ARL_DEF_AB (purse_total_arithmetic_delta_plus); /** * Losses the exchange made by bad amount calculations. */ -static struct TALER_Amount total_arithmetic_delta_minus; - -/** - * Array of reports about coin operations with bad signatures. - */ -static json_t *report_bad_sig_losses; +static TALER_ARL_DEF_AB (purse_total_arithmetic_delta_minus); /** * Total amount lost by operations for which signatures were invalid. */ -static struct TALER_Amount total_bad_sig_loss; +static TALER_ARL_DEF_AB (purse_total_bad_sig_loss); /** * Should we run checks that only work for exchange-internal audits? @@ -122,11 +93,6 @@ 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; @@ -198,8 +164,8 @@ report_amount_arithmetic_inconsistency ( if (0 != profitable) { target = (1 == profitable) - ? &total_arithmetic_delta_plus - : &total_arithmetic_delta_minus; + ? &TALER_ARL_USE_AB (purse_total_arithmetic_delta_plus) + : &TALER_ARL_USE_AB (purse_total_arithmetic_delta_minus); TALER_ARL_amount_add (target, target, &delta); @@ -536,8 +502,8 @@ handle_purse_requested ( GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); // FIXME: error handling! } - TALER_ARL_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (purse_total_bad_sig_loss), + &TALER_ARL_USE_AB (purse_total_bad_sig_loss), target_amount); } GNUNET_CRYPTO_hash (purse_pub, @@ -623,8 +589,6 @@ handle_purse_deposits ( report_row_inconsistency ("purse-deposit", rowid, "denomination key not found"); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } TALER_ARL_amount_subtract (&amount_minus_fee, @@ -657,8 +621,8 @@ handle_purse_deposits ( GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); // FIXME: error handling! } - TALER_ARL_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (purse_total_bad_sig_loss), + &TALER_ARL_USE_AB (purse_total_bad_sig_loss), &deposit->amount); return GNUNET_OK; } @@ -761,8 +725,8 @@ handle_purse_merged ( GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); // FIXME: error handling! } - TALER_ARL_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (purse_total_bad_sig_loss), + &TALER_ARL_USE_AB (purse_total_bad_sig_loss), amount); return GNUNET_OK; } @@ -865,8 +829,8 @@ handle_account_merged ( GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); // FIXME: error handling! } - TALER_ARL_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (purse_total_bad_sig_loss), + &TALER_ARL_USE_AB (purse_total_bad_sig_loss), purse_fee); return GNUNET_OK; } @@ -981,8 +945,10 @@ handle_purse_decision ( &ps->total_value, &balance_without_purse_fee, 0); - TALER_ARL_amount_add (&total_balance_insufficient_loss, - &total_balance_insufficient_loss, + TALER_ARL_amount_add (&TALER_ARL_USE_AB ( + purse_total_balance_insufficient_loss), + &TALER_ARL_USE_AB ( + purse_total_balance_insufficient_loss), &ps->total_value); } } @@ -1042,8 +1008,8 @@ handle_purse_expired ( GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); // FIXME: error handling! } - TALER_ARL_amount_add (&total_delayed_decisions, - &total_delayed_decisions, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (purse_total_delayed_decisions), + &TALER_ARL_USE_AB (purse_total_delayed_decisions), balance); return GNUNET_OK; } @@ -1152,8 +1118,6 @@ analyze_purses (void *cls) enum GNUNET_DB_QueryStatus qsx; enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qsp; - char progress_exists = 1; - char balance_exists = 1; (void) cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1179,10 +1143,6 @@ analyze_purses (void *cls) } else { - if (TALER_ARL_USE_PP (purse_account_merge_serial_id) == 0) - { - progress_exists = 0; - } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Resuming purse audit at %llu/%llu/%llu/%llu/%llu\n", (unsigned long long) TALER_ARL_USE_PP ( @@ -1200,14 +1160,19 @@ analyze_purses (void *cls) qsx = TALER_ARL_adb->get_balance ( TALER_ARL_adb->cls, TALER_ARL_GET_AB (purse_global_balance), + TALER_ARL_GET_AB (purse_total_balance_insufficient_loss), + TALER_ARL_GET_AB (purse_total_delayed_decisions), + TALER_ARL_GET_AB (purse_total_balance_purse_not_closed), + TALER_ARL_GET_AB (purse_total_arithmetic_delta_plus), + TALER_ARL_GET_AB (purse_total_arithmetic_delta_minus), + TALER_ARL_GET_AB (purse_total_bad_sig_loss), NULL); if (qsx < 0) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); return qsx; } - if (GNUNET_NO == TALER_amount_is_valid (&TALER_ARL_USE_AB ( - purse_global_balance))) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Found no balance, starting by 0.\n"); @@ -1215,7 +1180,32 @@ analyze_purses (void *cls) TALER_amount_set_zero (TALER_ARL_currency, &TALER_ARL_USE_AB ( purse_global_balance))); - balance_exists = 0; + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + purse_total_balance_insufficient_loss))); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + purse_total_delayed_decisions))); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + purse_total_arithmetic_delta_plus))) + ; + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + purse_total_arithmetic_delta_minus)) + ); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + purse_total_balance_purse_not_closed))); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + purse_total_bad_sig_loss))); } pc.purses = GNUNET_CONTAINER_multihashmap_create (512, GNUNET_NO); @@ -1230,7 +1220,6 @@ analyze_purses (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - qs = TALER_ARL_edb->select_purse_merges_above_serial_id ( TALER_ARL_edb->cls, TALER_ARL_USE_PP (purse_merges_serial_id), @@ -1262,7 +1251,6 @@ analyze_purses (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - qs = TALER_ARL_edb->select_all_purse_decisions_above_serial_id ( TALER_ARL_edb->cls, TALER_ARL_USE_PP (purse_decision_serial_id), @@ -1273,7 +1261,6 @@ analyze_purses (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - qs = TALER_ARL_adb->select_purse_expired ( TALER_ARL_adb->cls, &handle_purse_expired, @@ -1292,27 +1279,43 @@ analyze_purses (void *cls) GNUNET_CONTAINER_multihashmap_destroy (pc.purses); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != pc.qs) return qs; - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx && balance_exists == 0) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) { qs = TALER_ARL_adb->insert_balance ( TALER_ARL_adb->cls, TALER_ARL_SET_AB (purse_global_balance), + TALER_ARL_SET_AB (purse_total_balance_insufficient_loss), + TALER_ARL_SET_AB (purse_total_delayed_decisions), + TALER_ARL_SET_AB (purse_total_balance_purse_not_closed), + TALER_ARL_SET_AB (purse_total_arithmetic_delta_plus), + TALER_ARL_SET_AB (purse_total_arithmetic_delta_minus), + TALER_ARL_SET_AB (purse_total_bad_sig_loss), NULL); } else { + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx); qs = TALER_ARL_adb->update_balance ( TALER_ARL_adb->cls, TALER_ARL_SET_AB (purse_global_balance), + TALER_ARL_SET_AB (purse_total_balance_insufficient_loss), + TALER_ARL_SET_AB (purse_total_delayed_decisions), + TALER_ARL_SET_AB (purse_total_balance_purse_not_closed), + TALER_ARL_SET_AB (purse_total_arithmetic_delta_plus), + TALER_ARL_SET_AB (purse_total_arithmetic_delta_minus), + TALER_ARL_SET_AB (purse_total_bad_sig_loss), NULL); } if (0 >= qs) { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Failed to update auditor DB, not recording progress\n"); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp && progress_exists == 1) - qs = TALER_ARL_adb->update_auditor_progress ( + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) + { + 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), @@ -1321,8 +1324,11 @@ analyze_purses (void *cls) TALER_ARL_SET_PP (purse_request_serial_id), TALER_ARL_SET_PP (purse_open_counter), NULL); + } else - qs = TALER_ARL_adb->insert_auditor_progress ( + { + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp); + 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), @@ -1331,6 +1337,7 @@ analyze_purses (void *cls) 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, @@ -1366,60 +1373,22 @@ db_notify (void *cls, const void *extra, size_t extra_size) { - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Received notification to wake purses\n"); - (void) cls; (void) extra; (void) extra_size; - 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 ())); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Received notification to wake purses\n"); if (GNUNET_OK != TALER_ARL_setup_sessions_and_run (&analyze_purses, NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audit failed\n"); - TALER_ARL_done (NULL); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; + return; } - } @@ -1431,14 +1400,12 @@ do_shutdown (void *cls) { (void) cls; - if (test_mode != 1) + if (NULL != eh) { - db_plugin->event_listen_cancel (eh); + TALER_ARL_adb->event_listen_cancel (eh); eh = NULL; - TALER_AUDITORDB_plugin_unload (db_plugin); - db_plugin = NULL; - TALER_ARL_done (NULL); } + TALER_ARL_done (); } @@ -1461,162 +1428,43 @@ run (void *cls, (void) cfgfile; cfg = c; - GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Launching purses auditor\n"); - if (GNUNET_OK != TALER_ARL_init (c)) { global_ret = EXIT_FAILURE; return; } - - 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; - } - if (test_mode != 1) { - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running helper indefinitely\n"); - 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); - return; - } - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running helper in test mode\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Running helper indefinitely\n"); + eh = TALER_ARL_adb->event_listen (TALER_ARL_adb->cls, + &es, + GNUNET_TIME_UNIT_FOREVER_REL, + &db_notify, + NULL); + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting audit\n"); - - 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)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audit failed\n"); - TALER_ARL_done (NULL); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Audit complete\n"); - - 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)))); } diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index 9b7caf698..9b0d46808 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c @@ -116,11 +116,6 @@ 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; @@ -500,8 +495,6 @@ handle_reserve_in (void *cls, TALER_ARL_amount_add (&rs->total_in, &rs->total_in, credit); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -562,8 +555,6 @@ handle_reserve_out (void *cls, report_row_inconsistency ("withdraw", rowid, "denomination key not found"); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -626,8 +617,6 @@ handle_reserve_out (void *cls, TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss), &TALER_ARL_USE_AB (reserves_total_bad_sig_loss), amount_with_fee); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; /* exit function here, we cannot add this to the legitimate withdrawals */ } @@ -665,8 +654,6 @@ handle_reserve_out (void *cls, TALER_ARL_amount_add (&rs->total_out, &rs->total_out, &auditor_amount_with_fee); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -834,8 +821,6 @@ handle_recoup_by_reserve ( idle_reserve_expiration_time)); rs->a_expiration_date = GNUNET_TIME_timestamp_max (rs->a_expiration_date, expiry); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -975,8 +960,6 @@ handle_reserve_open ( "Additional open operation for reserve `%s' of %s\n", TALER_B2S (reserve_pub), TALER_amount2s (reserve_payment)); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1167,8 +1150,6 @@ handle_reserve_closed ( "Additional closing operation for reserve `%s' of %s\n", TALER_B2S (reserve_pub), TALER_amount2s (amount_with_fee)); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1305,8 +1286,6 @@ purse_decision_cb (void *cls, TALER_ARL_amount_add (&rs->total_in, &rs->total_in, purse_value); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1698,8 +1677,6 @@ analyze_reserves (void *cls) enum GNUNET_DB_QueryStatus qsx; enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qsp; - char progress_exists = 1; - char balance_exists = 1; (void) cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1727,10 +1704,6 @@ analyze_reserves (void *cls) } else { - if (TALER_ARL_USE_PP (reserves_reserve_in_serial_id) == 0) - { - progress_exists = 0; - } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Resuming reserve audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu\n", (unsigned long long) TALER_ARL_USE_PP ( @@ -1771,15 +1744,68 @@ analyze_reserves (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); return qsx; } - if (GNUNET_NO == - TALER_amount_is_valid (&TALER_ARL_USE_AB ( - reserves_reserve_total_balance))) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) { GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, &TALER_ARL_USE_AB ( reserves_reserve_total_balance))); - balance_exists = 0; + 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, + &TALER_ARL_USE_AB ( + total_balance_summary_delta_plus))); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + total_balance_summary_delta_minus))) + ; + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + reserves_total_arithmetic_delta_plus)) + ); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + reserves_total_arithmetic_delta_minus) + )); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + total_balance_reserve_not_closed))); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &TALER_ARL_USE_AB ( + reserves_total_bad_sig_loss))); } rc.reserves = GNUNET_CONTAINER_multihashmap_create (512, GNUNET_NO); @@ -1869,8 +1895,7 @@ analyze_reserves (void *cls) GNUNET_CONTAINER_multihashmap_destroy (rc.revoked); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != rc.qs) return qs; - if ( (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) && - (! balance_exists) ) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) { qs = TALER_ARL_adb->insert_balance ( TALER_ARL_adb->cls, @@ -1887,14 +1912,10 @@ analyze_reserves (void *cls) TALER_ARL_SET_AB (reserves_total_arithmetic_delta_minus), TALER_ARL_SET_AB (total_balance_summary_delta_minus), NULL); - if (0 >= qs) - { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - return qs; - } } else { + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx); qs = TALER_ARL_adb->update_balance ( TALER_ARL_adb->cls, TALER_ARL_SET_AB (reserves_reserve_total_balance), @@ -1916,9 +1937,9 @@ analyze_reserves (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - if ( (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) && - progress_exists) - qs = TALER_ARL_adb->update_auditor_progress ( + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) + { + 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), @@ -1929,8 +1950,11 @@ analyze_reserves (void *cls) 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 ( + { + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp); + 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), @@ -1941,6 +1965,7 @@ analyze_reserves (void *cls) 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, @@ -1982,75 +2007,19 @@ db_notify (void *cls, const void *extra, size_t extra_size) { - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Received notification to wake reserves helper\n"); - (void) cls; (void) extra; (void) extra_size; - 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, - &TALER_ARL_USE_AB ( - total_balance_summary_delta_plus))); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - total_balance_summary_delta_minus))); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - reserves_total_arithmetic_delta_plus)) - ); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - reserves_total_arithmetic_delta_minus) - )); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - total_balance_reserve_not_closed))); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - reserves_total_bad_sig_loss))); - + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Received notification to wake reserves helper\n"); if (GNUNET_OK != TALER_ARL_setup_sessions_and_run (&analyze_reserves, NULL)) { + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; + return; } } @@ -2062,19 +2031,12 @@ static void do_shutdown (void *cls) { (void) cls; - - if (test_mode != 1) + if (NULL != eh) { - - db_plugin->event_listen_cancel (eh); + TALER_ARL_adb->event_listen_cancel (eh); eh = NULL; - TALER_AUDITORDB_plugin_unload (db_plugin); - db_plugin = NULL; - TALER_ARL_done (NULL); - } - - + TALER_ARL_done (); } @@ -2109,45 +2071,6 @@ run (void *cls, global_ret = EXIT_FAILURE; return; } - - 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; - } - - if (test_mode != 1) - { - - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running helper indefinitely\n"); - - 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); - return; - } - - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running helper in test mode\n"); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (TALER_ARL_cfg, "exchangedb", @@ -2157,80 +2080,37 @@ run (void *cls, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchangedb", "IDLE_RESERVE_EXPIRATION_TIME"); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } + if (test_mode != 1) + { + struct GNUNET_DB_EventHeaderP es = { + .size = htons (sizeof (es)), + .type = htons (TALER_DBEVENT_EXCHANGE_AUDITOR_WAKE_HELPER_RESERVES) + }; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Running helper indefinitely\n"); + eh = TALER_ARL_adb->event_listen (TALER_ARL_adb->cls, + &es, + GNUNET_TIME_UNIT_FOREVER_REL, + &db_notify, + NULL); + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting audit\n"); - 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, - &TALER_ARL_USE_AB ( - total_balance_summary_delta_plus))); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - total_balance_summary_delta_minus))); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - reserves_total_arithmetic_delta_plus)) - ); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - reserves_total_arithmetic_delta_minus) - )); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - total_balance_reserve_not_closed))); - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (TALER_ARL_currency, - &TALER_ARL_USE_AB ( - reserves_total_bad_sig_loss))); - if (GNUNET_OK != TALER_ARL_setup_sessions_and_run (&analyze_reserves, NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audit failed\n"); - TALER_ARL_done (NULL); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Audit complete\n"); } diff --git a/src/auditor/taler-helper-auditor-wire-credit.c b/src/auditor/taler-helper-auditor-wire-credit.c index 0baaa23d2..9c0233045 100644 --- a/src/auditor/taler-helper-auditor-wire-credit.c +++ b/src/auditor/taler-helper-auditor-wire-credit.c @@ -52,8 +52,6 @@ /** * Run in test mode. Exit when idle instead of * going to sleep and waiting for more work. - * - * FIXME: not yet implemented! */ static int test_mode; @@ -218,11 +216,6 @@ 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; @@ -294,15 +287,10 @@ do_shutdown (void *cls) (void) cls; if (NULL != eh) { - db_plugin->event_listen_cancel (eh); + TALER_ARL_adb->event_listen_cancel (eh); eh = NULL; } - if (NULL != db_plugin) - { - TALER_AUDITORDB_plugin_unload (db_plugin); - db_plugin = NULL; - } - TALER_ARL_done (NULL); + TALER_ARL_done (); if (NULL != in_map) { GNUNET_CONTAINER_multihashmap_iterate (in_map, @@ -526,13 +514,9 @@ reserve_in_cb (void *cls, GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return GNUNET_SYSERR; } - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } wa->last_reserve_in_serial_id = rowid + 1; - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1130,24 +1114,6 @@ run (void *cls, global_ret = EXIT_FAILURE; return; } - - 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; - } - if (GNUNET_OK != TALER_config_get_amount (TALER_ARL_cfg, "auditor", @@ -1197,17 +1163,18 @@ run (void *cls, TALER_EXCHANGEDB_find_accounts (&process_account_cb, NULL); + if (0 == test_mode) { 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); + eh = TALER_ARL_adb->event_listen (TALER_ARL_adb->cls, + &es, + GNUNET_TIME_UNIT_FOREVER_REL, + &db_notify, + NULL); GNUNET_assert (NULL != eh); } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != diff --git a/src/auditor/taler-helper-auditor-wire-debit.c b/src/auditor/taler-helper-auditor-wire-debit.c index c01befc47..56ee9e5cd 100644 --- a/src/auditor/taler-helper-auditor-wire-debit.c +++ b/src/auditor/taler-helper-auditor-wire-debit.c @@ -56,8 +56,6 @@ /** * Run in test mode. Exit when idle instead of * going to sleep and waiting for more work. - * - * FIXME: not yet implemented! */ static int test_mode; @@ -279,11 +277,6 @@ 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; @@ -373,15 +366,10 @@ do_shutdown (void *cls) (void) cls; if (NULL != eh) { - db_plugin->event_listen_cancel (eh); + TALER_ARL_adb->event_listen_cancel (eh); eh = NULL; } - if (NULL != db_plugin) - { - TALER_AUDITORDB_plugin_unload (db_plugin); - db_plugin = NULL; - } - TALER_ARL_done (NULL); + TALER_ARL_done (); if (NULL != reserve_closures) { GNUNET_CONTAINER_multihashmap_iterate (reserve_closures, @@ -1135,8 +1123,6 @@ wire_out_cb (void *cls, TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_bad_amount_out_minus), &TALER_ARL_USE_AB (total_bad_amount_out_minus), amount); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } if (0 != strcasecmp (payto_uri, @@ -1230,8 +1216,6 @@ wire_out_cb (void *cls, &key, roi)); wa->last_wire_out_serial_id = rowid + 1; - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return ret; } @@ -1754,8 +1738,6 @@ reserve_closed_cb (void *cls, return GNUNET_OK; } GNUNET_free (rc); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } TALER_ARL_USE_PP (wire_reserve_close_id) @@ -1772,8 +1754,6 @@ reserve_closed_cb (void *cls, &key, rc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); - if (TALER_ARL_do_abort ()) - return GNUNET_SYSERR; return GNUNET_OK; } @@ -1998,6 +1978,7 @@ db_notify (void *cls, GNUNET_break (0); global_ret = EXIT_FAILURE; GNUNET_SCHEDULER_shutdown (); + return; } } @@ -2032,23 +2013,6 @@ run (void *cls, reserve_closures = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO); - 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; - } - if (GNUNET_OK != TALER_config_get_amount (TALER_ARL_cfg, "auditor", @@ -2108,17 +2072,18 @@ run (void *cls, TALER_EXCHANGEDB_find_accounts (&process_account_cb, NULL); + if (0 == test_mode) { 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); + eh = TALER_ARL_adb->event_listen (TALER_ARL_adb->cls, + &es, + GNUNET_TIME_UNIT_FOREVER_REL, + &db_notify, + NULL); GNUNET_assert (NULL != eh); } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != |