diff options
Diffstat (limited to 'src/auditordb')
159 files changed, 8760 insertions, 138 deletions
diff --git a/src/auditordb/0002-auditor_bad_sig_losses.sql b/src/auditordb/0002-auditor_bad_sig_losses.sql index e4e87f398..803f25124 100644 --- a/src/auditordb/0002-auditor_bad_sig_losses.sql +++ b/src/auditordb/0002-auditor_bad_sig_losses.sql @@ -18,7 +18,7 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_bad_sig_losses
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- operation VARCHAR(64),
+ operation TEXT,
loss taler_amount,
operation_specific_pub BYTEA NOT NULL CHECK (LENGTH(operation_specific_pub)=32),
suppressed BOOLEAN NOT NULL DEFAULT FALSE
diff --git a/src/auditordb/0002-auditor_row_inconsistency.sql b/src/auditordb/0002-auditor_row_inconsistency.sql index 20bf9fd7d..0b1d74a85 100644 --- a/src/auditordb/0002-auditor_row_inconsistency.sql +++ b/src/auditordb/0002-auditor_row_inconsistency.sql @@ -18,8 +18,8 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_row_inconsistency
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- row_table VARCHAR(64),
- diagnostic VARCHAR(64),
+ row_table TEXT,
+ diagnostic TEXT,
suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_row_inconsistency
diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am index 79cb8ae36..0dc499d35 100644 --- a/src/auditordb/Makefile.am +++ b/src/auditordb/Makefile.am @@ -126,6 +126,72 @@ pg_get_auditor_closure_lags.c pg_get_auditor_closure_lags.h \ pg_del_refreshes_hanging.c pg_del_refreshes_hanging.h \ pg_insert_refreshes_hanging.c pg_insert_refreshes_hanging.h \ pg_get_refreshes_hanging.c pg_get_refreshes_hanging.h \ +pg_update_emergency_by_count.c pg_update_emergency_by_count.h \ +pg_update_row_inconsistency.c pg_update_row_inconsistency.h \ +pg_update_purse_not_closed_inconsistencies.c pg_update_purse_not_closed_inconsistencies.h \ +pg_update_reserve_balance_insufficient_inconsistency.c pg_update_reserve_balance_insufficient_inconsistency.h \ +pg_update_coin_inconsistency.c pg_update_coin_inconsistency.h \ +pg_update_progress.c pg_update_progress.h \ +pg_update_denomination_key_validity_withdraw_inconsistency.c pg_update_denomination_key_validity_withdraw_inconsistency.h \ +pg_update_refreshes_hanging.c pg_update_refreshes_hanging.h \ +pg_update_emergency.c pg_update_emergency.h \ +pg_update_closure_lags.c pg_update_closure_lags.h \ +pg_get_reserve_in_inconsistency.c pg_get_reserve_in_inconsistency.h \ +pg_del_reserve_in_inconsistency.c pg_del_reserve_in_inconsistency.h \ +pg_insert_reserve_in_inconsistency.c pg_insert_reserve_in_inconsistency.h \ +pg_update_reserve_in_inconsistency.c pg_update_reserve_in_inconsistency.h \ +pg_get_reserve_not_closed_inconsistency.c pg_get_reserve_not_closed_inconsistency.h \ +pg_del_reserve_not_closed_inconsistency.c pg_del_reserve_not_closed_inconsistency.h \ +pg_insert_reserve_not_closed_inconsistency.c pg_insert_reserve_not_closed_inconsistency.h \ +pg_update_reserve_not_closed_inconsistency.c pg_update_reserve_not_closed_inconsistency.h \ +pg_get_denominations_without_sigs.c pg_get_denominations_without_sigs.h \ +pg_del_denominations_without_sigs.c pg_del_denominations_without_sigs.h \ +pg_insert_denominations_without_sigs.c pg_insert_denominations_without_sigs.h \ +pg_update_denominations_without_sigs.c pg_update_denominations_without_sigs.h \ +pg_get_misattribution_in_inconsistency.c pg_get_misattribution_in_inconsistency.h \ +pg_del_misattribution_in_inconsistency.c pg_del_misattribution_in_inconsistency.h \ +pg_insert_misattribution_in_inconsistency.c pg_insert_misattribution_in_inconsistency.h \ +pg_update_misattribution_in_inconsistency.c pg_update_misattribution_in_inconsistency.h \ +pg_get_reserves.c pg_get_reserves.h \ +pg_del_reserves.c pg_del_reserves.h \ +pg_insert_reserves.c pg_insert_reserves.h \ +pg_update_reserves.c pg_update_reserves.h \ +pg_get_purses.c pg_get_purses.h \ +pg_del_purses.c pg_del_purses.h \ +pg_insert_purses.c pg_insert_purses.h \ +pg_update_purses.c pg_update_purses.h \ +pg_get_historic_denomination_revenue.c pg_get_historic_denomination_revenue.h \ +pg_del_historic_denomination_revenue.c pg_del_historic_denomination_revenue.h \ +pg_insert_historic_denomination_revenue.c pg_insert_historic_denomination_revenue.h \ +pg_update_historic_denomination_revenue.c pg_update_historic_denomination_revenue.h \ +pg_get_denomination_pending.c pg_get_denomination_pending.h \ +pg_del_denomination_pending.c pg_del_denomination_pending.h \ +pg_insert_denomination_pending.c pg_insert_denomination_pending.h \ +pg_update_denomination_pending.c pg_update_denomination_pending.h \ +pg_get_historic_reserve_summary.c pg_get_historic_reserve_summary.h \ +pg_del_historic_reserve_summary.c pg_del_historic_reserve_summary.h \ +pg_insert_historic_reserve_summary.c pg_insert_historic_reserve_summary.h \ +pg_update_historic_reserve_summary.c pg_update_historic_reserve_summary.h \ +pg_get_exchange_signkeys.c pg_get_exchange_signkeys.h \ +pg_del_exchange_signkeys.c pg_del_exchange_signkeys.h \ +pg_insert_exchange_signkeys.c pg_insert_exchange_signkeys.h \ +pg_update_exchange_signkeys.c pg_update_exchange_signkeys.h \ +pg_get_wire_format_inconsistency.c pg_get_wire_format_inconsistency.h \ +pg_del_wire_format_inconsistency.c pg_del_wire_format_inconsistency.h \ +pg_insert_wire_format_inconsistency.c pg_insert_wire_format_inconsistency.h \ +pg_update_wire_format_inconsistency.c pg_update_wire_format_inconsistency.h \ +pg_get_wire_out_inconsistency.c pg_get_wire_out_inconsistency.h \ +pg_del_wire_out_inconsistency.c pg_del_wire_out_inconsistency.h \ +pg_insert_wire_out_inconsistency.c pg_insert_wire_out_inconsistency.h \ +pg_update_wire_out_inconsistency.c pg_update_wire_out_inconsistency.h \ +pg_get_reserve_balance_summary_wrong_inconsistency.c pg_get_reserve_balance_summary_wrong_inconsistency.h \ +pg_del_reserve_balance_summary_wrong_inconsistency.c pg_del_reserve_balance_summary_wrong_inconsistency.h \ +pg_insert_reserve_balance_summary_wrong_inconsistency.c pg_insert_reserve_balance_summary_wrong_inconsistency.h \ +pg_update_reserve_balance_summary_wrong_inconsistency.c pg_update_reserve_balance_summary_wrong_inconsistency.h \ +pg_get_row_minor_inconsistencies.c pg_get_row_minor_inconsistencies.h \ +pg_del_row_minor_inconsistencies.c pg_del_row_minor_inconsistencies.h \ +pg_insert_row_minor_inconsistencies.c pg_insert_row_minor_inconsistencies.h \ +pg_update_row_minor_inconsistencies.c pg_update_row_minor_inconsistencies.h \ pg_del_auditor_progress.c pg_del_auditor_progress.h libtaler_plugin_auditordb_postgres_la_LDFLAGS = \ $(TALER_PLUGIN_LDFLAGS) diff --git a/src/auditordb/pg_del_denomination_pending.c b/src/auditordb/pg_del_denomination_pending.c new file mode 100644 index 000000000..7d9158ea9 --- /dev/null +++ b/src/auditordb/pg_del_denomination_pending.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_denomination_pending.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_denomination_pending ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_denomination_pending", + "DELETE" + " FROM auditor_denomination_pending" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_denomination_pending", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_denomination_pending.h b/src/auditordb/pg_del_denomination_pending.h new file mode 100644 index 000000000..62d1651c4 --- /dev/null +++ b/src/auditordb/pg_del_denomination_pending.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_DENOMINATION_PENDING_H +#define SRC_PG_DEL_DENOMINATION_PENDING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_denomination_pending ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_DENOMINATION_PENDING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_denominations_without_sigs.c b/src/auditordb/pg_del_denominations_without_sigs.c new file mode 100644 index 000000000..8d5214f98 --- /dev/null +++ b/src/auditordb/pg_del_denominations_without_sigs.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_denominations_without_sigs.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_denominations_without_sigs ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_denominations_without_sigs", + "DELETE" + " FROM auditor_denominations_without_sigs" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_denominations_without_sigs", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_denominations_without_sigs.h b/src/auditordb/pg_del_denominations_without_sigs.h new file mode 100644 index 000000000..2329d430b --- /dev/null +++ b/src/auditordb/pg_del_denominations_without_sigs.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_DENOMINATIONS_WITHOUT_SIGS_H +#define SRC_PG_DEL_DENOMINATIONS_WITHOUT_SIGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_denominations_without_sigs ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_DENOMINATIONS_WITHOUT_SIGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_exchange_signkeys.c b/src/auditordb/pg_del_exchange_signkeys.c new file mode 100644 index 000000000..0ae722c1d --- /dev/null +++ b/src/auditordb/pg_del_exchange_signkeys.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_exchange_signkeys.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_exchange_signkeys ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_exchange_signkeys", + "DELETE" + " FROM auditor_exchange_signkeys" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_exchange_signkeys", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_exchange_signkeys.h b/src/auditordb/pg_del_exchange_signkeys.h new file mode 100644 index 000000000..d81fcb1d0 --- /dev/null +++ b/src/auditordb/pg_del_exchange_signkeys.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_EXCHANGE_SIGNKEYS_H +#define SRC_PG_DEL_EXCHANGE_SIGNKEYS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_exchange_signkeys ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_EXCHANGE_SIGNKEYS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_historic_denomination_revenue.c b/src/auditordb/pg_del_historic_denomination_revenue.c new file mode 100644 index 000000000..8376c1c4d --- /dev/null +++ b/src/auditordb/pg_del_historic_denomination_revenue.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_historic_denomination_revenue.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_historic_denomination_revenue ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_historic_denomination_revenue", + "DELETE" + " FROM auditor_historic_denomination_revenue" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_historic_denomination_revenue", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_historic_denomination_revenue.h b/src/auditordb/pg_del_historic_denomination_revenue.h new file mode 100644 index 000000000..6fa62c542 --- /dev/null +++ b/src/auditordb/pg_del_historic_denomination_revenue.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_HISTORIC_DENOMINATION_REVENUE_H +#define SRC_PG_DEL_HISTORIC_DENOMINATION_REVENUE_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_historic_denomination_revenue ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_HISTORIC_DENOMINATION_REVENUE_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_historic_reserve_summary.c b/src/auditordb/pg_del_historic_reserve_summary.c new file mode 100644 index 000000000..e6e99cc39 --- /dev/null +++ b/src/auditordb/pg_del_historic_reserve_summary.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_historic_reserve_summary.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_historic_reserve_summary ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_historic_reserve_summary", + "DELETE" + " FROM auditor_historic_reserve_summary" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_historic_reserve_summary", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_historic_reserve_summary.h b/src/auditordb/pg_del_historic_reserve_summary.h new file mode 100644 index 000000000..eeeacf2dc --- /dev/null +++ b/src/auditordb/pg_del_historic_reserve_summary.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_HISTORIC_RESERVE_SUMMARY_H +#define SRC_PG_DEL_HISTORIC_RESERVE_SUMMARY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_historic_reserve_summary ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_HISTORIC_RESERVE_SUMMARY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_misattribution_in_inconsistency.c b/src/auditordb/pg_del_misattribution_in_inconsistency.c new file mode 100644 index 000000000..052e3ff5a --- /dev/null +++ b/src/auditordb/pg_del_misattribution_in_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_misattribution_in_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_misattribution_in_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_misattribution_in_inconsistency", + "DELETE" + " FROM auditor_misattribution_in_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_misattribution_in_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_misattribution_in_inconsistency.h b/src/auditordb/pg_del_misattribution_in_inconsistency.h new file mode 100644 index 000000000..57cd551ea --- /dev/null +++ b/src/auditordb/pg_del_misattribution_in_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_MISATTRIBUTION_IN_INCONSISTENCY_H +#define SRC_PG_DEL_MISATTRIBUTION_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_misattribution_in_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_MISATTRIBUTION_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_purses.c b/src/auditordb/pg_del_purses.c new file mode 100644 index 000000000..03661b6e7 --- /dev/null +++ b/src/auditordb/pg_del_purses.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_purses.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_purses ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_purses", + "DELETE" + " FROM auditor_purses" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_purses", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_purses.h b/src/auditordb/pg_del_purses.h new file mode 100644 index 000000000..94b41b272 --- /dev/null +++ b/src/auditordb/pg_del_purses.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_PURSES_H +#define SRC_PG_DEL_PURSES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_purses ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_PURSES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.c new file mode 100644 index 000000000..b7cc6e5b4 --- /dev/null +++ b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_reserve_balance_summary_wrong_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_balance_summary_wrong_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_reserve_balance_summary_wrong_inconsistency", + "DELETE" + " FROM auditor_reserve_balance_summary_wrong_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_reserve_balance_summary_wrong_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.h b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.h new file mode 100644 index 000000000..e5640d2cb --- /dev/null +++ b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H +#define SRC_PG_DEL_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_balance_summary_wrong_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_in_inconsistency.c b/src/auditordb/pg_del_reserve_in_inconsistency.c new file mode 100644 index 000000000..5e0e6dbe6 --- /dev/null +++ b/src/auditordb/pg_del_reserve_in_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_reserve_in_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_in_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_reserve_in_inconsistency", + "DELETE" + " FROM auditor_reserve_in_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_reserve_in_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_in_inconsistency.h b/src/auditordb/pg_del_reserve_in_inconsistency.h new file mode 100644 index 000000000..ae274bb53 --- /dev/null +++ b/src/auditordb/pg_del_reserve_in_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_RESERVE_IN_INCONSISTENCY_H +#define SRC_PG_DEL_RESERVE_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_in_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_RESERVE_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_not_closed_inconsistency.c b/src/auditordb/pg_del_reserve_not_closed_inconsistency.c new file mode 100644 index 000000000..56a902132 --- /dev/null +++ b/src/auditordb/pg_del_reserve_not_closed_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_reserve_not_closed_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_not_closed_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_reserve_not_closed_inconsistency", + "DELETE" + " FROM auditor_reserve_not_closed_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_reserve_not_closed_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_not_closed_inconsistency.h b/src/auditordb/pg_del_reserve_not_closed_inconsistency.h new file mode 100644 index 000000000..2aa89c718 --- /dev/null +++ b/src/auditordb/pg_del_reserve_not_closed_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_RESERVE_NOT_CLOSED_INCONSISTENCY_H +#define SRC_PG_DEL_RESERVE_NOT_CLOSED_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_not_closed_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_RESERVE_NOT_CLOSED_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserves.c b/src/auditordb/pg_del_reserves.c new file mode 100644 index 000000000..1413c028b --- /dev/null +++ b/src/auditordb/pg_del_reserves.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_reserves.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserves ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_reserves", + "DELETE" + " FROM auditor_reserves" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_reserves", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserves.h b/src/auditordb/pg_del_reserves.h new file mode 100644 index 000000000..7e87a6189 --- /dev/null +++ b/src/auditordb/pg_del_reserves.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_RESERVES_H +#define SRC_PG_DEL_RESERVES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserves ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_RESERVES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_row_minor_inconsistencies.c b/src/auditordb/pg_del_row_minor_inconsistencies.c new file mode 100644 index 000000000..9a2c6953f --- /dev/null +++ b/src/auditordb/pg_del_row_minor_inconsistencies.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_row_minor_inconsistencies.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_row_minor_inconsistencies ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_row_minor_inconsistencies", + "DELETE" + " FROM auditor_row_minor_inconsistencies" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_row_minor_inconsistencies", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_row_minor_inconsistencies.h b/src/auditordb/pg_del_row_minor_inconsistencies.h new file mode 100644 index 000000000..c3df22c2d --- /dev/null +++ b/src/auditordb/pg_del_row_minor_inconsistencies.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_ROW_MINOR_INCONSISTENCIES_H +#define SRC_PG_DEL_ROW_MINOR_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_row_minor_inconsistencies ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_ROW_MINOR_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_wire_format_inconsistency.c b/src/auditordb/pg_del_wire_format_inconsistency.c new file mode 100644 index 000000000..018381f8c --- /dev/null +++ b/src/auditordb/pg_del_wire_format_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_wire_format_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_wire_format_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_wire_format_inconsistency", + "DELETE" + " FROM auditor_wire_format_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_wire_format_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_wire_format_inconsistency.h b/src/auditordb/pg_del_wire_format_inconsistency.h new file mode 100644 index 000000000..f298e4dd8 --- /dev/null +++ b/src/auditordb/pg_del_wire_format_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_WIRE_FORMAT_INCONSISTENCY_H +#define SRC_PG_DEL_WIRE_FORMAT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_wire_format_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_WIRE_FORMAT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_wire_out_inconsistency.c b/src/auditordb/pg_del_wire_out_inconsistency.c new file mode 100644 index 000000000..0976cec4d --- /dev/null +++ b/src/auditordb/pg_del_wire_out_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_wire_out_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_wire_out_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_wire_out_inconsistency", + "DELETE" + " FROM auditor_wire_out_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_wire_out_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_wire_out_inconsistency.h b/src/auditordb/pg_del_wire_out_inconsistency.h new file mode 100644 index 000000000..d7e3b54c1 --- /dev/null +++ b/src/auditordb/pg_del_wire_out_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_WIRE_OUT_INCONSISTENCY_H +#define SRC_PG_DEL_WIRE_OUT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_wire_out_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_WIRE_OUT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_amount_arithmetic_inconsistency.c b/src/auditordb/pg_get_amount_arithmetic_inconsistency.c index c768f43ac..312d9e233 100644 --- a/src/auditordb/pg_get_amount_arithmetic_inconsistency.c +++ b/src/auditordb/pg_get_amount_arithmetic_inconsistency.c @@ -102,19 +102,21 @@ amount_arithmetic_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_amount_arithmetic_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - // GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct AmountArithmeticInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -123,7 +125,7 @@ TAH_PG_get_amount_arithmetic_inconsistency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_amount_arithmetic_inconsistency_select", + "auditor_amount_arithmetic_inconsistency_select_desc", "SELECT" " row_id" ",operation" @@ -131,10 +133,27 @@ TAH_PG_get_amount_arithmetic_inconsistency ( ",auditor_amount" ",profitable" " FROM auditor_amount_arithmetic_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id<$1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_amount_arithmetic_inconsistency_select_asc", + "SELECT" + " row_id" + ",operation" + ",exchange_amount" + ",auditor_amount" + ",profitable" + " FROM auditor_amount_arithmetic_inconsistency" + " WHERE (row_id>$1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_amount_arithmetic_inconsistency_select", + (limit > 0) ? "auditor_amount_arithmetic_inconsistency_select_asc" : "auditor_amount_arithmetic_inconsistency_select_desc", params, &amount_arithmetic_inconsistency_cb, &dcc); diff --git a/src/auditordb/pg_get_amount_arithmetic_inconsistency.h b/src/auditordb/pg_get_amount_arithmetic_inconsistency.h index 845ae117c..3d00cccce 100644 --- a/src/auditordb/pg_get_amount_arithmetic_inconsistency.h +++ b/src/auditordb/pg_get_amount_arithmetic_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_amount_arithmetic_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_auditor_closure_lags.c b/src/auditordb/pg_get_auditor_closure_lags.c index 6624ca378..409be8a9b 100644 --- a/src/auditordb/pg_get_auditor_closure_lags.c +++ b/src/auditordb/pg_get_auditor_closure_lags.c @@ -96,18 +96,20 @@ closure_lags_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_auditor_closure_lags ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_ClosureLagsCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct ClosureLagsContext dcc = { .cb = cb, @@ -117,7 +119,7 @@ TAH_PG_get_auditor_closure_lags ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_closure_lags_get", + "auditor_closure_lags_get_desc", "SELECT" " row_id" ",amount" @@ -125,10 +127,27 @@ TAH_PG_get_auditor_closure_lags ( ",wtid" ",account" " FROM auditor_closure_lags" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_closure_lags_get_asc", + "SELECT" + " row_id" + ",amount" + ",deadline" + ",wtid" + ",account" + " FROM auditor_closure_lags" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_auditor_closure_lags_get", + (limit > 0) ? "auditor_auditor_closure_lags_get_asc" : "auditor_auditor_closure_lags_get_desc", params, &closure_lags_cb, &dcc); diff --git a/src/auditordb/pg_get_auditor_closure_lags.h b/src/auditordb/pg_get_auditor_closure_lags.h index 2497760ed..d94d8fa74 100644 --- a/src/auditordb/pg_get_auditor_closure_lags.h +++ b/src/auditordb/pg_get_auditor_closure_lags.h @@ -24,7 +24,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_auditor_closure_lags ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_ClosureLagsCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_coin_inconsistency.c b/src/auditordb/pg_get_coin_inconsistency.c index 949136ca3..0e6c45a18 100644 --- a/src/auditordb/pg_get_coin_inconsistency.c +++ b/src/auditordb/pg_get_coin_inconsistency.c @@ -106,19 +106,21 @@ coin_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_coin_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_CoinInconsistencyCallback cb, void *cb_cls) { printf ("checkpoint pg_0\n"); struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - // GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct CoinInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -129,7 +131,7 @@ TAH_PG_get_coin_inconsistency ( printf ("checkpoint pg_1\n"); PREPARE (pg, - "auditor_coin_inconsistency_select", + "auditor_coin_inconsistency_select_desc", "SELECT" " row_id" ",operation" @@ -138,10 +140,28 @@ TAH_PG_get_coin_inconsistency ( ",coin_pub" ",profitable" " FROM auditor_coin_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_coin_inconsistency_select_asc", + "SELECT" + " row_id" + ",operation" + ",exchange_amount" + ",auditor_amount" + ",coin_pub" + ",profitable" + " FROM auditor_coin_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_coin_inconsistency_select", + (limit > 0) ? "auditor_coin_inconsistency_select_asc" : "auditor_coin_inconsistency_select_desc", params, &coin_inconsistency_cb, &dcc); diff --git a/src/auditordb/pg_get_coin_inconsistency.h b/src/auditordb/pg_get_coin_inconsistency.h index f64b1aa1e..bff9b82b5 100644 --- a/src/auditordb/pg_get_coin_inconsistency.h +++ b/src/auditordb/pg_get_coin_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_coin_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_CoinInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c index 685e71381..94537b151 100644 --- a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c +++ b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c @@ -97,19 +97,21 @@ denomination_key_validity_withdraw_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_denomination_key_validity_withdraw_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct DenominationKeyValidityWithdrawInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -118,17 +120,33 @@ TAH_PG_get_denomination_key_validity_withdraw_inconsistency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_denomination_key_validity_withdraw_inconsistency_get", + "auditor_denomination_key_validity_withdraw_inconsistency_get_desc", "SELECT" " row_id" ",execution_date" ",reserve_pub" ",denompub_h" " FROM auditor_denomination_key_validity_withdraw_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_denomination_key_validity_withdraw_inconsistency_get_asc", + "SELECT" + " row_id" + ",execution_date" + ",reserve_pub" + ",denompub_h" + " FROM auditor_denomination_key_validity_withdraw_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_denomination_key_validity_withdraw_inconsistency_get", + (limit > 0 ) ? "auditor_denomination_key_validity_withdraw_inconsistency_get_asc" : "auditor_denomination_key_validity_withdraw_inconsistency_get_desc", params, & denomination_key_validity_withdraw_inconsistency_cb, diff --git a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h index 0421eb3bc..ab40da401 100644 --- a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h +++ b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_denomination_key_validity_withdraw_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_denomination_pending.c b/src/auditordb/pg_get_denomination_pending.c new file mode 100644 index 000000000..e7b82fe9b --- /dev/null +++ b/src/auditordb/pg_get_denomination_pending.c @@ -0,0 +1,188 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_denomination_pending.h" + + +struct DenominationPendingContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_DenominationPendingCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_denomination_pending(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct DenominationPendingContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +denomination_pending_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct DenominationPendingContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_DenominationPending dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("denom_pub_hash", &dc.denom_pub_hash), +TALER_PQ_RESULT_SPEC_AMOUNT("denom_balance", &dc.denom_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("denom_loss", &dc.denom_loss), +GNUNET_PQ_result_spec_int64("num_issued", &dc.num_issued), +TALER_PQ_RESULT_SPEC_AMOUNT("denom_risk", &dc.denom_risk), +TALER_PQ_RESULT_SPEC_AMOUNT("recoup_loss", &dc.recoup_loss), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_denomination_pending ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_DenominationPendingCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct DenominationPendingContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_denomination_pending_get_desc", + "SELECT" + " denom_pub_hash," +" denom_balance," +" denom_loss," +" num_issued," +" denom_risk," +" recoup_loss," +" suppressed" + " FROM auditor_denomination_pending" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_denomination_pending_get_asc", + "SELECT" + " denom_pub_hash," +" denom_balance," +" denom_loss," +" num_issued," +" denom_risk," +" recoup_loss," +" suppressed" + " FROM auditor_denomination_pending" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_denomination_pending_get_asc" + : "auditor_denomination_pending_get_desc", + params, + &denomination_pending_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_denomination_pending.h b/src/auditordb/pg_get_denomination_pending.h new file mode 100644 index 000000000..ac157e676 --- /dev/null +++ b/src/auditordb/pg_get_denomination_pending.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_DENOMINATION_PENDING_H +#define SRC_PG_GET_DENOMINATION_PENDING_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about denomination-pending from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_denomination_pending ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_DenominationPendingCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_DENOMINATION_PENDING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_denominations_without_sigs.c b/src/auditordb/pg_get_denominations_without_sigs.c new file mode 100644 index 000000000..227c00d45 --- /dev/null +++ b/src/auditordb/pg_get_denominations_without_sigs.c @@ -0,0 +1,184 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_denominations_without_sigs.h" + + +struct DenominationsWithoutSigsContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_DenominationsWithoutSigsCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_denominations_without_sigs(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct DenominationsWithoutSigsContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +denominations_without_sigs_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct DenominationsWithoutSigsContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_DenominationsWithoutSigs dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("denompub_h", &dc.denompub_h), +TALER_PQ_RESULT_SPEC_AMOUNT("value", &dc.value), +GNUNET_PQ_result_spec_int64("start_time", &dc.start_time), +GNUNET_PQ_result_spec_int64("end_time", &dc.end_time), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_denominations_without_sigs ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_DenominationsWithoutSigsCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct DenominationsWithoutSigsContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_denominations_without_sigs_get_desc", + "SELECT" + " row_id," +" denompub_h," +" value," +" start_time," +" end_time," +" suppressed" + " FROM auditor_denominations_without_sigs" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_denominations_without_sigs_get_asc", + "SELECT" + " row_id," +" denompub_h," +" value," +" start_time," +" end_time," +" suppressed" + " FROM auditor_denominations_without_sigs" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_denominations_without_sigs_get_asc" + : "auditor_denominations_without_sigs_get_desc", + params, + &denominations_without_sigs_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_denominations_without_sigs.h b/src/auditordb/pg_get_denominations_without_sigs.h new file mode 100644 index 000000000..7186dee00 --- /dev/null +++ b/src/auditordb/pg_get_denominations_without_sigs.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_DENOMINATIONS_WITHOUT_SIGS_H +#define SRC_PG_GET_DENOMINATIONS_WITHOUT_SIGS_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about denominations-without-sigs from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_denominations_without_sigs ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_DenominationsWithoutSigsCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_DENOMINATIONS_WITHOUT_SIGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_deposit_confirmations.c b/src/auditordb/pg_get_deposit_confirmations.c index 0601056d9..e5158a69d 100644 --- a/src/auditordb/pg_get_deposit_confirmations.c +++ b/src/auditordb/pg_get_deposit_confirmations.c @@ -176,19 +176,19 @@ TAH_PG_get_deposit_confirmations ( "auditor_deposit_confirmation_select", "SELECT" " deposit_confirmation_serial_id" - // ",h_contract_terms" - // ",h_policy" - // ",h_wire" + ",h_contract_terms" + ",h_policy" + ",h_wire" ",exchange_timestamp" ",wire_deadline" ",refund_deadline" ",total_without_fee" - // ",coin_pubs" - // ",coin_sigs" - // ",merchant_pub" - // ",exchange_sig" - // ",exchange_pub" - // ",master_sig" + ",coin_pubs" + ",coin_sigs" + ",merchant_pub" + ",exchange_sig" + ",exchange_pub" + ",master_sig" " FROM auditor_deposit_confirmations" " WHERE deposit_confirmation_serial_id>$1" " AND ($2 OR NOT suppressed);"); diff --git a/src/auditordb/pg_get_emergency.c b/src/auditordb/pg_get_emergency.c index 7e44aade1..33a8de1f0 100644 --- a/src/auditordb/pg_get_emergency.c +++ b/src/auditordb/pg_get_emergency.c @@ -99,18 +99,20 @@ emergency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_emergency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_EmergencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct EmergencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -119,7 +121,7 @@ TAH_PG_get_emergency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_emergency_get", + "auditor_emergency_get_desc", "SELECT" " row_id" ",denompub_h" @@ -129,10 +131,29 @@ TAH_PG_get_emergency ( ",deposit_end" ",value" " FROM auditor_emergency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_emergency_get_asc", + "SELECT" + " row_id" + ",denompub_h" + ",denom_risk" + ",denom_loss" + ",deposit_start" + ",deposit_end" + ",value" + " FROM auditor_emergency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_emergency_get", + (limit > 0) ? "auditor_emergency_get_asc" : "auditor_emergency_get_desc", params, &emergency_cb, &dcc); diff --git a/src/auditordb/pg_get_emergency.h b/src/auditordb/pg_get_emergency.h index 86f01a7bc..64415750b 100644 --- a/src/auditordb/pg_get_emergency.h +++ b/src/auditordb/pg_get_emergency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_emergency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_EmergencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_emergency_by_count.c b/src/auditordb/pg_get_emergency_by_count.c index 56d83e16e..b056683c1 100644 --- a/src/auditordb/pg_get_emergency_by_count.c +++ b/src/auditordb/pg_get_emergency_by_count.c @@ -102,18 +102,20 @@ emergency_by_count_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_emergency_by_count ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_EmergenciesByCountCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct EmergencyByCountContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -122,7 +124,7 @@ TAH_PG_get_emergency_by_count ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_emergency_by_count_get", + "auditor_emergency_by_count_get_desc", "SELECT" " row_id" ",denompub_h" @@ -133,10 +135,30 @@ TAH_PG_get_emergency_by_count ( ",deposit_end" ",value" " FROM auditor_emergency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_emergency_by_count_get_asc", + "SELECT" + " row_id" + ",denompub_h" + ",num_issued" + ",num_known" + ",risk" + ",start" + ",deposit_end" + ",value" + " FROM auditor_emergency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_emergency_by_count_get", + (limit > 0) ? "auditor_emergency_by_count_get_asc" : "auditor_emergency_by_count_get_desc", params, &emergency_by_count_cb, &dcc); diff --git a/src/auditordb/pg_get_emergency_by_count.h b/src/auditordb/pg_get_emergency_by_count.h index 99944afa3..b6b4e0f04 100644 --- a/src/auditordb/pg_get_emergency_by_count.h +++ b/src/auditordb/pg_get_emergency_by_count.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_emergency_by_count ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_EmergenciesByCountCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_exchange_signkeys.c b/src/auditordb/pg_get_exchange_signkeys.c new file mode 100644 index 000000000..0d0ee64dd --- /dev/null +++ b/src/auditordb/pg_get_exchange_signkeys.c @@ -0,0 +1,185 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_exchange_signkeys.h" + + +struct ExchangeSignkeysContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ExchangeSignkeysCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_exchange_signkeys(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ExchangeSignkeysContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +exchange_signkeys_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ExchangeSignkeysContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ExchangeSignkeys dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("exchange_pub", &dc.exchange_pub), +GNUNET_PQ_result_spec_auto_from_type("master_sig", &dc.master_sig), +GNUNET_PQ_result_spec_int64("ep_valid_from", &dc.ep_valid_from), +GNUNET_PQ_result_spec_int64("ep_expire_sign", &dc.ep_expire_sign), +GNUNET_PQ_result_spec_int64("ep_expire_legal", &dc.ep_expire_legal), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_exchange_signkeys ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ExchangeSignkeysCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ExchangeSignkeysContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_exchange_signkeys_get_desc", + "SELECT" + " exchange_pub," +" master_sig," +" ep_valid_from," +" ep_expire_sign," +" ep_expire_legal," +" suppressed" + " FROM auditor_exchange_signkeys" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_exchange_signkeys_get_asc", + "SELECT" + " exchange_pub," +" master_sig," +" ep_valid_from," +" ep_expire_sign," +" ep_expire_legal," +" suppressed" + " FROM auditor_exchange_signkeys" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_exchange_signkeys_get_asc" + : "auditor_exchange_signkeys_get_desc", + params, + &exchange_signkeys_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_exchange_signkeys.h b/src/auditordb/pg_get_exchange_signkeys.h new file mode 100644 index 000000000..45d071b32 --- /dev/null +++ b/src/auditordb/pg_get_exchange_signkeys.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_EXCHANGE_SIGNKEYS_H +#define SRC_PG_GET_EXCHANGE_SIGNKEYS_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about exchange-signkeys from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_exchange_signkeys ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ExchangeSignkeysCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_EXCHANGE_SIGNKEYS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_fee_time_inconsistency.c b/src/auditordb/pg_get_fee_time_inconsistency.c index c24a4e54c..5b1a7aa3f 100644 --- a/src/auditordb/pg_get_fee_time_inconsistency.c +++ b/src/auditordb/pg_get_fee_time_inconsistency.c @@ -99,18 +99,20 @@ fee_time_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_fee_time_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_FeeTimeInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct FeeTimeInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -119,17 +121,33 @@ TAH_PG_get_fee_time_inconsistency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_fee_time_inconsistency_get", + "auditor_fee_time_inconsistency_get_desc", "SELECT" " row_id" ",type" ",time" ",diagnostic" " FROM auditor_fee_time_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_fee_time_inconsistency_get_asc", + "SELECT" + " row_id" + ",type" + ",time" + ",diagnostic" + " FROM auditor_fee_time_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_fee_time_inconsistency_get", + (limit > 0) ? "auditor_fee_time_inconsistency_get_asc" : "auditor_fee_time_inconsistency_get_desc", params, &fee_time_inconsistency_cb, &dcc); diff --git a/src/auditordb/pg_get_fee_time_inconsistency.h b/src/auditordb/pg_get_fee_time_inconsistency.h index 6d182432e..7c4796b4b 100644 --- a/src/auditordb/pg_get_fee_time_inconsistency.h +++ b/src/auditordb/pg_get_fee_time_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_fee_time_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_FeeTimeInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_historic_denomination_revenue.c b/src/auditordb/pg_get_historic_denomination_revenue.c new file mode 100644 index 000000000..ca14e88a0 --- /dev/null +++ b/src/auditordb/pg_get_historic_denomination_revenue.c @@ -0,0 +1,182 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_historic_denomination_revenue.h" + + +struct HistoricDenominationRevenueContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_HistoricDenominationRevenueCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_historic_denomination_revenue(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct HistoricDenominationRevenueContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +historic_denomination_revenue_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct HistoricDenominationRevenueContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_HistoricDenominationRevenue dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("denom_pub_hash", &dc.denom_pub_hash), +GNUNET_PQ_result_spec_int64("revenue_timestamp", &dc.revenue_timestamp), +TALER_PQ_RESULT_SPEC_AMOUNT("revenue_balance", &dc.revenue_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("loss_balance", &dc.loss_balance), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_historic_denomination_revenue ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_HistoricDenominationRevenueCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct HistoricDenominationRevenueContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_historic_denomination_revenue_get_desc", + "SELECT" + " denom_pub_hash," +" revenue_timestamp," +" revenue_balance," +" loss_balance," +" suppressed" + " FROM auditor_historic_denomination_revenue" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_historic_denomination_revenue_get_asc", + "SELECT" + " denom_pub_hash," +" revenue_timestamp," +" revenue_balance," +" loss_balance," +" suppressed" + " FROM auditor_historic_denomination_revenue" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_historic_denomination_revenue_get_asc" + : "auditor_historic_denomination_revenue_get_desc", + params, + &historic_denomination_revenue_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_historic_denomination_revenue.h b/src/auditordb/pg_get_historic_denomination_revenue.h new file mode 100644 index 000000000..82a73c8ec --- /dev/null +++ b/src/auditordb/pg_get_historic_denomination_revenue.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_HISTORIC_DENOMINATION_REVENUE_H +#define SRC_PG_GET_HISTORIC_DENOMINATION_REVENUE_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about historic-denomination-revenue from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_historic_denomination_revenue ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_HistoricDenominationRevenueCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_HISTORIC_DENOMINATION_REVENUE_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_historic_reserve_summary.c b/src/auditordb/pg_get_historic_reserve_summary.c new file mode 100644 index 000000000..454224533 --- /dev/null +++ b/src/auditordb/pg_get_historic_reserve_summary.c @@ -0,0 +1,179 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_historic_reserve_summary.h" + + +struct HistoricReserveSummaryContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_HistoricReserveSummaryCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_historic_reserve_summary(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct HistoricReserveSummaryContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +historic_reserve_summary_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct HistoricReserveSummaryContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_HistoricReserveSummary dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_int64("start_date", &dc.start_date), +GNUNET_PQ_result_spec_int64("end_date", &dc.end_date), +TALER_PQ_RESULT_SPEC_AMOUNT("reserve_profits", &dc.reserve_profits), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_historic_reserve_summary ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_HistoricReserveSummaryCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct HistoricReserveSummaryContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_historic_reserve_summary_get_desc", + "SELECT" + " start_date," +" end_date," +" reserve_profits," +" suppressed" + " FROM auditor_historic_reserve_summary" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_historic_reserve_summary_get_asc", + "SELECT" + " start_date," +" end_date," +" reserve_profits," +" suppressed" + " FROM auditor_historic_reserve_summary" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_historic_reserve_summary_get_asc" + : "auditor_historic_reserve_summary_get_desc", + params, + &historic_reserve_summary_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_historic_reserve_summary.h b/src/auditordb/pg_get_historic_reserve_summary.h new file mode 100644 index 000000000..c0e912268 --- /dev/null +++ b/src/auditordb/pg_get_historic_reserve_summary.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_HISTORIC_RESERVE_SUMMARY_H +#define SRC_PG_GET_HISTORIC_RESERVE_SUMMARY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about historic-reserve-summary from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_historic_reserve_summary ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_HistoricReserveSummaryCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_HISTORIC_RESERVE_SUMMARY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_misattribution_in_inconsistency.c b/src/auditordb/pg_get_misattribution_in_inconsistency.c new file mode 100644 index 000000000..a47b11306 --- /dev/null +++ b/src/auditordb/pg_get_misattribution_in_inconsistency.c @@ -0,0 +1,181 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_misattribution_in_inconsistency.h" + + +struct MisattributionInInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_MisattributionInInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_misattribution_in_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct MisattributionInInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +misattribution_in_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct MisattributionInInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_MisattributionInInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + TALER_PQ_RESULT_SPEC_AMOUNT("amount", &dc.amount), +GNUNET_PQ_result_spec_int64("bank_row", &dc.bank_row), +GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_misattribution_in_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_MisattributionInInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct MisattributionInInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_misattribution_in_inconsistency_get_desc", + "SELECT" + " row_id," +" amount," +" bank_row," +" reserve_pub," +" suppressed" + " FROM auditor_misattribution_in_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_misattribution_in_inconsistency_get_asc", + "SELECT" + " row_id," +" amount," +" bank_row," +" reserve_pub," +" suppressed" + " FROM auditor_misattribution_in_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_misattribution_in_inconsistency_get_asc" + : "auditor_misattribution_in_inconsistency_get_desc", + params, + &misattribution_in_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_misattribution_in_inconsistency.h b/src/auditordb/pg_get_misattribution_in_inconsistency.h new file mode 100644 index 000000000..54fb6c03e --- /dev/null +++ b/src/auditordb/pg_get_misattribution_in_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_MISATTRIBUTION_IN_INCONSISTENCY_H +#define SRC_PG_GET_MISATTRIBUTION_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about misattribution-in-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_misattribution_in_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_MisattributionInInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_MISATTRIBUTION_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_purse_not_closed_inconsistencies.c b/src/auditordb/pg_get_purse_not_closed_inconsistencies.c index 4ba51e0a3..7489f7ccb 100644 --- a/src/auditordb/pg_get_purse_not_closed_inconsistencies.c +++ b/src/auditordb/pg_get_purse_not_closed_inconsistencies.c @@ -100,18 +100,20 @@ purse_not_closed_inconsistencies_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_purse_not_closed_inconsistencies ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct PurseNotClosedInconsistenciesContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -120,17 +122,33 @@ TAH_PG_get_purse_not_closed_inconsistencies ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_purse_not_closed_inconsistencies_get", + "auditor_purse_not_closed_inconsistencies_get_desc", "SELECT" " row_id" ",purse_pub" ",amount" ",expiration_date" " FROM auditor_purse_not_closed_inconsistencies" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_purse_not_closed_inconsistencies_get_asc", + "SELECT" + " row_id" + ",purse_pub" + ",amount" + ",expiration_date" + " FROM auditor_purse_not_closed_inconsistencies" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_purse_not_closed_inconsistencies_get", + (limit > 0) ? "auditor_purse_not_closed_inconsistencies_get_asc" : "auditor_purse_not_closed_inconsistencies_get_desc", params, & purse_not_closed_inconsistencies_cb, diff --git a/src/auditordb/pg_get_purse_not_closed_inconsistencies.h b/src/auditordb/pg_get_purse_not_closed_inconsistencies.h index 188180485..658aeea80 100644 --- a/src/auditordb/pg_get_purse_not_closed_inconsistencies.h +++ b/src/auditordb/pg_get_purse_not_closed_inconsistencies.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_purse_not_closed_inconsistencies ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_purses.c b/src/auditordb/pg_get_purses.c new file mode 100644 index 000000000..a977a1a94 --- /dev/null +++ b/src/auditordb/pg_get_purses.c @@ -0,0 +1,185 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_purses.h" + + +struct PursesContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_PursesCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_purses(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct PursesContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +purses_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct PursesContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_Purses dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_int64("auditor_purses_rowid", &dc.auditor_purses_rowid), +GNUNET_PQ_result_spec_auto_from_type("purse_pub", &dc.purse_pub), +TALER_PQ_RESULT_SPEC_AMOUNT("balance", &dc.balance), +TALER_PQ_RESULT_SPEC_AMOUNT("target", &dc.target), +GNUNET_PQ_result_spec_int64("expiration_date", &dc.expiration_date), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_purses ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_PursesCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct PursesContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_purses_get_desc", + "SELECT" + " auditor_purses_rowid," +" purse_pub," +" balance," +" target," +" expiration_date," +" suppressed" + " FROM auditor_purses" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_purses_get_asc", + "SELECT" + " auditor_purses_rowid," +" purse_pub," +" balance," +" target," +" expiration_date," +" suppressed" + " FROM auditor_purses" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_purses_get_asc" + : "auditor_purses_get_desc", + params, + &purses_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_purses.h b/src/auditordb/pg_get_purses.h new file mode 100644 index 000000000..1890d9bb8 --- /dev/null +++ b/src/auditordb/pg_get_purses.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_PURSES_H +#define SRC_PG_GET_PURSES_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about purses from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_purses ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_PursesCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_PURSES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_refreshes_hanging.c b/src/auditordb/pg_get_refreshes_hanging.c index 5c88966f4..d4dd83b67 100644 --- a/src/auditordb/pg_get_refreshes_hanging.c +++ b/src/auditordb/pg_get_refreshes_hanging.c @@ -98,18 +98,20 @@ refreshes_hanging_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_refreshes_hanging ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_RefreshesHangingCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct RefreshesHangingContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -118,16 +120,31 @@ TAH_PG_get_refreshes_hanging ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_refreshes_hanging_get", + "auditor_refreshes_hanging_get_desc", "SELECT" " row_id" ",amount" ",coin_pub" " FROM auditor_refreshes_hanging" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_refreshes_hanging_get_asc", + "SELECT" + " row_id" + ",amount" + ",coin_pub" + " FROM auditor_refreshes_hanging" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_refreshes_hanging_get", + (limit > 0) ? "auditor_refreshes_hanging_get_asc" : "auditor_refreshes_hanging_get_desc", params, &refreshes_hanging_cb, &dcc); diff --git a/src/auditordb/pg_get_refreshes_hanging.h b/src/auditordb/pg_get_refreshes_hanging.h index 2dd72ed8d..7603c9b3d 100644 --- a/src/auditordb/pg_get_refreshes_hanging.h +++ b/src/auditordb/pg_get_refreshes_hanging.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_refreshes_hanging ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_RefreshesHangingCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c index 250af182d..4182e5dc9 100644 --- a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c +++ b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c @@ -100,18 +100,20 @@ reserve_balance_insufficient_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_reserve_balance_insufficient_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - // GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct ReserveBalanceInsufficientInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -120,17 +122,33 @@ TAH_PG_get_reserve_balance_insufficient_inconsistency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_reserve_balance_insufficient_inconsistency_get", + "auditor_reserve_balance_insufficient_inconsistency_get_desc", "SELECT" " row_id" ",reserve_pub" ",inconsistency_gain" ",inconsistency_amount" " FROM auditor_reserve_balance_insufficient_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_reserve_balance_insufficient_inconsistency_get_asc", + "SELECT" + " row_id" + ",reserve_pub" + ",inconsistency_gain" + ",inconsistency_amount" + " FROM auditor_reserve_balance_insufficient_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_reserve_balance_insufficient_inconsistency_get", + (limit > 0) ? "auditor_reserve_balance_insufficient_inconsistency_get_asc" : "auditor_reserve_balance_insufficient_inconsistency_get_desc", params, & reserve_balance_insufficient_inconsistency_cb, diff --git a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h index 892e75cee..5133f8149 100644 --- a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h +++ b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_reserve_balance_insufficient_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c new file mode 100644 index 000000000..5e7ac3533 --- /dev/null +++ b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,181 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_reserve_balance_summary_wrong_inconsistency.h" + + +struct ReserveBalanceSummaryWrongInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_reserve_balance_summary_wrong_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ReserveBalanceSummaryWrongInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +reserve_balance_summary_wrong_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ReserveBalanceSummaryWrongInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +TALER_PQ_RESULT_SPEC_AMOUNT("exchange_amount", &dc.exchange_amount), +TALER_PQ_RESULT_SPEC_AMOUNT("auditor_amount", &dc.auditor_amount), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_balance_summary_wrong_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ReserveBalanceSummaryWrongInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_reserve_balance_summary_wrong_inconsistency_get_desc", + "SELECT" + " row_id," +" reserve_pub," +" exchange_amount," +" auditor_amount," +" suppressed" + " FROM auditor_reserve_balance_summary_wrong_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_reserve_balance_summary_wrong_inconsistency_get_asc", + "SELECT" + " row_id," +" reserve_pub," +" exchange_amount," +" auditor_amount," +" suppressed" + " FROM auditor_reserve_balance_summary_wrong_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_reserve_balance_summary_wrong_inconsistency_get_asc" + : "auditor_reserve_balance_summary_wrong_inconsistency_get_desc", + params, + &reserve_balance_summary_wrong_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.h b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.h new file mode 100644 index 000000000..2b70e556e --- /dev/null +++ b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H +#define SRC_PG_GET_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about reserve-balance-summary-wrong-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_balance_summary_wrong_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_in_inconsistency.c b/src/auditordb/pg_get_reserve_in_inconsistency.c new file mode 100644 index 000000000..22950f537 --- /dev/null +++ b/src/auditordb/pg_get_reserve_in_inconsistency.c @@ -0,0 +1,190 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_reserve_in_inconsistency.h" + + +struct ReserveInInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ReserveInInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_reserve_in_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ReserveInInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +reserve_in_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ReserveInInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ReserveInInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + TALER_PQ_RESULT_SPEC_AMOUNT("amount_exchange_expected", &dc.amount_exchange_expected), +TALER_PQ_RESULT_SPEC_AMOUNT("amount_wired", &dc.amount_wired), +GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +GNUNET_PQ_result_spec_int64("timestamp", &dc.timestamp), +GNUNET_PQ_result_spec_auto_from_type("account", &dc.account), +GNUNET_PQ_result_spec_auto_from_type("diagnostic", &dc.diagnostic), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_in_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ReserveInInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ReserveInInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_reserve_in_inconsistency_get_desc", + "SELECT" + " row_id," +" amount_exchange_expected," +" amount_wired," +" reserve_pub," +" timestamp," +" account," +" diagnostic," +" suppressed" + " FROM auditor_reserve_in_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_reserve_in_inconsistency_get_asc", + "SELECT" + " row_id," +" amount_exchange_expected," +" amount_wired," +" reserve_pub," +" timestamp," +" account," +" diagnostic," +" suppressed" + " FROM auditor_reserve_in_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_reserve_in_inconsistency_get_asc" + : "auditor_reserve_in_inconsistency_get_desc", + params, + &reserve_in_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_in_inconsistency.h b/src/auditordb/pg_get_reserve_in_inconsistency.h new file mode 100644 index 000000000..2313ce090 --- /dev/null +++ b/src/auditordb/pg_get_reserve_in_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_RESERVE_IN_INCONSISTENCY_H +#define SRC_PG_GET_RESERVE_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about reserve-in-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_in_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveInInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_RESERVE_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_not_closed_inconsistency.c b/src/auditordb/pg_get_reserve_not_closed_inconsistency.c new file mode 100644 index 000000000..ebef6697f --- /dev/null +++ b/src/auditordb/pg_get_reserve_not_closed_inconsistency.c @@ -0,0 +1,184 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_reserve_not_closed_inconsistency.h" + + +struct ReserveNotClosedInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_reserve_not_closed_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ReserveNotClosedInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +reserve_not_closed_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ReserveNotClosedInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ReserveNotClosedInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +TALER_PQ_RESULT_SPEC_AMOUNT("balance", &dc.balance), +GNUNET_PQ_result_spec_int64("expiration_time", &dc.expiration_time), +GNUNET_PQ_result_spec_auto_from_type("diagnostic", &dc.diagnostic), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_not_closed_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ReserveNotClosedInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_reserve_not_closed_inconsistency_get_desc", + "SELECT" + " row_id," +" reserve_pub," +" balance," +" expiration_time," +" diagnostic," +" suppressed" + " FROM auditor_reserve_not_closed_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_reserve_not_closed_inconsistency_get_asc", + "SELECT" + " row_id," +" reserve_pub," +" balance," +" expiration_time," +" diagnostic," +" suppressed" + " FROM auditor_reserve_not_closed_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_reserve_not_closed_inconsistency_get_asc" + : "auditor_reserve_not_closed_inconsistency_get_desc", + params, + &reserve_not_closed_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_not_closed_inconsistency.h b/src/auditordb/pg_get_reserve_not_closed_inconsistency.h new file mode 100644 index 000000000..6dc28f46b --- /dev/null +++ b/src/auditordb/pg_get_reserve_not_closed_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_RESERVE_NOT_CLOSED_INCONSISTENCY_H +#define SRC_PG_GET_RESERVE_NOT_CLOSED_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about reserve-not-closed-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_not_closed_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_RESERVE_NOT_CLOSED_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserves.c b/src/auditordb/pg_get_reserves.c new file mode 100644 index 000000000..8eefba898 --- /dev/null +++ b/src/auditordb/pg_get_reserves.c @@ -0,0 +1,203 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_reserves.h" + + +struct ReservesContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ReservesCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_reserves(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ReservesContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +reserves_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ReservesContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_Reserves dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_int64("auditor_reserves_rowid", &dc.auditor_reserves_rowid), +GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +TALER_PQ_RESULT_SPEC_AMOUNT("reserve_balance", &dc.reserve_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("reserve_loss", &dc.reserve_loss), +TALER_PQ_RESULT_SPEC_AMOUNT("withdraw_fee_balance", &dc.withdraw_fee_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("close_fee_balance", &dc.close_fee_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("purse_fee_balance", &dc.purse_fee_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("open_fee_balance", &dc.open_fee_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("history_fee_balance", &dc.history_fee_balance), +GNUNET_PQ_result_spec_int64("expiration_date", &dc.expiration_date), +GNUNET_PQ_result_spec_string("origin_account", &dc.origin_account), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserves ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ReservesCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ReservesContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_reserves_get_desc", + "SELECT" + " auditor_reserves_rowid," +" reserve_pub," +" reserve_balance," +" reserve_loss," +" withdraw_fee_balance," +" close_fee_balance," +" purse_fee_balance," +" open_fee_balance," +" history_fee_balance," +" expiration_date," +" origin_account," +" suppressed" + " FROM auditor_reserves" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_reserves_get_asc", + "SELECT" + " auditor_reserves_rowid," +" reserve_pub," +" reserve_balance," +" reserve_loss," +" withdraw_fee_balance," +" close_fee_balance," +" purse_fee_balance," +" open_fee_balance," +" history_fee_balance," +" expiration_date," +" origin_account," +" suppressed" + " FROM auditor_reserves" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_reserves_get_asc" + : "auditor_reserves_get_desc", + params, + &reserves_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserves.h b/src/auditordb/pg_get_reserves.h new file mode 100644 index 000000000..0fe15fddd --- /dev/null +++ b/src/auditordb/pg_get_reserves.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_RESERVES_H +#define SRC_PG_GET_RESERVES_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about reserves from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserves ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReservesCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_RESERVES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_row_inconsistency.c b/src/auditordb/pg_get_row_inconsistency.c index 922880da8..67f83f6ed 100644 --- a/src/auditordb/pg_get_row_inconsistency.c +++ b/src/auditordb/pg_get_row_inconsistency.c @@ -99,18 +99,20 @@ row_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_row_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_RowInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - // GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct RowInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -120,16 +122,31 @@ TAH_PG_get_row_inconsistency ( PREPARE (pg, - "auditor_row_inconsistency_select", + "auditor_row_inconsistency_select_desc", "SELECT" " row_id" ",row_table" ",diagnostic" " FROM auditor_row_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_row_inconsistency_select_asc", + "SELECT" + " row_id" + ",row_table" + ",diagnostic" + " FROM auditor_row_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_row_inconsistency_select", + (limit > 0) ? "auditor_row_inconsistency_select_asc" : "auditor_row_inconsistency_select_desc", params, &row_inconsistency_cb, &dcc); diff --git a/src/auditordb/pg_get_row_inconsistency.h b/src/auditordb/pg_get_row_inconsistency.h index 7bfd37e32..ef0136f39 100644 --- a/src/auditordb/pg_get_row_inconsistency.h +++ b/src/auditordb/pg_get_row_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_row_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_RowInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_row_minor_inconsistencies.c b/src/auditordb/pg_get_row_minor_inconsistencies.c new file mode 100644 index 000000000..002abbda3 --- /dev/null +++ b/src/auditordb/pg_get_row_minor_inconsistencies.c @@ -0,0 +1,178 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_row_minor_inconsistencies.h" + + +struct RowMinorInconsistenciesContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_RowMinorInconsistenciesCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_row_minor_inconsistencies(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct RowMinorInconsistenciesContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +row_minor_inconsistencies_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct RowMinorInconsistenciesContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_RowMinorInconsistencies dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("row_table", &dc.row_table), +GNUNET_PQ_result_spec_auto_from_type("diagnostic", &dc.diagnostic), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_row_minor_inconsistencies ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_RowMinorInconsistenciesCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct RowMinorInconsistenciesContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_row_minor_inconsistencies_get_desc", + "SELECT" + " row_id," +" row_table," +" diagnostic," +" suppressed" + " FROM auditor_row_minor_inconsistencies" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_row_minor_inconsistencies_get_asc", + "SELECT" + " row_id," +" row_table," +" diagnostic," +" suppressed" + " FROM auditor_row_minor_inconsistencies" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_row_minor_inconsistencies_get_asc" + : "auditor_row_minor_inconsistencies_get_desc", + params, + &row_minor_inconsistencies_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_row_minor_inconsistencies.h b/src/auditordb/pg_get_row_minor_inconsistencies.h new file mode 100644 index 000000000..5c71b3f78 --- /dev/null +++ b/src/auditordb/pg_get_row_minor_inconsistencies.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_ROW_MINOR_INCONSISTENCIES_H +#define SRC_PG_GET_ROW_MINOR_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about row-minor-inconsistencies from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_row_minor_inconsistencies ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_RowMinorInconsistenciesCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_ROW_MINOR_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_wire_format_inconsistency.c b/src/auditordb/pg_get_wire_format_inconsistency.c new file mode 100644 index 000000000..ec443616e --- /dev/null +++ b/src/auditordb/pg_get_wire_format_inconsistency.c @@ -0,0 +1,181 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_wire_format_inconsistency.h" + + +struct WireFormatInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_WireFormatInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_wire_format_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct WireFormatInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +wire_format_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct WireFormatInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_WireFormatInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + TALER_PQ_RESULT_SPEC_AMOUNT("amount", &dc.amount), +GNUNET_PQ_result_spec_int64("wire_offset", &dc.wire_offset), +GNUNET_PQ_result_spec_auto_from_type("diagnostic", &dc.diagnostic), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_wire_format_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_WireFormatInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct WireFormatInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_wire_format_inconsistency_get_desc", + "SELECT" + " row_id," +" amount," +" wire_offset," +" diagnostic," +" suppressed" + " FROM auditor_wire_format_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_wire_format_inconsistency_get_asc", + "SELECT" + " row_id," +" amount," +" wire_offset," +" diagnostic," +" suppressed" + " FROM auditor_wire_format_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_wire_format_inconsistency_get_asc" + : "auditor_wire_format_inconsistency_get_desc", + params, + &wire_format_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_wire_format_inconsistency.h b/src/auditordb/pg_get_wire_format_inconsistency.h new file mode 100644 index 000000000..ce4bc303a --- /dev/null +++ b/src/auditordb/pg_get_wire_format_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_WIRE_FORMAT_INCONSISTENCY_H +#define SRC_PG_GET_WIRE_FORMAT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about wire-format-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_wire_format_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_WireFormatInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_WIRE_FORMAT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_wire_out_inconsistency.c b/src/auditordb/pg_get_wire_out_inconsistency.c new file mode 100644 index 000000000..f9394375d --- /dev/null +++ b/src/auditordb/pg_get_wire_out_inconsistency.c @@ -0,0 +1,181 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_wire_out_inconsistency.h" + + +struct WireOutInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_WireOutInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_wire_out_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct WireOutInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +wire_out_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct WireOutInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_WireOutInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("destination_account", &dc.destination_account), +TALER_PQ_RESULT_SPEC_AMOUNT("expected", &dc.expected), +TALER_PQ_RESULT_SPEC_AMOUNT("claimed", &dc.claimed), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_wire_out_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_WireOutInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct WireOutInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_wire_out_inconsistency_get_desc", + "SELECT" + " row_id," +" destination_account," +" expected," +" claimed," +" suppressed" + " FROM auditor_wire_out_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_wire_out_inconsistency_get_asc", + "SELECT" + " row_id," +" destination_account," +" expected," +" claimed," +" suppressed" + " FROM auditor_wire_out_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_wire_out_inconsistency_get_asc" + : "auditor_wire_out_inconsistency_get_desc", + params, + &wire_out_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_wire_out_inconsistency.h b/src/auditordb/pg_get_wire_out_inconsistency.h new file mode 100644 index 000000000..0fd8562b1 --- /dev/null +++ b/src/auditordb/pg_get_wire_out_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_WIRE_OUT_INCONSISTENCY_H +#define SRC_PG_GET_WIRE_OUT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about wire-out-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_wire_out_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_WireOutInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_WIRE_OUT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_denomination_pending.c b/src/auditordb/pg_insert_denomination_pending.c new file mode 100644 index 000000000..70a9981d7 --- /dev/null +++ b/src/auditordb/pg_insert_denomination_pending.c @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_denomination_pending.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_denomination_pending ( + void *cls, + const struct TALER_AUDITORDB_DenominationPending *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->denom_pub_hash), +TALER_PQ_query_param_amount(pg->conn, &dc->denom_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->denom_loss), +GNUNET_PQ_query_param_int64(&dc->num_issued), +TALER_PQ_query_param_amount(pg->conn, &dc->denom_risk), +TALER_PQ_query_param_amount(pg->conn, &dc->recoup_loss), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_denomination_pending_insert", + "INSERT INTO auditor_denomination_pending " + "( denom_pub_hash," +" denom_balance," +" denom_loss," +" num_issued," +" denom_risk," +" recoup_loss," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6,$7);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_denomination_pending_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_denomination_pending.h b/src/auditordb/pg_insert_denomination_pending.h new file mode 100644 index 000000000..32f498f08 --- /dev/null +++ b/src/auditordb/pg_insert_denomination_pending.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_DENOMINATION_PENDING_H +#define SRC_PG_INSERT_DENOMINATION_PENDING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_denomination_pending ( + void *cls, + const struct TALER_AUDITORDB_DenominationPending *dc); + +#endif // SRC_PG_INSERT_DENOMINATION_PENDING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_denominations_without_sigs.c b/src/auditordb/pg_insert_denominations_without_sigs.c new file mode 100644 index 000000000..e22e4ffe9 --- /dev/null +++ b/src/auditordb/pg_insert_denominations_without_sigs.c @@ -0,0 +1,61 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_denominations_without_sigs.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_denominations_without_sigs ( + void *cls, + const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->denompub_h), +TALER_PQ_query_param_amount(pg->conn, &dc->value), +GNUNET_PQ_query_param_int64(&dc->start_time), +GNUNET_PQ_query_param_int64(&dc->end_time), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_denominations_without_sigs_insert", + "INSERT INTO auditor_denominations_without_sigs " + "( row_id," +" denompub_h," +" value," +" start_time," +" end_time," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_denominations_without_sigs_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_denominations_without_sigs.h b/src/auditordb/pg_insert_denominations_without_sigs.h new file mode 100644 index 000000000..eb56f74a6 --- /dev/null +++ b/src/auditordb/pg_insert_denominations_without_sigs.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_DENOMINATIONS_WITHOUT_SIGS_H +#define SRC_PG_INSERT_DENOMINATIONS_WITHOUT_SIGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_denominations_without_sigs ( + void *cls, + const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc); + +#endif // SRC_PG_INSERT_DENOMINATIONS_WITHOUT_SIGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_exchange_signkeys.c b/src/auditordb/pg_insert_exchange_signkeys.c new file mode 100644 index 000000000..09ab0e941 --- /dev/null +++ b/src/auditordb/pg_insert_exchange_signkeys.c @@ -0,0 +1,62 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_exchange_signkeys.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_exchange_signkeys ( + void *cls, + const struct TALER_AUDITORDB_ExchangeSignkeys *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->exchange_pub), +GNUNET_PQ_query_param_auto_from_type(&dc->master_sig), +GNUNET_PQ_query_param_int64(&dc->ep_valid_from), +GNUNET_PQ_query_param_int64(&dc->ep_expire_sign), +GNUNET_PQ_query_param_int64(&dc->ep_expire_legal), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_exchange_signkeys_insert", + "INSERT INTO auditor_exchange_signkeys " + "( exchange_pub," +" master_sig," +" ep_valid_from," +" ep_expire_sign," +" ep_expire_legal," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_exchange_signkeys_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_exchange_signkeys.h b/src/auditordb/pg_insert_exchange_signkeys.h new file mode 100644 index 000000000..62df3aaac --- /dev/null +++ b/src/auditordb/pg_insert_exchange_signkeys.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_EXCHANGE_SIGNKEYS_H +#define SRC_PG_INSERT_EXCHANGE_SIGNKEYS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_exchange_signkeys ( + void *cls, + const struct TALER_AUDITORDB_ExchangeSignkeys *dc); + +#endif // SRC_PG_INSERT_EXCHANGE_SIGNKEYS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_historic_denomination_revenue.c b/src/auditordb/pg_insert_historic_denomination_revenue.c new file mode 100644 index 000000000..c7779c9b3 --- /dev/null +++ b/src/auditordb/pg_insert_historic_denomination_revenue.c @@ -0,0 +1,60 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_historic_denomination_revenue.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_historic_denomination_revenue ( + void *cls, + const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->denom_pub_hash), +GNUNET_PQ_query_param_int64(&dc->revenue_timestamp), +TALER_PQ_query_param_amount(pg->conn, &dc->revenue_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->loss_balance), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_historic_denomination_revenue_insert", + "INSERT INTO auditor_historic_denomination_revenue " + "( denom_pub_hash," +" revenue_timestamp," +" revenue_balance," +" loss_balance," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_historic_denomination_revenue_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_historic_denomination_revenue.h b/src/auditordb/pg_insert_historic_denomination_revenue.h new file mode 100644 index 000000000..0e21ef3e3 --- /dev/null +++ b/src/auditordb/pg_insert_historic_denomination_revenue.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_HISTORIC_DENOMINATION_REVENUE_H +#define SRC_PG_INSERT_HISTORIC_DENOMINATION_REVENUE_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_historic_denomination_revenue ( + void *cls, + const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc); + +#endif // SRC_PG_INSERT_HISTORIC_DENOMINATION_REVENUE_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_historic_reserve_summary.c b/src/auditordb/pg_insert_historic_reserve_summary.c new file mode 100644 index 000000000..420b6223c --- /dev/null +++ b/src/auditordb/pg_insert_historic_reserve_summary.c @@ -0,0 +1,58 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_historic_reserve_summary.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_historic_reserve_summary ( + void *cls, + const struct TALER_AUDITORDB_HistoricReserveSummary *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_int64(&dc->start_date), +GNUNET_PQ_query_param_int64(&dc->end_date), +TALER_PQ_query_param_amount(pg->conn, &dc->reserve_profits), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_historic_reserve_summary_insert", + "INSERT INTO auditor_historic_reserve_summary " + "( start_date," +" end_date," +" reserve_profits," +" suppressed" +") VALUES ($1,$2,$3,$4);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_historic_reserve_summary_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_historic_reserve_summary.h b/src/auditordb/pg_insert_historic_reserve_summary.h new file mode 100644 index 000000000..c3f360b98 --- /dev/null +++ b/src/auditordb/pg_insert_historic_reserve_summary.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_HISTORIC_RESERVE_SUMMARY_H +#define SRC_PG_INSERT_HISTORIC_RESERVE_SUMMARY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_historic_reserve_summary ( + void *cls, + const struct TALER_AUDITORDB_HistoricReserveSummary *dc); + +#endif // SRC_PG_INSERT_HISTORIC_RESERVE_SUMMARY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_misattribution_in_inconsistency.c b/src/auditordb/pg_insert_misattribution_in_inconsistency.c new file mode 100644 index 000000000..45eb8c004 --- /dev/null +++ b/src/auditordb/pg_insert_misattribution_in_inconsistency.c @@ -0,0 +1,59 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_misattribution_in_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_misattribution_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_MisattributionInInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + TALER_PQ_query_param_amount(pg->conn, &dc->amount), +GNUNET_PQ_query_param_int64(&dc->bank_row), +GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_misattribution_in_inconsistency_insert", + "INSERT INTO auditor_misattribution_in_inconsistency " + "( row_id," +" amount," +" bank_row," +" reserve_pub," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_misattribution_in_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_misattribution_in_inconsistency.h b/src/auditordb/pg_insert_misattribution_in_inconsistency.h new file mode 100644 index 000000000..d631e8007 --- /dev/null +++ b/src/auditordb/pg_insert_misattribution_in_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_MISATTRIBUTION_IN_INCONSISTENCY_H +#define SRC_PG_INSERT_MISATTRIBUTION_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_misattribution_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_MisattributionInInconsistency *dc); + +#endif // SRC_PG_INSERT_MISATTRIBUTION_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_purses.c b/src/auditordb/pg_insert_purses.c new file mode 100644 index 000000000..e32b33bd5 --- /dev/null +++ b/src/auditordb/pg_insert_purses.c @@ -0,0 +1,62 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_purses.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_purses ( + void *cls, + const struct TALER_AUDITORDB_Purses *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_int64(&dc->auditor_purses_rowid), +GNUNET_PQ_query_param_auto_from_type(&dc->purse_pub), +TALER_PQ_query_param_amount(pg->conn, &dc->balance), +TALER_PQ_query_param_amount(pg->conn, &dc->target), +GNUNET_PQ_query_param_int64(&dc->expiration_date), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_purses_insert", + "INSERT INTO auditor_purses " + "( auditor_purses_rowid," +" purse_pub," +" balance," +" target," +" expiration_date," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_purses_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_purses.h b/src/auditordb/pg_insert_purses.h new file mode 100644 index 000000000..7fd1f0ab4 --- /dev/null +++ b/src/auditordb/pg_insert_purses.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_PURSES_H +#define SRC_PG_INSERT_PURSES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_purses ( + void *cls, + const struct TALER_AUDITORDB_Purses *dc); + +#endif // SRC_PG_INSERT_PURSES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.c new file mode 100644 index 000000000..34419d062 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,59 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_reserve_balance_summary_wrong_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_balance_summary_wrong_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +TALER_PQ_query_param_amount(pg->conn, &dc->exchange_amount), +TALER_PQ_query_param_amount(pg->conn, &dc->auditor_amount), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserve_balance_summary_wrong_inconsistency_insert", + "INSERT INTO auditor_reserve_balance_summary_wrong_inconsistency " + "( row_id," +" reserve_pub," +" exchange_amount," +" auditor_amount," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_balance_summary_wrong_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.h b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.h new file mode 100644 index 000000000..30281f2cf --- /dev/null +++ b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H +#define SRC_PG_INSERT_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_balance_summary_wrong_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc); + +#endif // SRC_PG_INSERT_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_in_inconsistency.c b/src/auditordb/pg_insert_reserve_in_inconsistency.c new file mode 100644 index 000000000..0b69f10e9 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_in_inconsistency.c @@ -0,0 +1,65 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_reserve_in_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveInInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + TALER_PQ_query_param_amount(pg->conn, &dc->amount_exchange_expected), +TALER_PQ_query_param_amount(pg->conn, &dc->amount_wired), +GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +GNUNET_PQ_query_param_int64(&dc->timestamp), +GNUNET_PQ_query_param_auto_from_type(&dc->account), +GNUNET_PQ_query_param_auto_from_type(&dc->diagnostic), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserve_in_inconsistency_insert", + "INSERT INTO auditor_reserve_in_inconsistency " + "( row_id," +" amount_exchange_expected," +" amount_wired," +" reserve_pub," +" timestamp," +" account," +" diagnostic," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_in_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_in_inconsistency.h b/src/auditordb/pg_insert_reserve_in_inconsistency.h new file mode 100644 index 000000000..83856507a --- /dev/null +++ b/src/auditordb/pg_insert_reserve_in_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_RESERVE_IN_INCONSISTENCY_H +#define SRC_PG_INSERT_RESERVE_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveInInconsistency *dc); + +#endif // SRC_PG_INSERT_RESERVE_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c new file mode 100644 index 000000000..6f35e6f77 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c @@ -0,0 +1,61 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_reserve_not_closed_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_not_closed_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +TALER_PQ_query_param_amount(pg->conn, &dc->balance), +GNUNET_PQ_query_param_int64(&dc->expiration_time), +GNUNET_PQ_query_param_auto_from_type(&dc->diagnostic), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserve_not_closed_inconsistency_insert", + "INSERT INTO auditor_reserve_not_closed_inconsistency " + "( row_id," +" reserve_pub," +" balance," +" expiration_time," +" diagnostic," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_not_closed_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_not_closed_inconsistency.h b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.h new file mode 100644 index 000000000..c8464d978 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_RESERVE_NOT_CLOSED_INCONSISTENCY_H +#define SRC_PG_INSERT_RESERVE_NOT_CLOSED_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_not_closed_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc); + +#endif // SRC_PG_INSERT_RESERVE_NOT_CLOSED_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserves.c b/src/auditordb/pg_insert_reserves.c new file mode 100644 index 000000000..3bb73a73e --- /dev/null +++ b/src/auditordb/pg_insert_reserves.c @@ -0,0 +1,74 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_reserves.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserves ( + void *cls, + const struct TALER_AUDITORDB_Reserves *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_int64(&dc->auditor_reserves_rowid), +GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +TALER_PQ_query_param_amount(pg->conn, &dc->reserve_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->reserve_loss), +TALER_PQ_query_param_amount(pg->conn, &dc->withdraw_fee_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->close_fee_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->purse_fee_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->open_fee_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->history_fee_balance), +GNUNET_PQ_query_param_int64(&dc->expiration_date), +GNUNET_PQ_query_param_string(dc->origin_account), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserves_insert", + "INSERT INTO auditor_reserves " + "( auditor_reserves_rowid," +" reserve_pub," +" reserve_balance," +" reserve_loss," +" withdraw_fee_balance," +" close_fee_balance," +" purse_fee_balance," +" open_fee_balance," +" history_fee_balance," +" expiration_date," +" origin_account," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserves_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserves.h b/src/auditordb/pg_insert_reserves.h new file mode 100644 index 000000000..6fce382de --- /dev/null +++ b/src/auditordb/pg_insert_reserves.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_RESERVES_H +#define SRC_PG_INSERT_RESERVES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserves ( + void *cls, + const struct TALER_AUDITORDB_Reserves *dc); + +#endif // SRC_PG_INSERT_RESERVES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_row_minor_inconsistencies.c b/src/auditordb/pg_insert_row_minor_inconsistencies.c new file mode 100644 index 000000000..c60fdc3c5 --- /dev/null +++ b/src/auditordb/pg_insert_row_minor_inconsistencies.c @@ -0,0 +1,57 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_row_minor_inconsistencies.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_row_minor_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_RowMinorInconsistencies *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->row_table), +GNUNET_PQ_query_param_auto_from_type(&dc->diagnostic), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_row_minor_inconsistencies_insert", + "INSERT INTO auditor_row_minor_inconsistencies " + "( row_id," +" row_table," +" diagnostic," +" suppressed" +") VALUES ($1,$2,$3,$4);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_row_minor_inconsistencies_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_row_minor_inconsistencies.h b/src/auditordb/pg_insert_row_minor_inconsistencies.h new file mode 100644 index 000000000..919f5518a --- /dev/null +++ b/src/auditordb/pg_insert_row_minor_inconsistencies.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_ROW_MINOR_INCONSISTENCIES_H +#define SRC_PG_INSERT_ROW_MINOR_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_row_minor_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_RowMinorInconsistencies *dc); + +#endif // SRC_PG_INSERT_ROW_MINOR_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_wire_format_inconsistency.c b/src/auditordb/pg_insert_wire_format_inconsistency.c new file mode 100644 index 000000000..210bcc5e8 --- /dev/null +++ b/src/auditordb/pg_insert_wire_format_inconsistency.c @@ -0,0 +1,59 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_wire_format_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_wire_format_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_WireFormatInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + TALER_PQ_query_param_amount(pg->conn, &dc->amount), +GNUNET_PQ_query_param_int64(&dc->wire_offset), +GNUNET_PQ_query_param_auto_from_type(&dc->diagnostic), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_wire_format_inconsistency_insert", + "INSERT INTO auditor_wire_format_inconsistency " + "( row_id," +" amount," +" wire_offset," +" diagnostic," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_wire_format_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_wire_format_inconsistency.h b/src/auditordb/pg_insert_wire_format_inconsistency.h new file mode 100644 index 000000000..16bfd568e --- /dev/null +++ b/src/auditordb/pg_insert_wire_format_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_WIRE_FORMAT_INCONSISTENCY_H +#define SRC_PG_INSERT_WIRE_FORMAT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_wire_format_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_WireFormatInconsistency *dc); + +#endif // SRC_PG_INSERT_WIRE_FORMAT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_wire_out_inconsistency.c b/src/auditordb/pg_insert_wire_out_inconsistency.c new file mode 100644 index 000000000..ea72a5fc1 --- /dev/null +++ b/src/auditordb/pg_insert_wire_out_inconsistency.c @@ -0,0 +1,59 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_wire_out_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_wire_out_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_WireOutInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->destination_account), +TALER_PQ_query_param_amount(pg->conn, &dc->expected), +TALER_PQ_query_param_amount(pg->conn, &dc->claimed), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_wire_out_inconsistency_insert", + "INSERT INTO auditor_wire_out_inconsistency " + "( row_id," +" destination_account," +" expected," +" claimed," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_wire_out_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_wire_out_inconsistency.h b/src/auditordb/pg_insert_wire_out_inconsistency.h new file mode 100644 index 000000000..ad9728eae --- /dev/null +++ b/src/auditordb/pg_insert_wire_out_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_WIRE_OUT_INCONSISTENCY_H +#define SRC_PG_INSERT_WIRE_OUT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_wire_out_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_WireOutInconsistency *dc); + +#endif // SRC_PG_INSERT_WIRE_OUT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_closure_lags.c b/src/auditordb/pg_update_closure_lags.c new file mode 100644 index 000000000..0702fce7f --- /dev/null +++ b/src/auditordb/pg_update_closure_lags.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_closure_lags.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_closure_lags ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_closure_lags", + "UPDATE auditor_closure_lags SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_closure_lags", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_closure_lags.h b/src/auditordb/pg_update_closure_lags.h new file mode 100644 index 000000000..33581b94c --- /dev/null +++ b/src/auditordb/pg_update_closure_lags.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_CLOSURE_LAGS_H +#define SRC_PG_UPDATE_CLOSURE_LAGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_closure_lags ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_CLOSURE_LAGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_coin_inconsistency.c b/src/auditordb/pg_update_coin_inconsistency.c new file mode 100644 index 000000000..1f1d4e1b8 --- /dev/null +++ b/src/auditordb/pg_update_coin_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_coin_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_coin_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_coin_inconsistency", + "UPDATE auditor_coin_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_coin_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_coin_inconsistency.h b/src/auditordb/pg_update_coin_inconsistency.h new file mode 100644 index 000000000..37a2bfd3a --- /dev/null +++ b/src/auditordb/pg_update_coin_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_COIN_INCONSISTENCY_H +#define SRC_PG_UPDATE_COIN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_coin_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_COIN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c new file mode 100644 index 000000000..8ac44fa45 --- /dev/null +++ b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_denomination_key_validity_withdraw_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_denomination_key_validity_withdraw_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_denomination_key_validity_withdraw_inconsistency", + "UPDATE auditor_denomination_key_validity_withdraw_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_denomination_key_validity_withdraw_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h new file mode 100644 index 000000000..8b29209d9 --- /dev/null +++ b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H +#define SRC_PG_UPDATE_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_denomination_key_validity_withdraw_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denomination_pending.c b/src/auditordb/pg_update_denomination_pending.c new file mode 100644 index 000000000..a530951a3 --- /dev/null +++ b/src/auditordb/pg_update_denomination_pending.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_denomination_pending.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_denomination_pending ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_denomination_pending", + "UPDATE auditor_denomination_pending SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_denomination_pending", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denomination_pending.h b/src/auditordb/pg_update_denomination_pending.h new file mode 100644 index 000000000..773b5bac7 --- /dev/null +++ b/src/auditordb/pg_update_denomination_pending.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_DENOMINATION_PENDING_H +#define SRC_PG_UPDATE_DENOMINATION_PENDING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_denomination_pending ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_DENOMINATION_PENDING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denominations_without_sigs.c b/src/auditordb/pg_update_denominations_without_sigs.c new file mode 100644 index 000000000..009ab059a --- /dev/null +++ b/src/auditordb/pg_update_denominations_without_sigs.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_denominations_without_sigs.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_denominations_without_sigs ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_denominations_without_sigs", + "UPDATE auditor_denominations_without_sigs SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_denominations_without_sigs", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denominations_without_sigs.h b/src/auditordb/pg_update_denominations_without_sigs.h new file mode 100644 index 000000000..9c185b89b --- /dev/null +++ b/src/auditordb/pg_update_denominations_without_sigs.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_DENOMINATIONS_WITHOUT_SIGS_H +#define SRC_PG_UPDATE_DENOMINATIONS_WITHOUT_SIGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_denominations_without_sigs ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_DENOMINATIONS_WITHOUT_SIGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_emergency.c b/src/auditordb/pg_update_emergency.c new file mode 100644 index 000000000..4f9d745d0 --- /dev/null +++ b/src/auditordb/pg_update_emergency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_emergency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_emergency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_emergency", + "UPDATE auditor_emergency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_emergency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_emergency.h b/src/auditordb/pg_update_emergency.h new file mode 100644 index 000000000..5af01fc7d --- /dev/null +++ b/src/auditordb/pg_update_emergency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_EMERGENCY_H +#define SRC_PG_UPDATE_EMERGENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_emergency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_EMERGENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_emergency_by_count.c b/src/auditordb/pg_update_emergency_by_count.c new file mode 100644 index 000000000..39c3bcbdf --- /dev/null +++ b/src/auditordb/pg_update_emergency_by_count.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_emergency_by_count.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_emergency_by_count ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_emergency_by_count", + "UPDATE auditor_emergency_by_count SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_emergency_by_count", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_emergency_by_count.h b/src/auditordb/pg_update_emergency_by_count.h new file mode 100644 index 000000000..1a8c0422b --- /dev/null +++ b/src/auditordb/pg_update_emergency_by_count.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_EMERGENCY_BY_COUNT_H +#define SRC_PG_UPDATE_EMERGENCY_BY_COUNT_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_emergency_by_count ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_EMERGENCY_BY_COUNT_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_exchange_signkeys.c b/src/auditordb/pg_update_exchange_signkeys.c new file mode 100644 index 000000000..4f6a7bfe8 --- /dev/null +++ b/src/auditordb/pg_update_exchange_signkeys.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_exchange_signkeys.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_exchange_signkeys ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_exchange_signkeys", + "UPDATE auditor_exchange_signkeys SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_exchange_signkeys", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_exchange_signkeys.h b/src/auditordb/pg_update_exchange_signkeys.h new file mode 100644 index 000000000..30a7ef1d4 --- /dev/null +++ b/src/auditordb/pg_update_exchange_signkeys.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_EXCHANGE_SIGNKEYS_H +#define SRC_PG_UPDATE_EXCHANGE_SIGNKEYS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_exchange_signkeys ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_EXCHANGE_SIGNKEYS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_historic_denomination_revenue.c b/src/auditordb/pg_update_historic_denomination_revenue.c new file mode 100644 index 000000000..1d812c0c3 --- /dev/null +++ b/src/auditordb/pg_update_historic_denomination_revenue.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_historic_denomination_revenue.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_historic_denomination_revenue ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_historic_denomination_revenue", + "UPDATE auditor_historic_denomination_revenue SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_historic_denomination_revenue", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_historic_denomination_revenue.h b/src/auditordb/pg_update_historic_denomination_revenue.h new file mode 100644 index 000000000..4579205d7 --- /dev/null +++ b/src/auditordb/pg_update_historic_denomination_revenue.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_HISTORIC_DENOMINATION_REVENUE_H +#define SRC_PG_UPDATE_HISTORIC_DENOMINATION_REVENUE_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_historic_denomination_revenue ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_HISTORIC_DENOMINATION_REVENUE_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_historic_reserve_summary.c b/src/auditordb/pg_update_historic_reserve_summary.c new file mode 100644 index 000000000..e9767285e --- /dev/null +++ b/src/auditordb/pg_update_historic_reserve_summary.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_historic_reserve_summary.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_historic_reserve_summary ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_historic_reserve_summary", + "UPDATE auditor_historic_reserve_summary SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_historic_reserve_summary", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_historic_reserve_summary.h b/src/auditordb/pg_update_historic_reserve_summary.h new file mode 100644 index 000000000..047dd57e7 --- /dev/null +++ b/src/auditordb/pg_update_historic_reserve_summary.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_HISTORIC_RESERVE_SUMMARY_H +#define SRC_PG_UPDATE_HISTORIC_RESERVE_SUMMARY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_historic_reserve_summary ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_HISTORIC_RESERVE_SUMMARY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_misattribution_in_inconsistency.c b/src/auditordb/pg_update_misattribution_in_inconsistency.c new file mode 100644 index 000000000..c45907b0f --- /dev/null +++ b/src/auditordb/pg_update_misattribution_in_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_misattribution_in_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_misattribution_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_misattribution_in_inconsistency", + "UPDATE auditor_misattribution_in_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_misattribution_in_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_misattribution_in_inconsistency.h b/src/auditordb/pg_update_misattribution_in_inconsistency.h new file mode 100644 index 000000000..158c8d6b9 --- /dev/null +++ b/src/auditordb/pg_update_misattribution_in_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_MISATTRIBUTION_IN_INCONSISTENCY_H +#define SRC_PG_UPDATE_MISATTRIBUTION_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_misattribution_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_MISATTRIBUTION_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_progress.c b/src/auditordb/pg_update_progress.c new file mode 100644 index 000000000..e079415c8 --- /dev/null +++ b/src/auditordb/pg_update_progress.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_progress.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_progress ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_progress", + "UPDATE auditor_progress SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_progress", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_progress.h b/src/auditordb/pg_update_progress.h new file mode 100644 index 000000000..22023464e --- /dev/null +++ b/src/auditordb/pg_update_progress.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_PROGRESS_H +#define SRC_PG_UPDATE_PROGRESS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_progress ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_PROGRESS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_purse_not_closed_inconsistencies.c b/src/auditordb/pg_update_purse_not_closed_inconsistencies.c new file mode 100644 index 000000000..3ff830204 --- /dev/null +++ b/src/auditordb/pg_update_purse_not_closed_inconsistencies.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_purse_not_closed_inconsistencies.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_purse_not_closed_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_purse_not_closed_inconsistencies", + "UPDATE auditor_purse_not_closed_inconsistencies SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_purse_not_closed_inconsistencies", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_purse_not_closed_inconsistencies.h b/src/auditordb/pg_update_purse_not_closed_inconsistencies.h new file mode 100644 index 000000000..528afd1cc --- /dev/null +++ b/src/auditordb/pg_update_purse_not_closed_inconsistencies.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H +#define SRC_PG_UPDATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_purse_not_closed_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_purses.c b/src/auditordb/pg_update_purses.c new file mode 100644 index 000000000..68bc8a71e --- /dev/null +++ b/src/auditordb/pg_update_purses.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_purses.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_purses ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_purses", + "UPDATE auditor_purses SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_purses", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_purses.h b/src/auditordb/pg_update_purses.h new file mode 100644 index 000000000..52e8a6bcd --- /dev/null +++ b/src/auditordb/pg_update_purses.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_PURSES_H +#define SRC_PG_UPDATE_PURSES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_purses ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_PURSES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_refreshes_hanging.c b/src/auditordb/pg_update_refreshes_hanging.c new file mode 100644 index 000000000..f480c8ecd --- /dev/null +++ b/src/auditordb/pg_update_refreshes_hanging.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_refreshes_hanging.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_refreshes_hanging ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_refreshes_hanging", + "UPDATE auditor_refreshes_hanging SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_refreshes_hanging", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_refreshes_hanging.h b/src/auditordb/pg_update_refreshes_hanging.h new file mode 100644 index 000000000..927ddc551 --- /dev/null +++ b/src/auditordb/pg_update_refreshes_hanging.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_REFRESHES_HANGING_H +#define SRC_PG_UPDATE_REFRESHES_HANGING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_refreshes_hanging ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_REFRESHES_HANGING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c new file mode 100644 index 000000000..b220d8c94 --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserve_balance_insufficient_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_balance_insufficient_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserve_balance_insufficient_inconsistency", + "UPDATE auditor_reserve_balance_insufficient_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserve_balance_insufficient_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h new file mode 100644 index 000000000..4656f083b --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H +#define SRC_PG_UPDATE_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_balance_insufficient_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c new file mode 100644 index 000000000..0ba78a03f --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserve_balance_summary_wrong_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_balance_summary_wrong_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserve_balance_summary_wrong_inconsistency", + "UPDATE auditor_reserve_balance_summary_wrong_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserve_balance_summary_wrong_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h new file mode 100644 index 000000000..846636338 --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H +#define SRC_PG_UPDATE_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_balance_summary_wrong_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_in_inconsistency.c b/src/auditordb/pg_update_reserve_in_inconsistency.c new file mode 100644 index 000000000..d053a1270 --- /dev/null +++ b/src/auditordb/pg_update_reserve_in_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserve_in_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserve_in_inconsistency", + "UPDATE auditor_reserve_in_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserve_in_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_in_inconsistency.h b/src/auditordb/pg_update_reserve_in_inconsistency.h new file mode 100644 index 000000000..a826412e6 --- /dev/null +++ b/src/auditordb/pg_update_reserve_in_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVE_IN_INCONSISTENCY_H +#define SRC_PG_UPDATE_RESERVE_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVE_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_not_closed_inconsistency.c b/src/auditordb/pg_update_reserve_not_closed_inconsistency.c new file mode 100644 index 000000000..8951e04db --- /dev/null +++ b/src/auditordb/pg_update_reserve_not_closed_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserve_not_closed_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_not_closed_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserve_not_closed_inconsistency", + "UPDATE auditor_reserve_not_closed_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserve_not_closed_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_not_closed_inconsistency.h b/src/auditordb/pg_update_reserve_not_closed_inconsistency.h new file mode 100644 index 000000000..b7f73f369 --- /dev/null +++ b/src/auditordb/pg_update_reserve_not_closed_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVE_NOT_CLOSED_INCONSISTENCY_H +#define SRC_PG_UPDATE_RESERVE_NOT_CLOSED_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_not_closed_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVE_NOT_CLOSED_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserves.c b/src/auditordb/pg_update_reserves.c new file mode 100644 index 000000000..ed706d0c5 --- /dev/null +++ b/src/auditordb/pg_update_reserves.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserves.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserves ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserves", + "UPDATE auditor_reserves SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserves", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserves.h b/src/auditordb/pg_update_reserves.h new file mode 100644 index 000000000..d2316ab5d --- /dev/null +++ b/src/auditordb/pg_update_reserves.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVES_H +#define SRC_PG_UPDATE_RESERVES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserves ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_row_inconsistency.c b/src/auditordb/pg_update_row_inconsistency.c new file mode 100644 index 000000000..3258e0f97 --- /dev/null +++ b/src/auditordb/pg_update_row_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_row_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_row_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_row_inconsistency", + "UPDATE auditor_row_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_row_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_row_inconsistency.h b/src/auditordb/pg_update_row_inconsistency.h new file mode 100644 index 000000000..42e9e8e07 --- /dev/null +++ b/src/auditordb/pg_update_row_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_ROW_INCONSISTENCY_H +#define SRC_PG_UPDATE_ROW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_row_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_ROW_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_row_minor_inconsistencies.c b/src/auditordb/pg_update_row_minor_inconsistencies.c new file mode 100644 index 000000000..8d93558ff --- /dev/null +++ b/src/auditordb/pg_update_row_minor_inconsistencies.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_row_minor_inconsistencies.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_row_minor_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_row_minor_inconsistencies", + "UPDATE auditor_row_minor_inconsistencies SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_row_minor_inconsistencies", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_row_minor_inconsistencies.h b/src/auditordb/pg_update_row_minor_inconsistencies.h new file mode 100644 index 000000000..4c16bdfbf --- /dev/null +++ b/src/auditordb/pg_update_row_minor_inconsistencies.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_ROW_MINOR_INCONSISTENCIES_H +#define SRC_PG_UPDATE_ROW_MINOR_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_row_minor_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_ROW_MINOR_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_wire_format_inconsistency.c b/src/auditordb/pg_update_wire_format_inconsistency.c new file mode 100644 index 000000000..381e35e77 --- /dev/null +++ b/src/auditordb/pg_update_wire_format_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_wire_format_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_wire_format_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_wire_format_inconsistency", + "UPDATE auditor_wire_format_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_wire_format_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_wire_format_inconsistency.h b/src/auditordb/pg_update_wire_format_inconsistency.h new file mode 100644 index 000000000..ddd306fdb --- /dev/null +++ b/src/auditordb/pg_update_wire_format_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_WIRE_FORMAT_INCONSISTENCY_H +#define SRC_PG_UPDATE_WIRE_FORMAT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_wire_format_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_WIRE_FORMAT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_wire_out_inconsistency.c b/src/auditordb/pg_update_wire_out_inconsistency.c new file mode 100644 index 000000000..9d2349ccb --- /dev/null +++ b/src/auditordb/pg_update_wire_out_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_wire_out_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_wire_out_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_wire_out_inconsistency", + "UPDATE auditor_wire_out_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_wire_out_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_wire_out_inconsistency.h b/src/auditordb/pg_update_wire_out_inconsistency.h new file mode 100644 index 000000000..d042e74bb --- /dev/null +++ b/src/auditordb/pg_update_wire_out_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_WIRE_OUT_INCONSISTENCY_H +#define SRC_PG_UPDATE_WIRE_OUT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_wire_out_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_WIRE_OUT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 5060a016c..9eb5df7b4 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -59,9 +59,17 @@ #include "pg_get_amount_arithmetic_inconsistency.h" #include "pg_get_coin_inconsistency.h" #include "pg_get_row_inconsistency.h" - - -// MARK: CRUD +#include "pg_update_emergency_by_count.h" +#include "pg_update_row_inconsistency.h" +#include "pg_update_purse_not_closed_inconsistencies.h" +#include "pg_update_reserve_balance_insufficient_inconsistency.h" +#include "pg_update_coin_inconsistency.h" +#include "pg_update_progress.h" +#include "pg_update_denomination_key_validity_withdraw_inconsistency.h" +#include "pg_update_refreshes_hanging.h" +#include "pg_update_emergency.h" +#include "pg_update_closure_lags.h" +#include "pg_update_row_minor_inconsistencies.h" #include "pg_del_amount_arithmetic_inconsistency.h" #include "pg_del_coin_inconsistency.h" @@ -83,9 +91,7 @@ #include "pg_del_emergency.h" #include "pg_insert_emergency.h" -// #include "pg_get_auditor_progress.h" #include "pg_del_auditor_progress.h" -// #include "pg_insert_auditor_progress.h" #include "pg_get_bad_sig_losses.h" #include "pg_del_bad_sig_losses.h" @@ -112,6 +118,76 @@ #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" + +#include "pg_get_reserves.h" +#include "pg_del_reserves.h" +#include "pg_insert_reserves.h" +#include "pg_update_reserves.h" + +#include "pg_get_purses.h" +#include "pg_del_purses.h" +#include "pg_insert_purses.h" +#include "pg_update_purses.h" + +#include "pg_get_historic_denomination_revenue.h" +#include "pg_del_historic_denomination_revenue.h" +#include "pg_insert_historic_denomination_revenue.h" +#include "pg_update_historic_denomination_revenue.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_historic_reserve_summary.h" +#include "pg_del_historic_reserve_summary.h" +#include "pg_insert_historic_reserve_summary.h" +#include "pg_update_historic_reserve_summary.h" + +#include "pg_get_exchange_signkeys.h" +#include "pg_del_exchange_signkeys.h" +#include "pg_insert_exchange_signkeys.h" +#include "pg_update_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_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" + #define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", \ __VA_ARGS__) @@ -660,6 +736,100 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->insert_refreshes_hanging = &TAH_PG_insert_refreshes_hanging; plugin->get_refreshes_hanging = &TAH_PG_get_refreshes_hanging; + plugin->update_emergency_by_count = &TAH_PG_update_emergency_by_count; + plugin->update_row_inconsistency = &TAH_PG_update_row_inconsistency; + plugin->update_purse_not_closed_inconsistencies = &TAH_PG_update_purse_not_closed_inconsistencies; + plugin->update_reserve_balance_insufficient_inconsistency = &TAH_PG_update_reserve_balance_insufficient_inconsistency; + plugin->update_coin_inconsistency = &TAH_PG_update_coin_inconsistency; + plugin->update_progress = &TAH_PG_update_progress; + plugin->update_denomination_key_validity_withdraw_inconsistency = &TAH_PG_update_denomination_key_validity_withdraw_inconsistency; + plugin->update_refreshes_hanging = &TAH_PG_update_refreshes_hanging; + plugin->update_emergency = &TAH_PG_update_emergency; + 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; + plugin->update_reserve_in_inconsistency = &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 = &TAH_PG_get_reserve_not_closed_inconsistency; + plugin->update_reserve_not_closed_inconsistency = &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 = &TAH_PG_get_denominations_without_sigs; + plugin->update_denominations_without_sigs = &TAH_PG_update_denominations_without_sigs; + + + 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 = &TAH_PG_get_misattribution_in_inconsistency; + plugin->update_misattribution_in_inconsistency = &TAH_PG_update_misattribution_in_inconsistency; + + + plugin->delete_reserves = &TAH_PG_del_reserves; + plugin->insert_reserves = &TAH_PG_insert_reserves; + plugin->get_reserves = &TAH_PG_get_reserves; + plugin->update_reserves = &TAH_PG_update_reserves; + + + plugin->delete_purses = &TAH_PG_del_purses; + plugin->insert_purses = &TAH_PG_insert_purses; + plugin->get_purses = &TAH_PG_get_purses; + plugin->update_purses = &TAH_PG_update_purses; + + + plugin->delete_historic_denomination_revenue = &TAH_PG_del_historic_denomination_revenue; + plugin->insert_historic_denomination_revenue = &TAH_PG_insert_historic_denomination_revenue; + plugin->get_historic_denomination_revenue = &TAH_PG_get_historic_denomination_revenue; + plugin->update_historic_denomination_revenue = &TAH_PG_update_historic_denomination_revenue; + + + 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->delete_historic_reserve_summary = &TAH_PG_del_historic_reserve_summary; + plugin->insert_historic_reserve_summary = &TAH_PG_insert_historic_reserve_summary; + plugin->get_historic_reserve_summary = &TAH_PG_get_historic_reserve_summary; + plugin->update_historic_reserve_summary = &TAH_PG_update_historic_reserve_summary; + + + plugin->delete_exchange_signkeys = &TAH_PG_del_exchange_signkeys; + plugin->insert_exchange_signkeys = &TAH_PG_insert_exchange_signkeys; + plugin->get_exchange_signkeys = &TAH_PG_get_exchange_signkeys; + plugin->update_exchange_signkeys = &TAH_PG_update_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; + plugin->update_wire_format_inconsistency = &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->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 = &TAH_PG_get_reserve_balance_summary_wrong_inconsistency; + plugin->update_reserve_balance_summary_wrong_inconsistency = &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; return plugin; } |