diff options
author | Nic Eigel <nic@eigel.ch> | 2024-09-17 01:09:52 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-09-17 13:12:02 +0200 |
commit | 85ec9879b3b6814ad07049392189b06bc458ece7 (patch) | |
tree | 90e85a5fa36e22ea885f2a18ca0018804ebbfac1 | |
parent | c73cc663be6f7d6b2e93bbb72683b87bf2369261 (diff) |
adding generic delete for auditor
-rw-r--r-- | src/auditor/taler-auditor-httpd.c | 25 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_delete_generic.c | 113 | ||||
-rw-r--r-- | src/auditordb/pg_update_generic_suppressed.c | 2 | ||||
-rw-r--r-- | src/auditordb/plugin_auditordb_postgres.c | 65 |
4 files changed, 57 insertions, 148 deletions
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index 9dadf7f9e..b681543cb 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -32,42 +32,29 @@ #include "taler_exchangedb_lib.h" #include "taler-auditor-httpd_spa.h" #include "taler-auditor-httpd_deposit-confirmation.h" -#include "taler-auditor-httpd_deposit-confirmation-del.h" #include "taler-auditor-httpd_deposit-confirmation-get.h" #include "taler-auditor-httpd_amount-arithmetic-inconsistency-get.h" -#include "taler-auditor-httpd_amount-arithmetic-inconsistency-del.h" #include "taler-auditor-httpd_amount-arithmetic-inconsistency-upd.h" #include "taler-auditor-httpd_coin-inconsistency-get.h" -#include "taler-auditor-httpd_coin-inconsistency-del.h" #include "taler-auditor-httpd_row-inconsistency-get.h" -#include "taler-auditor-httpd_row-inconsistency-del.h" #include "taler-auditor-httpd_emergency-get.h" -#include "taler-auditor-httpd_emergency-del.h" #include "taler-auditor-httpd_emergency-by-count-get.h" -#include "taler-auditor-httpd_emergency-by-count-del.h" #include \ "taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.h" -#include \ - "taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-del.h" #include "taler-auditor-httpd_purse-not-closed-inconsistencies-get.h" -#include "taler-auditor-httpd_purse-not-closed-inconsistencies-del.h" #include "taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.h" -#include "taler-auditor-httpd_reserve-balance-insufficient-inconsistency-del.h" #include "taler-auditor-httpd_bad-sig-losses-get.h" -#include "taler-auditor-httpd_bad-sig-losses-del.h" #include "taler-auditor-httpd_bad-sig-losses-upd.h" #include "taler-auditor-httpd_closure-lags-get.h" -#include "taler-auditor-httpd_closure-lags-del.h" #include "taler-auditor-httpd_refreshes-hanging-get.h" -#include "taler-auditor-httpd_refreshes-hanging-del.h" #include "taler-auditor-httpd_mhd.h" #include "taler-auditor-httpd.h" @@ -86,19 +73,15 @@ #include "taler-auditor-httpd_closure-lags-upd.h" #include "taler-auditor-httpd_row-minor-inconsistencies-upd.h" -#include "taler-auditor-httpd_reserve-in-inconsistency-del.h" #include "taler-auditor-httpd_reserve-in-inconsistency-get.h" #include "taler-auditor-httpd_reserve-in-inconsistency-upd.h" -#include "taler-auditor-httpd_reserve-not-closed-inconsistency-del.h" #include "taler-auditor-httpd_reserve-not-closed-inconsistency-get.h" #include "taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h" -#include "taler-auditor-httpd_denominations-without-sigs-del.h" #include "taler-auditor-httpd_denominations-without-sigs-get.h" #include "taler-auditor-httpd_denominations-without-sigs-upd.h" -#include "taler-auditor-httpd_misattribution-in-inconsistency-del.h" #include "taler-auditor-httpd_misattribution-in-inconsistency-get.h" #include "taler-auditor-httpd_misattribution-in-inconsistency-upd.h" @@ -108,27 +91,21 @@ #include "taler-auditor-httpd_historic-denomination-revenue-get.h" #include "taler-auditor-httpd_historic-reserve-summary-get.h" -#include "taler-auditor-httpd_denomination-pending-del.h" #include "taler-auditor-httpd_denomination-pending-get.h" #include "taler-auditor-httpd_denomination-pending-upd.h" -#include "taler-auditor-httpd_wire-format-inconsistency-del.h" #include "taler-auditor-httpd_wire-format-inconsistency-get.h" #include "taler-auditor-httpd_wire-format-inconsistency-upd.h" -#include "taler-auditor-httpd_wire-out-inconsistency-del.h" #include "taler-auditor-httpd_wire-out-inconsistency-get.h" #include "taler-auditor-httpd_wire-out-inconsistency-upd.h" -#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.h" #include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h" #include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h" -#include "taler-auditor-httpd_row-minor-inconsistencies-del.h" #include "taler-auditor-httpd_row-minor-inconsistencies-get.h" #include "taler-auditor-httpd_row-minor-inconsistencies-upd.h" -#include "taler-auditor-httpd_fee-time-inconsistency-del.h" #include "taler-auditor-httpd_fee-time-inconsistency-get.h" #include "taler-auditor-httpd_fee-time-inconsistency-upd.h" @@ -441,7 +418,7 @@ handle_mhd_request (void *cls, &TAH_patch_handler_generic_suppressed, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_AMOUNT_ARITHMETIC_INCONSISTENCY_SUPPRESS + .table = TALER_AUDITORDB_AMOUNT_ARITHMETIC_INCONSISTENCY }, { "/monitoring/coin-inconsistency", MHD_HTTP_METHOD_GET, "application/json", diff --git a/src/auditor/taler-auditor-httpd_delete_generic.c b/src/auditor/taler-auditor-httpd_delete_generic.c index f10daf328..2f2775cd1 100644 --- a/src/auditor/taler-auditor-httpd_delete_generic.c +++ b/src/auditor/taler-auditor-httpd_delete_generic.c @@ -33,67 +33,64 @@ TAH_delete_handler_generic ( void **connection_cls, const char *upload_data, size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - unsigned long long row_id; + const char *const args[]) { + enum GNUNET_DB_QueryStatus qs; + unsigned long long row_id; - (void) connection_cls; - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } + (void) connection_cls; + if (GNUNET_SYSERR == + TAH_plugin->preflight(TAH_plugin->cls)) { + GNUNET_break(0); + return TALER_MHD_reply_with_error(connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } - if ( (NULL == args[1]) || - (1 != sscanf (args[1], + if ((NULL == args[1]) || + (1 != sscanf(args[1], "%llu", - &row_id)) ) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - } + &row_id))) { + GNUNET_break_op(0); + return TALER_MHD_reply_with_error(connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, + "no row id specified"); + } - { + { - /* execute transaction */ - qs = TAH_plugin->delete_generic (TAH_plugin->cls, - rh->table, - row_id); + /* execute transaction */ + qs = TAH_plugin->delete_generic(TAH_plugin->cls, + rh->table, + row_id); - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "db store failed"); - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no delete executed"); - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - return TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - } - GNUNET_break (0); - return MHD_NO; -} + switch (qs) { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break(0); + return TALER_MHD_reply_with_error(connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "db store failed"); + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break(0); + return TALER_MHD_reply_with_error(connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error(connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, + "no delete executed"); + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + return TALER_MHD_reply_static(connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + } + GNUNET_break(0); + return MHD_NO; + } +}
\ No newline at end of file diff --git a/src/auditordb/pg_update_generic_suppressed.c b/src/auditordb/pg_update_generic_suppressed.c index de17fc397..e92f27cfd 100644 --- a/src/auditordb/pg_update_generic_suppressed.c +++ b/src/auditordb/pg_update_generic_suppressed.c @@ -36,7 +36,7 @@ struct Preparations enum GNUNET_DB_QueryStatus TAH_PG_update_generic_suppressed ( void *cls, - enum TALER_AUDITORDB_SuppressableTables table, + enum TALER_AUDITORDB_DeletableSuppressableTables table, uint64_t row_id, bool suppressed) { diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 6af19c9f1..3e585af0d 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -75,71 +75,53 @@ #include "pg_update_balance.h" -#include "pg_del_amount_arithmetic_inconsistency.h" -#include "pg_del_coin_inconsistency.h" -#include "pg_del_row_inconsistency.h" #include "pg_insert_coin_inconsistency.h" #include "pg_insert_row_inconsistency.h" #include "pg_insert_amount_arithmetic_inconsistency.h" #include "pg_get_auditor_closure_lags.h" -#include "pg_del_auditor_closure_lags.h" #include "pg_insert_auditor_closure_lags.h" #include "pg_get_emergency_by_count.h" -#include "pg_del_emergency_by_count.h" #include "pg_insert_emergency_by_count.h" #include "pg_get_emergency.h" -#include "pg_del_emergency.h" #include "pg_insert_emergency.h" -#include "pg_del_auditor_progress.h" - #include "pg_get_bad_sig_losses.h" -#include "pg_del_bad_sig_losses.h" #include "pg_insert_bad_sig_losses.h" #include "pg_update_bad_sig_losses.h" #include "pg_get_denomination_key_validity_withdraw_inconsistency.h" -#include "pg_del_denomination_key_validity_withdraw_inconsistency.h" #include "pg_insert_denomination_key_validity_withdraw_inconsistency.h" #include "pg_get_fee_time_inconsistency.h" -#include "pg_del_fee_time_inconsistency.h" #include "pg_insert_fee_time_inconsistency.h" #include "pg_update_fee_time_inconsistency.h" #include "pg_get_purse_not_closed_inconsistencies.h" -#include "pg_del_purse_not_closed_inconsistencies.h" #include "pg_insert_purse_not_closed_inconsistencies.h" #include "pg_get_refreshes_hanging.h" -#include "pg_del_refreshes_hanging.h" #include "pg_insert_refreshes_hanging.h" #include "pg_get_reserve_balance_insufficient_inconsistency.h" -#include "pg_del_reserve_balance_insufficient_inconsistency.h" #include "pg_insert_reserve_balance_insufficient_inconsistency.h" #include "pg_get_reserve_in_inconsistency.h" -#include "pg_del_reserve_in_inconsistency.h" #include "pg_insert_reserve_in_inconsistency.h" #include "pg_update_reserve_in_inconsistency.h" #include "pg_get_reserve_not_closed_inconsistency.h" -#include "pg_del_reserve_not_closed_inconsistency.h" #include "pg_insert_reserve_not_closed_inconsistency.h" #include "pg_update_reserve_not_closed_inconsistency.h" #include "pg_get_denominations_without_sigs.h" -#include "pg_del_denominations_without_sigs.h" #include "pg_insert_denominations_without_sigs.h" #include "pg_update_denominations_without_sigs.h" #include "pg_get_misattribution_in_inconsistency.h" -#include "pg_del_misattribution_in_inconsistency.h" #include "pg_insert_misattribution_in_inconsistency.h" #include "pg_update_misattribution_in_inconsistency.h" @@ -147,30 +129,25 @@ #include "pg_get_purses.h" #include "pg_get_denomination_pending.h" -#include "pg_del_denomination_pending.h" #include "pg_insert_denomination_pending.h" #include "pg_update_denomination_pending.h" #include "pg_get_exchange_signkeys.h" #include "pg_get_wire_format_inconsistency.h" -#include "pg_del_wire_format_inconsistency.h" #include "pg_insert_wire_format_inconsistency.h" #include "pg_update_wire_format_inconsistency.h" #include "pg_get_wire_out_inconsistency.h" -#include "pg_del_wire_out_inconsistency.h" #include "pg_insert_wire_out_inconsistency.h" #include "pg_delete_wire_out_inconsistency_if_matching.h" #include "pg_update_wire_out_inconsistency.h" #include "pg_get_reserve_balance_summary_wrong_inconsistency.h" -#include "pg_del_reserve_balance_summary_wrong_inconsistency.h" #include "pg_insert_reserve_balance_summary_wrong_inconsistency.h" #include "pg_update_reserve_balance_summary_wrong_inconsistency.h" #include "pg_get_row_minor_inconsistencies.h" -#include "pg_del_row_minor_inconsistencies.h" #include "pg_insert_row_minor_inconsistencies.h" #include "pg_update_row_minor_inconsistencies.h" @@ -622,14 +599,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) = &TAH_PG_get_row_inconsistency; - plugin->delete_row_inconsistency - = &TAH_PG_del_row_inconsistency; - plugin->delete_coin_inconsistency - = &TAH_PG_del_coin_inconsistency; - plugin->delete_amount_arithmetic_inconsistency - = &TAH_PG_del_amount_arithmetic_inconsistency; - - plugin->insert_amount_arithmetic_inconsistency = &TAH_PG_insert_amount_arithmetic_inconsistency; plugin->insert_coin_inconsistency @@ -685,51 +654,37 @@ libtaler_plugin_auditordb_postgres_init (void *cls) = &TAH_PG_select_historic_reserve_revenue; - plugin->delete_emergency = &TAH_PG_del_emergency; plugin->insert_emergency = &TAH_PG_insert_emergency; plugin->get_emergency = &TAH_PG_get_emergency; - plugin->delete_emergency_by_count = &TAH_PG_del_emergency_by_count; plugin->insert_emergency_by_count = &TAH_PG_insert_emergency_by_count; plugin->get_emergency_by_count = &TAH_PG_get_emergency_by_count; - plugin->delete_denomination_key_validity_withdraw_inconsistency = - &TAH_PG_del_denomination_key_validity_withdraw_inconsistency; plugin->insert_denomination_key_validity_withdraw_inconsistency = &TAH_PG_insert_denomination_key_validity_withdraw_inconsistency; plugin->get_denomination_key_validity_withdraw_inconsistency = &TAH_PG_get_denomination_key_validity_withdraw_inconsistency; - plugin->delete_purse_not_closed_inconsistencies = - &TAH_PG_del_purse_not_closed_inconsistencies; plugin->insert_purse_not_closed_inconsistencies = &TAH_PG_insert_purse_not_closed_inconsistencies; plugin->get_purse_not_closed_inconsistencies = &TAH_PG_get_purse_not_closed_inconsistencies; - plugin->delete_reserve_balance_insufficient_inconsistency = - &TAH_PG_del_reserve_balance_insufficient_inconsistency; plugin->insert_reserve_balance_insufficient_inconsistency = &TAH_PG_insert_reserve_balance_insufficient_inconsistency; plugin->get_reserve_balance_insufficient_inconsistency = &TAH_PG_get_reserve_balance_insufficient_inconsistency; - plugin->delete_bad_sig_losses = &TAH_PG_del_bad_sig_losses; plugin->insert_bad_sig_losses = &TAH_PG_insert_bad_sig_losses; plugin->get_bad_sig_losses = &TAH_PG_get_bad_sig_losses; plugin->update_bad_sig_losses = &TAH_PG_update_bad_sig_losses; - plugin->delete_auditor_closure_lags = &TAH_PG_del_auditor_closure_lags; plugin->insert_auditor_closure_lags = &TAH_PG_insert_auditor_closure_lags; plugin->get_auditor_closure_lags = &TAH_PG_get_auditor_closure_lags; - plugin->delete_progress = &TAH_PG_del_progress; - - - plugin->delete_refreshes_hanging = &TAH_PG_del_refreshes_hanging; plugin->insert_refreshes_hanging = &TAH_PG_insert_refreshes_hanging; plugin->get_refreshes_hanging = &TAH_PG_get_refreshes_hanging; @@ -747,8 +702,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->update_closure_lags = &TAH_PG_update_closure_lags; - plugin->delete_reserve_in_inconsistency = - &TAH_PG_del_reserve_in_inconsistency; plugin->insert_reserve_in_inconsistency = &TAH_PG_insert_reserve_in_inconsistency; plugin->get_reserve_in_inconsistency = &TAH_PG_get_reserve_in_inconsistency; @@ -756,8 +709,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) &TAH_PG_update_reserve_in_inconsistency; - plugin->delete_reserve_not_closed_inconsistency = - &TAH_PG_del_reserve_not_closed_inconsistency; plugin->insert_reserve_not_closed_inconsistency = &TAH_PG_insert_reserve_not_closed_inconsistency; plugin->get_reserve_not_closed_inconsistency = @@ -766,8 +717,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) &TAH_PG_update_reserve_not_closed_inconsistency; - plugin->delete_denominations_without_sigs = - &TAH_PG_del_denominations_without_sigs; plugin->insert_denominations_without_sigs = &TAH_PG_insert_denominations_without_sigs; plugin->get_denominations_without_sigs = @@ -779,8 +728,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) = &TAH_PG_get_progress_points; - plugin->delete_misattribution_in_inconsistency = - &TAH_PG_del_misattribution_in_inconsistency; plugin->insert_misattribution_in_inconsistency = &TAH_PG_insert_misattribution_in_inconsistency; plugin->get_misattribution_in_inconsistency = @@ -791,15 +738,12 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->get_reserves = &TAH_PG_get_reserves; plugin->get_purses = &TAH_PG_get_purses; - plugin->delete_denomination_pending = &TAH_PG_del_denomination_pending; plugin->insert_denomination_pending = &TAH_PG_insert_denomination_pending; plugin->get_denomination_pending = &TAH_PG_get_denomination_pending; plugin->update_denomination_pending = &TAH_PG_update_denomination_pending; plugin->get_exchange_signkeys = &TAH_PG_get_exchange_signkeys; - plugin->delete_wire_format_inconsistency = - &TAH_PG_del_wire_format_inconsistency; plugin->insert_wire_format_inconsistency = &TAH_PG_insert_wire_format_inconsistency; plugin->get_wire_format_inconsistency = &TAH_PG_get_wire_format_inconsistency; @@ -807,19 +751,13 @@ libtaler_plugin_auditordb_postgres_init (void *cls) &TAH_PG_update_wire_format_inconsistency; - plugin->delete_wire_out_inconsistency - = &TAH_PG_del_wire_out_inconsistency; plugin->insert_wire_out_inconsistency = &TAH_PG_insert_wire_out_inconsistency; - plugin->delete_wire_out_inconsistency_if_matching - = &TAH_PG_delete_wire_out_inconsistency_if_matching; plugin->get_wire_out_inconsistency = &TAH_PG_get_wire_out_inconsistency; plugin->update_wire_out_inconsistency = &TAH_PG_update_wire_out_inconsistency; - plugin->delete_reserve_balance_summary_wrong_inconsistency = - &TAH_PG_del_reserve_balance_summary_wrong_inconsistency; plugin->insert_reserve_balance_summary_wrong_inconsistency = &TAH_PG_insert_reserve_balance_summary_wrong_inconsistency; plugin->get_reserve_balance_summary_wrong_inconsistency = @@ -828,15 +766,12 @@ libtaler_plugin_auditordb_postgres_init (void *cls) &TAH_PG_update_reserve_balance_summary_wrong_inconsistency; - plugin->delete_row_minor_inconsistencies = - &TAH_PG_del_row_minor_inconsistencies; plugin->insert_row_minor_inconsistencies = &TAH_PG_insert_row_minor_inconsistencies; plugin->get_row_minor_inconsistencies = &TAH_PG_get_row_minor_inconsistencies; plugin->update_row_minor_inconsistencies = &TAH_PG_update_row_minor_inconsistencies; - plugin->delete_fee_time_inconsistency = &TAH_PG_del_fee_time_inconsistency; plugin->insert_fee_time_inconsistency = &TAH_PG_insert_fee_time_inconsistency; plugin->get_fee_time_inconsistency = &TAH_PG_get_fee_time_inconsistency; plugin->update_fee_time_inconsistency = &TAH_PG_update_fee_time_inconsistency; |