diff options
Diffstat (limited to 'src/auditordb')
265 files changed, 13709 insertions, 84 deletions
diff --git a/src/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql b/src/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql index 19dfa682c..007f69ea1 100644 --- a/src/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql +++ b/src/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql @@ -14,13 +14,18 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
--
+-- TODO: The constraints of operation are just for testing
+
CREATE TABLE auditor_amount_arithmetic_inconsistency
(
- row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- operation BYTEA,
+ row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE,
+ -- TODO: correct constraintcheck, currently wrong
+ --operation BYTEA NOT NULL CHECK (LENGTH(operation)=16),
+ operation TEXT NOT NULL PRIMARY KEY,
exchange_amount taler_amount,
auditor_amount taler_amount,
- profitable BOOLEAN
+ profitable BOOLEAN,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_amount_arithmetic_inconsistency
IS 'Report a (serious) inconsistency in the exchange''s database with respect to calculations involving amounts';
diff --git a/src/auditordb/0002-auditor_bad_sig_losses.sql b/src/auditordb/0002-auditor_bad_sig_losses.sql index ac17a5120..a3b9b73dc 100644 --- a/src/auditordb/0002-auditor_bad_sig_losses.sql +++ b/src/auditordb/0002-auditor_bad_sig_losses.sql @@ -17,10 +17,12 @@ 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 BYTEA,
+ row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE,
+ operation TEXT,
loss taler_amount,
- operation_specific_pub BYTEA
+ operation_specific_pub BYTEA NOT NULL CHECK (LENGTH(operation_specific_pub)=32),
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE,
+ PRIMARY KEY (operation, operation_specific_pub)
);
COMMENT ON TABLE auditor_bad_sig_losses
IS 'Report a (serious) inconsistency with losses due to bad signatures';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_balances.sql b/src/auditordb/0002-auditor_balances.sql index 8014b9c41..78ff8a414 100644 --- a/src/auditordb/0002-auditor_balances.sql +++ b/src/auditordb/0002-auditor_balances.sql @@ -16,8 +16,10 @@ CREATE TABLE IF NOT EXISTS auditor_balances ( - balance_key TEXT PRIMARY KEY NOT NULL - ,balance_value taler_amount + row_id BIGINT GENERATED BY DEFAULT AS IDENTITY, + balance_key TEXT PRIMARY KEY NOT NULL, + balance_value taler_amount + ); COMMENT ON TABLE auditor_balances diff --git a/src/auditordb/0002-auditor_closure_lags.sql b/src/auditordb/0002-auditor_closure_lags.sql index 8473b25f9..9556da788 100644 --- a/src/auditordb/0002-auditor_closure_lags.sql +++ b/src/auditordb/0002-auditor_closure_lags.sql @@ -20,8 +20,9 @@ CREATE TABLE IF NOT EXISTS auditor_closure_lags row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
amount taler_amount,
deadline BIGINT,
- wtid integer,
- account BYTEA
+ wtid BYTEA,
+ account BYTEA,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_closure_lags
IS 'Report closure lags.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_coin_inconsistency.sql b/src/auditordb/0002-auditor_coin_inconsistency.sql index 91f954a68..2e4b38356 100644 --- a/src/auditordb/0002-auditor_coin_inconsistency.sql +++ b/src/auditordb/0002-auditor_coin_inconsistency.sql @@ -17,12 +17,14 @@ SET search_path TO auditor;
CREATE TABLE IF NOT EXISTS auditor_coin_inconsistency
(
- row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- operation BYTEA,
+ row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE,
+ operation TEXT NOT NULL,
exchange_amount taler_amount,
auditor_amount taler_amount,
- coin_pub BYTEA,
- profitable BOOLEAN
+ coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32),
+ profitable BOOLEAN,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE,
+ PRIMARY KEY (operation, coin_pub)
);
COMMENT ON TABLE auditor_coin_inconsistency
IS 'Report a (serious) inconsistency in the exchange''s database with respect to calculations involving amounts';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql b/src/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql index fd18f35fb..7bf4539ab 100644 --- a/src/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql +++ b/src/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql @@ -20,7 +20,8 @@ CREATE TABLE IF NOT EXISTS auditor_denomination_key_validity_withdraw_inconsiste row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
execution_date BIGINT,
reserve_pub BYTEA,
- denompub_h BYTEA
+ denompub_h BYTEA,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_denomination_key_validity_withdraw_inconsistency
IS 'Report a (serious) denomination key validity withdraw inconsistency in the exchange''s database';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_denomination_pending.sql b/src/auditordb/0002-auditor_denomination_pending.sql index f9ba535b4..00ed18145 100644 --- a/src/auditordb/0002-auditor_denomination_pending.sql +++ b/src/auditordb/0002-auditor_denomination_pending.sql @@ -15,10 +15,11 @@ -- CREATE TABLE auditor_denomination_pending - (denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64) + (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, + denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64) ,denom_balance taler_amount NOT NULL ,denom_loss taler_amount NOT NULL - ,num_issued INT8 NOT NULL + ,num_issued BIGINT NOT NULL ,denom_risk taler_amount NOT NULL ,recoup_loss taler_amount NOT NULL ); diff --git a/src/auditordb/0002-auditor_denominations_without_sigs.sql b/src/auditordb/0002-auditor_denominations_without_sigs.sql index 86c83e94f..4143beac4 100644 --- a/src/auditordb/0002-auditor_denominations_without_sigs.sql +++ b/src/auditordb/0002-auditor_denominations_without_sigs.sql @@ -17,11 +17,12 @@ SET search_path TO auditor;
CREATE TABLE IF NOT EXISTS auditor_denominations_without_sigs
(
- row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- denompub_h BYTEA,
+ row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE,
+ denompub_h BYTEA PRIMARY KEY,
value taler_amount,
start_time BIGINT,
- end_time BIGINT
+ end_time BIGINT,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_denominations_without_sigs
IS 'Report encountered denomination that auditor is not auditing.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_deposit_confirmations.sql b/src/auditordb/0002-auditor_deposit_confirmations.sql index 1b7fec185..7e47b4fd1 100644 --- a/src/auditordb/0002-auditor_deposit_confirmations.sql +++ b/src/auditordb/0002-auditor_deposit_confirmations.sql @@ -19,9 +19,9 @@ CREATE TABLE auditor_deposit_confirmations ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64) ,h_policy BYTEA NOT NULL CHECK (LENGTH(h_policy)=64) ,h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64) - ,exchange_timestamp INT8 NOT NULL - ,refund_deadline INT8 NOT NULL - ,wire_deadline INT8 NOT NULL + ,exchange_timestamp BIGINT NOT NULL + ,refund_deadline BIGINT NOT NULL + ,wire_deadline BIGINT NOT NULL ,total_without_fee taler_amount NOT NULL ,coin_pubs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_pubs)>0) ,coin_sigs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_sigs)=CARDINALITY(coin_pubs)) diff --git a/src/auditordb/0002-auditor_emergency.sql b/src/auditordb/0002-auditor_emergency.sql index 2bb13d7e5..b63b5fd00 100644 --- a/src/auditordb/0002-auditor_emergency.sql +++ b/src/auditordb/0002-auditor_emergency.sql @@ -1,3 +1,5 @@ +
+
--
-- This file is part of TALER
-- Copyright (C) 2014--2024 Taler Systems SA
@@ -18,7 +20,7 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_emergency
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- denompub_h BYTEA,
+ denompub_h BYTEA CHECK (LENGTH(denompub_h)=64),
denom_risk taler_amount,
denom_loss taler_amount,
deposit_start BIGINT,
diff --git a/src/auditordb/0002-auditor_emergency_by_count.sql b/src/auditordb/0002-auditor_emergency_by_count.sql index 4daa994a7..c217a61d4 100644 --- a/src/auditordb/0002-auditor_emergency_by_count.sql +++ b/src/auditordb/0002-auditor_emergency_by_count.sql @@ -19,12 +19,13 @@ CREATE TABLE IF NOT EXISTS auditor_emergency_by_count (
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
denompub_h BYTEA,
- num_issued integer,
- num_known integer,
+ num_issued BIGINT,
+ num_known BIGINT,
risk taler_amount,
start BIGINT,
deposit_end BIGINT,
- value taler_amount
+ value taler_amount,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_emergency_by_count
IS 'Report an emergency denomination.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_exchange_signkeys.sql b/src/auditordb/0002-auditor_exchange_signkeys.sql index 64349a2ff..289b60ed9 100644 --- a/src/auditordb/0002-auditor_exchange_signkeys.sql +++ b/src/auditordb/0002-auditor_exchange_signkeys.sql @@ -15,11 +15,13 @@ -- CREATE TABLE auditor_exchange_signkeys - (exchange_pub BYTEA PRIMARY KEY CHECK (LENGTH(exchange_pub)=32) + (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, + exchange_pub BYTEA PRIMARY KEY CHECK (LENGTH(exchange_pub)=32) ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64) - ,ep_valid_from INT8 NOT NULL - ,ep_expire_sign INT8 NOT NULL - ,ep_expire_legal INT8 NOT NULL + ,ep_valid_from BIGINT NOT NULL + ,ep_expire_sign BIGINT NOT NULL + ,ep_expire_legal BIGINT NOT NULL, + suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_exchange_signkeys IS 'list of the online signing keys of exchanges we are auditing'; diff --git a/src/auditordb/0002-auditor_fee_time_inconsistency.sql b/src/auditordb/0002-auditor_fee_time_inconsistency.sql index b89cc59c7..317c487a6 100644 --- a/src/auditordb/0002-auditor_fee_time_inconsistency.sql +++ b/src/auditordb/0002-auditor_fee_time_inconsistency.sql @@ -20,7 +20,8 @@ CREATE TABLE IF NOT EXISTS auditor_fee_time_inconsistency row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
type BYTEA,
time BIGINT,
- diagnostic BYTEA
+ diagnostic BYTEA,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_fee_time_inconsistency
IS 'Report a (serious) fee time inconsistency in the exchange''s database';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_historic_denomination_revenue.sql b/src/auditordb/0002-auditor_historic_denomination_revenue.sql index bf7e4c07e..d711ac7fc 100644 --- a/src/auditordb/0002-auditor_historic_denomination_revenue.sql +++ b/src/auditordb/0002-auditor_historic_denomination_revenue.sql @@ -15,8 +15,9 @@ -- CREATE TABLE auditor_historic_denomination_revenue - (denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64) - ,revenue_timestamp INT8 NOT NULL + (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, + denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64) + ,revenue_timestamp BIGINT NOT NULL ,revenue_balance taler_amount NOT NULL ,loss_balance taler_amount NOT NULL ); diff --git a/src/auditordb/0002-auditor_historic_reserve_summary.sql b/src/auditordb/0002-auditor_historic_reserve_summary.sql index 819c4e160..0dc68d594 100644 --- a/src/auditordb/0002-auditor_historic_reserve_summary.sql +++ b/src/auditordb/0002-auditor_historic_reserve_summary.sql @@ -16,9 +16,14 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary - (start_date INT8 PRIMARY KEY - ,end_date INT8 NOT NULL - ,reserve_profits taler_amount NOT NULL + ( + row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, + start_date BIGINT, + end_date BIGINT NOT NULL, + reserve_profits taler_amount NOT NULL, + PRIMARY KEY (start_date, end_date) + + ); COMMENT ON TABLE auditor_historic_reserve_summary IS 'historic profits from reserves; we eventually GC auditor_historic_reserve_revenue, and then store the totals in here (by time intervals).'; diff --git a/src/auditordb/0002-auditor_misattribution_in_inconsistency.sql b/src/auditordb/0002-auditor_misattribution_in_inconsistency.sql index f786d0fdf..23bd90887 100644 --- a/src/auditordb/0002-auditor_misattribution_in_inconsistency.sql +++ b/src/auditordb/0002-auditor_misattribution_in_inconsistency.sql @@ -20,7 +20,8 @@ CREATE TABLE IF NOT EXISTS auditor_misattribution_in_inconsistency row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
amount taler_amount,
bank_row BIGINT,
- reserve_pub BYTEA
+ reserve_pub BYTEA,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_misattribution_in_inconsistency
IS 'Report wire transfer that was smaller than it should have been.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_pending_deposits.sql b/src/auditordb/0002-auditor_pending_deposits.sql new file mode 100644 index 000000000..5cef7bf8c --- /dev/null +++ b/src/auditordb/0002-auditor_pending_deposits.sql @@ -0,0 +1,25 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2014--2022 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/> +-- + +CREATE TABLE IF NOT EXISTS auditor_pending_deposits +( + row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, + total_amount taler_amount, + wire_target_h_payto BYTEA, + batch_deposit_serial_id BIGINT, + deadline BIGINT, + suppressed BOOLEAN NOT NULL DEFAULT FALSE +); diff --git a/src/auditordb/0002-auditor_progress.sql b/src/auditordb/0002-auditor_progress.sql index 288a08ae9..15d1fe2e4 100644 --- a/src/auditordb/0002-auditor_progress.sql +++ b/src/auditordb/0002-auditor_progress.sql @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS auditor_progress (progress_key TEXT PRIMARY KEY NOT NULL - ,progress_offset INT8 NOT NULL + ,progress_offset BIGINT NOT NULL ); COMMENT ON TABLE auditor_progress IS 'Information about to the point until which the audit has progressed. Used for SELECTing the statements to process.'; diff --git a/src/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql b/src/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql index 5ffb6e85a..80bc1e1f4 100644 --- a/src/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql +++ b/src/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql @@ -17,10 +17,11 @@ SET search_path TO auditor;
CREATE TABLE IF NOT EXISTS auditor_purse_not_closed_inconsistencies
(
- row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- purse_pub BYTEA,
+ row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE ,
+ purse_pub BYTEA PRIMARY KEY,
amount taler_amount,
- expiration_date BIGINT
+ expiration_date BIGINT,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_purse_not_closed_inconsistencies
IS 'Report expired purses';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_purses.sql b/src/auditordb/0002-auditor_purses.sql index 86b6494d1..9cfe2b095 100644 --- a/src/auditordb/0002-auditor_purses.sql +++ b/src/auditordb/0002-auditor_purses.sql @@ -19,7 +19,7 @@ CREATE TABLE auditor_purses ,purse_pub BYTEA PRIMARY KEY CHECK(LENGTH(purse_pub)=32) ,balance taler_amount NOT NULL DEFAULT(0,0) ,target taler_amount NOT NULL - ,expiration_date INT8 NOT NULL + ,expiration_date BIGINT NOT NULL ); COMMENT ON TABLE auditor_purses IS 'all of the purses and their respective balances that the auditor is aware of'; diff --git a/src/auditordb/0002-auditor_refreshes_hanging.sql b/src/auditordb/0002-auditor_refreshes_hanging.sql index 5544bc0d8..9d0152b7f 100644 --- a/src/auditordb/0002-auditor_refreshes_hanging.sql +++ b/src/auditordb/0002-auditor_refreshes_hanging.sql @@ -17,9 +17,10 @@ SET search_path TO auditor;
CREATE TABLE IF NOT EXISTS auditor_refreshes_hanging
(
- row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
+ row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE,
amount taler_amount,
- coin_pub BYTEA
+ coin_pub BYTEA PRIMARY KEY,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_refreshes_hanging
IS 'Report a hanging refresh.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql b/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql index bbc0c8118..e80a7bec8 100644 --- a/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql +++ b/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql @@ -18,9 +18,10 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_reserve_balance_insufficient_inconsistency
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- reserve_pub BYTEA,
+ reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32),
inconsistency_gain BOOLEAN,
- inconsistency_amount taler_amount
+ inconsistency_amount taler_amount,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_reserve_balance_insufficient_inconsistency
IS 'Report a (serious) balance insufficiency in the exchange''s database';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql b/src/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql index 26d872132..380d80ae8 100644 --- a/src/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql +++ b/src/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql @@ -20,7 +20,8 @@ CREATE TABLE IF NOT EXISTS auditor_reserve_balance_summary_wrong_inconsistency row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
reserve_pub BYTEA,
exchange_amount taler_amount,
- auditor_amount taler_amount
+ auditor_amount taler_amount,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_reserve_balance_summary_wrong_inconsistency
IS 'Report a (serious) reserve balance insufficiency.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_reserve_in_inconsistency.sql b/src/auditordb/0002-auditor_reserve_in_inconsistency.sql index bb90c4018..1a9e1c7f2 100644 --- a/src/auditordb/0002-auditor_reserve_in_inconsistency.sql +++ b/src/auditordb/0002-auditor_reserve_in_inconsistency.sql @@ -23,7 +23,8 @@ CREATE TABLE IF NOT EXISTS auditor_reserve_in_inconsistency reserve_pub BYTEA,
timestamp BIGINT,
account BYTEA,
- diagnostic BYTEA
+ diagnostic BYTEA,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_reserve_in_inconsistency
IS 'Report an incoming wire transfer claimed by exchange not found.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql b/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql index 1147b4ae8..d09a73225 100644 --- a/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql +++ b/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql @@ -17,11 +17,12 @@ SET search_path TO auditor;
CREATE TABLE IF NOT EXISTS auditor_reserve_not_closed_inconsistency
(
- row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- reserve_pub BYTEA,
+ row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE ,
+ reserve_pub BYTEA PRIMARY KEY,
balance taler_amount,
expiration_time BIGINT,
- diagnostic BYTEA
+ diagnostic BYTEA,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_reserve_not_closed_inconsistency
IS 'Report a (serious) reserve balance insufficiency.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_reserves.sql b/src/auditordb/0002-auditor_reserves.sql index 808524b28..f50653512 100644 --- a/src/auditordb/0002-auditor_reserves.sql +++ b/src/auditordb/0002-auditor_reserves.sql @@ -24,7 +24,7 @@ CREATE TABLE auditor_reserves ,purse_fee_balance taler_amount NOT NULL ,open_fee_balance taler_amount NOT NULL ,history_fee_balance taler_amount NOT NULL - ,expiration_date INT8 NOT NULL + ,expiration_date BIGINT NOT NULL ,origin_account TEXT ); COMMENT ON TABLE auditor_reserves diff --git a/src/auditordb/0002-auditor_row_inconsistency.sql b/src/auditordb/0002-auditor_row_inconsistency.sql index ece2e5661..0b1d74a85 100644 --- a/src/auditordb/0002-auditor_row_inconsistency.sql +++ b/src/auditordb/0002-auditor_row_inconsistency.sql @@ -18,8 +18,9 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_row_inconsistency
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- table BYTEA,
- diagnostic BYTEA
+ row_table TEXT,
+ diagnostic TEXT,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_row_inconsistency
IS 'Report a (serious) row inconsistency in the exchange''s database';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql index 7836037c7..5e9116e80 100644 --- a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql +++ b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql @@ -18,8 +18,9 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_row_minor_inconsistency
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- table BYTEA,
- diagnostic BYTEA
+ row_table BYTEA,
+ diagnostic BYTEA,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_row_minor_inconsistency
IS 'Report a (serious) row inconsistency in the exchange''s database.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_wire_format_inconsistency.sql b/src/auditordb/0002-auditor_wire_format_inconsistency.sql index 1bc9af89d..cbb6bcce7 100644 --- a/src/auditordb/0002-auditor_wire_format_inconsistency.sql +++ b/src/auditordb/0002-auditor_wire_format_inconsistency.sql @@ -20,7 +20,8 @@ CREATE TABLE IF NOT EXISTS auditor_wire_format_inconsistency row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
amount taler_amount,
wire_offset BIGINT,
- diagnostic BYTEA
+ diagnostic BYTEA,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_wire_format_inconsistency
IS 'Report a (serious) format inconsistency.';
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_wire_out_inconsistency.sql b/src/auditordb/0002-auditor_wire_out_inconsistency.sql index 6a49c24a0..5ee3211ab 100644 --- a/src/auditordb/0002-auditor_wire_out_inconsistency.sql +++ b/src/auditordb/0002-auditor_wire_out_inconsistency.sql @@ -18,9 +18,10 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_wire_out_inconsistency
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- destination_account BYTEA,
+ destination_account TEXT NOT NULL,
expected taler_amount,
- claimed taler_amount
+ claimed taler_amount,
+ suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_wire_out_inconsistency
IS 'Report a (serious) wire inconsistency in the exchange''s database';
\ No newline at end of file diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am index c0282e9c9..265ec52a5 100644 --- a/src/auditordb/Makefile.am +++ b/src/auditordb/Makefile.am @@ -56,6 +56,8 @@ plugin_LTLIBRARIES = \ libtaler_plugin_auditordb_postgres.la endif +# MARK: CRUD + libtaler_plugin_auditordb_postgres_la_SOURCES = \ plugin_auditordb_postgres.c pg_helper.h \ pg_delete_deposit_confirmations.c pg_delete_deposit_confirmations.h \ @@ -74,8 +76,6 @@ libtaler_plugin_auditordb_postgres_la_SOURCES = \ pg_insert_balance.c pg_insert_balance.h \ pg_insert_denomination_balance.c pg_insert_denomination_balance.h \ pg_insert_deposit_confirmation.c pg_insert_deposit_confirmation.h \ - pg_insert_exchange_signkey.c pg_insert_exchange_signkey.h \ - pg_insert_historic_denom_revenue.c pg_insert_historic_denom_revenue.h \ pg_insert_historic_reserve_revenue.c pg_insert_historic_reserve_revenue.h \ pg_insert_pending_deposit.c pg_insert_pending_deposit.h \ pg_insert_purse_info.c pg_insert_purse_info.h \ @@ -89,7 +89,118 @@ libtaler_plugin_auditordb_postgres_la_SOURCES = \ pg_update_denomination_balance.c pg_update_denomination_balance.h \ pg_update_purse_info.c pg_update_purse_info.h \ pg_update_reserve_info.c pg_update_reserve_info.h \ - pg_update_wire_fee_summary.c pg_update_wire_fee_summary.h + pg_update_wire_fee_summary.c pg_update_wire_fee_summary.h \ + pg_get_amount_arithmetic_inconsistency.c pg_get_amount_arithmetic_inconsistency.h \ + pg_get_coin_inconsistency.c pg_get_coin_inconsistency.h \ + pg_get_row_inconsistency.c pg_get_row_inconsistency.h \ + pg_insert_amount_arithmetic_inconsistency.c pg_insert_amount_arithmetic_inconsistency.h \ + pg_insert_coin_inconsistency.c pg_insert_coin_inconsistency.h \ + pg_insert_row_inconsistency.c pg_insert_row_inconsistency.h \ + pg_del_amount_arithmetic_inconsistency.c pg_del_amount_arithmetic_inconsistency.h \ + pg_del_coin_inconsistency.c pg_del_coin_inconsistency.h \ + pg_del_row_inconsistency.c pg_del_row_inconsistency.h \ + pg_del_emergency.c pg_del_emergency.h \ + pg_insert_emergency.c pg_insert_emergency.h \ + pg_get_emergency.c pg_get_emergency.h \ + pg_del_emergency_by_count.c pg_del_emergency_by_count.h \ + pg_insert_emergency_by_count.c pg_insert_emergency_by_count.h \ + pg_get_emergency_by_count.c pg_get_emergency_by_count.h \ + pg_del_denomination_key_validity_withdraw_inconsistency.c pg_del_denomination_key_validity_withdraw_inconsistency.h \ + pg_insert_denomination_key_validity_withdraw_inconsistency.c pg_insert_denomination_key_validity_withdraw_inconsistency.h \ + pg_get_denomination_key_validity_withdraw_inconsistency.c pg_get_denomination_key_validity_withdraw_inconsistency.h \ + pg_del_purse_not_closed_inconsistencies.c pg_del_purse_not_closed_inconsistencies.h \ + pg_insert_purse_not_closed_inconsistencies.c pg_insert_purse_not_closed_inconsistencies.h \ + pg_get_purse_not_closed_inconsistencies.c pg_get_purse_not_closed_inconsistencies.h \ + pg_del_reserve_balance_insufficient_inconsistency.c pg_del_reserve_balance_insufficient_inconsistency.h \ +pg_insert_reserve_balance_insufficient_inconsistency.c pg_insert_reserve_balance_insufficient_inconsistency.h \ +pg_get_reserve_balance_insufficient_inconsistency.c pg_get_reserve_balance_insufficient_inconsistency.h \ +pg_del_bad_sig_losses.c pg_del_bad_sig_losses.h \ +pg_insert_bad_sig_losses.c pg_insert_bad_sig_losses.h \ +pg_get_bad_sig_losses.c pg_get_bad_sig_losses.h \ +pg_update_bad_sig_losses.c pg_update_bad_sig_losses.h \ +pg_del_auditor_closure_lags.c pg_del_auditor_closure_lags.h \ +pg_insert_auditor_closure_lags.c pg_insert_auditor_closure_lags.h \ +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 \ +pg_get_fee_time_inconsistency.c pg_get_fee_time_inconsistency.h \ +pg_del_fee_time_inconsistency.c pg_del_fee_time_inconsistency.h \ +pg_insert_fee_time_inconsistency.c pg_insert_fee_time_inconsistency.h \ +pg_update_fee_time_inconsistency.c pg_update_fee_time_inconsistency.h \ +pg_get_balances.c pg_get_balances.h \ +pg_del_balances.c pg_del_balances.h \ +pg_insert_balances.c pg_insert_balances.h \ +pg_update_deposit_confirmations.c pg_update_deposit_confirmations.h \ +pg_update_amount_arithmetic_inconsistency.c pg_update_amount_arithmetic_inconsistency.h \ +pg_update_balances.c pg_update_balances.h libtaler_plugin_auditordb_postgres_la_LDFLAGS = \ $(TALER_PLUGIN_LDFLAGS) libtaler_plugin_auditordb_postgres_la_LIBADD = \ diff --git a/src/auditordb/auditor-0002.sql.in b/src/auditordb/auditor-0002.sql.in index ad459b472..9d76eb307 100644 --- a/src/auditordb/auditor-0002.sql.in +++ b/src/auditordb/auditor-0002.sql.in @@ -33,14 +33,34 @@ EXCEPTION END $$; #include "0002-auditor_amount_arithmetic_inconsistency.sql" +#include "0002-auditor_bad_sig_losses.sql" #include "0002-auditor_balances.sql" +#include "0002-auditor_closure_lags.sql" +#include "0002-auditor_coin_inconsistency.sql" +#include "0002-auditor_denomination_key_validity_withdraw_inconsistency.sql" #include "0002-auditor_denomination_pending.sql" +#include "0002-auditor_denominations_without_sigs.sql" +#include "0002-auditor_deposit_confirmations.sql" +#include "0002-auditor_emergency.sql" +#include "0002-auditor_emergency_by_count.sql" #include "0002-auditor_exchange_signkeys.sql" +#include "0002-auditor_fee_time_inconsistency.sql" #include "0002-auditor_historic_denomination_revenue.sql" #include "0002-auditor_historic_reserve_summary.sql" +#include "0002-auditor_misattribution_in_inconsistency.sql" #include "0002-auditor_progress.sql" +#include "0002-auditor_purse_not_closed_inconsistencies.sql" #include "0002-auditor_purses.sql" +#include "0002-auditor_refreshes_hanging.sql" +#include "0002-auditor_reserve_balance_insufficient_inconsistency.sql" +#include "0002-auditor_reserve_balance_summary_wrong_inconsistency.sql" +#include "0002-auditor_reserve_in_inconsistency.sql" +#include "0002-auditor_reserve_not_closed_inconsistency.sql" #include "0002-auditor_reserves.sql" -#include "0002-auditor_deposit_confirmations.sql" +#include "0002-auditor_row_inconsistency.sql" +#include "0002-auditor_row_minor_inconsistencies.sql" +#include "0002-auditor_wire_format_inconsistency.sql" +#include "0002-auditor_wire_out_inconsistency.sql" +#include "0002-auditor_pending_deposits.sql" COMMIT; diff --git a/src/auditordb/pg_del_amount_arithmetic_inconsistency.c b/src/auditordb/pg_del_amount_arithmetic_inconsistency.c new file mode 100644 index 000000000..5af3bdda7 --- /dev/null +++ b/src/auditordb/pg_del_amount_arithmetic_inconsistency.c @@ -0,0 +1,41 @@ +/* + 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_amount_arithmetic_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_amount_arithmetic_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_amount_arithmetic_inconsistency", + "DELETE" + " FROM auditor_amount_arithmetic_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_amount_arithmetic_inconsistency", + params); +} diff --git a/src/auditordb/pg_del_amount_arithmetic_inconsistency.h b/src/auditordb/pg_del_amount_arithmetic_inconsistency.h new file mode 100644 index 000000000..ff7f12cf2 --- /dev/null +++ b/src/auditordb/pg_del_amount_arithmetic_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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_AMOUNT_ARITHMETIC_INCONSISTENCY_H +#define SRC_PG_DEL_AMOUNT_ARITHMETIC_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the deposit confirmations 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_amount_arithmetic_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_AMOUNT_ARITHMETIC_INCONSISTENCY_H diff --git a/src/auditordb/pg_del_auditor_closure_lags.c b/src/auditordb/pg_del_auditor_closure_lags.c new file mode 100644 index 000000000..89f230af3 --- /dev/null +++ b/src/auditordb/pg_del_auditor_closure_lags.c @@ -0,0 +1,41 @@ +/* + 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_auditor_closure_lags.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_auditor_closure_lags ( + 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_auditor_closure_lags", + "DELETE" + " FROM auditor_closure_lags" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_auditor_closure_lags", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_auditor_closure_lags.h b/src/auditordb/pg_del_auditor_closure_lags.h new file mode 100644 index 000000000..7c6f2db51 --- /dev/null +++ b/src/auditordb/pg_del_auditor_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_DEL_AUDITOR_CLOSURE_LAGS_H +#define SRC_PG_DEL_AUDITOR_CLOSURE_LAGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the auditor closure lags 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_auditor_closure_lags ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_AUDITOR_CLOSURE_LAGS_H diff --git a/src/auditordb/pg_del_auditor_emergency.c b/src/auditordb/pg_del_auditor_emergency.c new file mode 100644 index 000000000..a4afd14c5 --- /dev/null +++ b/src/auditordb/pg_del_auditor_emergency.c @@ -0,0 +1,41 @@ +/* + 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_auditor_emergency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_emergency ( + 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_emergency", + "DELETE" + " FROM auditor_emergency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_emergency", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_auditor_emergency.h b/src/auditordb/pg_del_auditor_emergency.h new file mode 100644 index 000000000..94c8bc4e9 --- /dev/null +++ b/src/auditordb/pg_del_auditor_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_DEL_AUDITOR_EMERGENCY_H +#define SRC_PG_DEL_AUDITOR_EMERGENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the emergency 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_emergency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_AUDITOR_EMERGENCY_H diff --git a/src/auditordb/pg_del_auditor_progress.c b/src/auditordb/pg_del_auditor_progress.c new file mode 100644 index 000000000..087e2783c --- /dev/null +++ b/src/auditordb/pg_del_auditor_progress.c @@ -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/> + */ + +#include "pg_del_auditor_progress.h" + + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_progress ( + 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_auditor_closure_lags", + "DELETE" + " FROM auditor_progress" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_auditor_closure_lags", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_auditor_progress.h b/src/auditordb/pg_del_auditor_progress.h new file mode 100644 index 000000000..51e974040 --- /dev/null +++ b/src/auditordb/pg_del_auditor_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_DEL_AUDITOR_PROGRESS_H +#define SRC_PG_DEL_AUDITOR_PROGRESS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the progress 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_progress ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_AUDITOR_PROGRESS_H diff --git a/src/auditordb/pg_del_bad_sig_losses.c b/src/auditordb/pg_del_bad_sig_losses.c new file mode 100644 index 000000000..2bf48642c --- /dev/null +++ b/src/auditordb/pg_del_bad_sig_losses.c @@ -0,0 +1,41 @@ +/* + 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_bad_sig_losses.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_bad_sig_losses ( + 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_bad_sig_losses", + "DELETE" + " FROM auditor_bad_sig_losses" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_bad_sig_losses", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_bad_sig_losses.h b/src/auditordb/pg_del_bad_sig_losses.h new file mode 100644 index 000000000..4881e8715 --- /dev/null +++ b/src/auditordb/pg_del_bad_sig_losses.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_DEL_BAD_SIG_LOSSES_H +#define SRC_PG_DEL_BAD_SIG_LOSSES_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_bad_sig_losses ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_BAD_SIG_LOSSES_H diff --git a/src/auditordb/pg_del_balances.c b/src/auditordb/pg_del_balances.c new file mode 100644 index 000000000..9cdf9e2ea --- /dev/null +++ b/src/auditordb/pg_del_balances.c @@ -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/> + */ + + +#include "pg_del_balances.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_balances ( + 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_balances", + "DELETE" + " FROM auditor_balances" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_balances", + params); +} diff --git a/src/auditordb/pg_del_balances.h b/src/auditordb/pg_del_balances.h new file mode 100644 index 000000000..03baebebc --- /dev/null +++ b/src/auditordb/pg_del_balances.h @@ -0,0 +1,36 @@ +/* + 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_BALANCES_H +#define SRC_PG_DEL_BALANCES_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_balances ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_BALANCES_H diff --git a/src/auditordb/pg_del_coin_inconsistency.c b/src/auditordb/pg_del_coin_inconsistency.c new file mode 100644 index 000000000..d1426c955 --- /dev/null +++ b/src/auditordb/pg_del_coin_inconsistency.c @@ -0,0 +1,41 @@ +/* + 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_coin_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_coin_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_coin_inconsistency", + "DELETE" + " FROM auditor_coin_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_coin_inconsistency", + params); +} diff --git a/src/auditordb/pg_del_coin_inconsistency.h b/src/auditordb/pg_del_coin_inconsistency.h new file mode 100644 index 000000000..8fc43c1c5 --- /dev/null +++ b/src/auditordb/pg_del_coin_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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_COIN_INCONSISTENCY_H +#define SRC_PG_DEL_COIN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the coin inconsistency 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_coin_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_COIN_INCONSISTENCY_H diff --git a/src/auditordb/pg_del_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_del_denomination_key_validity_withdraw_inconsistency.c new file mode 100644 index 000000000..fa8d01580 --- /dev/null +++ b/src/auditordb/pg_del_denomination_key_validity_withdraw_inconsistency.c @@ -0,0 +1,41 @@ +/* + 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_key_validity_withdraw_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_denomination_key_validity_withdraw_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_denomination_key_validity_withdraw_inconsistency", + "DELETE" + " FROM auditor_denomination_key_validity_withdraw_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_denomination_key_validity_withdraw_inconsistency", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_denomination_key_validity_withdraw_inconsistency.h b/src/auditordb/pg_del_denomination_key_validity_withdraw_inconsistency.h new file mode 100644 index 000000000..9c11dd768 --- /dev/null +++ b/src/auditordb/pg_del_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_DEL_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H +#define SRC_PG_DEL_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the denom key validity withdraw inconsistency 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_key_validity_withdraw_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H diff --git a/src/auditordb/pg_del_denomination_pending.c b/src/auditordb/pg_del_denomination_pending.c new file mode 100644 index 000000000..ac5ab7211 --- /dev/null +++ b/src/auditordb/pg_del_denomination_pending.c @@ -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/> + */ + + +#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); +} diff --git a/src/auditordb/pg_del_denomination_pending.h b/src/auditordb/pg_del_denomination_pending.h new file mode 100644 index 000000000..91e7fea59 --- /dev/null +++ b/src/auditordb/pg_del_denomination_pending.h @@ -0,0 +1,36 @@ +/* + 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 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..03c222105 --- /dev/null +++ b/src/auditordb/pg_del_denominations_without_sigs.c @@ -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/> + */ + + +#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); +} 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..ae090b5c8 --- /dev/null +++ b/src/auditordb/pg_del_denominations_without_sigs.h @@ -0,0 +1,36 @@ +/* + 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 diff --git a/src/auditordb/pg_del_emergency.c b/src/auditordb/pg_del_emergency.c new file mode 100644 index 000000000..8160dc582 --- /dev/null +++ b/src/auditordb/pg_del_emergency.c @@ -0,0 +1,41 @@ +/* + This file is part of TALER + Copyright (C) 2022 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_emergency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_emergency ( + 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_emergency", + "DELETE" + " FROM auditor_emergency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_emergency", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_emergency.h b/src/auditordb/pg_del_emergency.h new file mode 100644 index 000000000..a99d09c93 --- /dev/null +++ b/src/auditordb/pg_del_emergency.h @@ -0,0 +1,35 @@ +/* + This file is part of TALER + Copyright (C) 2022 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_EMERGENCY_H +#define SRC_PG_DEL_EMERGENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the denom key validity withdraw inconsistency 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_emergency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_EMERGENCY_H diff --git a/src/auditordb/pg_del_emergency_by_count.c b/src/auditordb/pg_del_emergency_by_count.c new file mode 100644 index 000000000..84ab0def0 --- /dev/null +++ b/src/auditordb/pg_del_emergency_by_count.c @@ -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/> + */ + +#include "pg_del_emergency_by_count.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TAH_PG_del_emergency_by_count ( + 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_emergency_by_count", + "DELETE" + " FROM auditor_emergency_by_count" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_emergency_by_count", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_emergency_by_count.h b/src/auditordb/pg_del_emergency_by_count.h new file mode 100644 index 000000000..734c7ae7e --- /dev/null +++ b/src/auditordb/pg_del_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_DEL_EMERGENCY_BY_COUNT_H +#define SRC_PG_DEL_EMERGENCY_BY_COUNT_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the emergency by count 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_emergency_by_count ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_EMERGENCY_BY_COUNT_H diff --git a/src/auditordb/pg_del_exchange_signkeys.c b/src/auditordb/pg_del_exchange_signkeys.c new file mode 100644 index 000000000..168221e2d --- /dev/null +++ b/src/auditordb/pg_del_exchange_signkeys.c @@ -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/> + */ + + +#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); +} diff --git a/src/auditordb/pg_del_exchange_signkeys.h b/src/auditordb/pg_del_exchange_signkeys.h new file mode 100644 index 000000000..100e11450 --- /dev/null +++ b/src/auditordb/pg_del_exchange_signkeys.h @@ -0,0 +1,36 @@ +/* + 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 diff --git a/src/auditordb/pg_del_fee_time_inconsistency.c b/src/auditordb/pg_del_fee_time_inconsistency.c new file mode 100644 index 000000000..94fbff42f --- /dev/null +++ b/src/auditordb/pg_del_fee_time_inconsistency.c @@ -0,0 +1,43 @@ +/* + 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_fee_time_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TAH_PG_del_fee_time_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_fee_time_inconsistency", + "DELETE" + " FROM auditor_fee_time_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_fee_time_inconsistency", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_fee_time_inconsistency.h b/src/auditordb/pg_del_fee_time_inconsistency.h new file mode 100644 index 000000000..49b7e253e --- /dev/null +++ b/src/auditordb/pg_del_fee_time_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_DEL_FEE_TIME_INCONSISTENCY_H +#define SRC_PG_DEL_FEE_TIME_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the dee time inconsistency 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_fee_time_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_FEE_TIME_INCONSISTENCY_H 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..72f6c7be8 --- /dev/null +++ b/src/auditordb/pg_del_historic_denomination_revenue.c @@ -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/> + */ + + +#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); +} 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..12668b743 --- /dev/null +++ b/src/auditordb/pg_del_historic_denomination_revenue.h @@ -0,0 +1,36 @@ +/* + 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 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..e82b0dafd --- /dev/null +++ b/src/auditordb/pg_del_historic_reserve_summary.c @@ -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/> + */ + + +#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); +} 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..c1675d668 --- /dev/null +++ b/src/auditordb/pg_del_historic_reserve_summary.h @@ -0,0 +1,36 @@ +/* + 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 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..c3ebd0fc6 --- /dev/null +++ b/src/auditordb/pg_del_misattribution_in_inconsistency.c @@ -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/> + */ + + +#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); +} 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..916c53dd8 --- /dev/null +++ b/src/auditordb/pg_del_misattribution_in_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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 diff --git a/src/auditordb/pg_del_purse_not_closed_inconsistencies.c b/src/auditordb/pg_del_purse_not_closed_inconsistencies.c new file mode 100644 index 000000000..3bc82f1e9 --- /dev/null +++ b/src/auditordb/pg_del_purse_not_closed_inconsistencies.c @@ -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/> + */ + +#include "pg_del_purse_not_closed_inconsistencies.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TAH_PG_del_purse_not_closed_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_purse_not_closed_inconsistencies", + "DELETE" + " FROM auditor_purse_not_closed_inconsistencies" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_purse_not_closed_inconsistencies", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_purse_not_closed_inconsistencies.h b/src/auditordb/pg_del_purse_not_closed_inconsistencies.h new file mode 100644 index 000000000..25d4305e2 --- /dev/null +++ b/src/auditordb/pg_del_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_DEL_PURSE_NOT_CLOSED_INCONSISTENCIES_H +#define SRC_PG_DEL_PURSE_NOT_CLOSED_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the purse not closed inconsistency 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_purse_not_closed_inconsistencies ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_PURSE_NOT_CLOSED_INCONSISTENCIES_H diff --git a/src/auditordb/pg_del_purses.c b/src/auditordb/pg_del_purses.c new file mode 100644 index 000000000..aeeaac88a --- /dev/null +++ b/src/auditordb/pg_del_purses.c @@ -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/> + */ + + +#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); +} diff --git a/src/auditordb/pg_del_purses.h b/src/auditordb/pg_del_purses.h new file mode 100644 index 000000000..e4f4566ad --- /dev/null +++ b/src/auditordb/pg_del_purses.h @@ -0,0 +1,36 @@ +/* + 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 diff --git a/src/auditordb/pg_del_refreshes_hanging.c b/src/auditordb/pg_del_refreshes_hanging.c new file mode 100644 index 000000000..43a1cbba1 --- /dev/null +++ b/src/auditordb/pg_del_refreshes_hanging.c @@ -0,0 +1,41 @@ +/* + 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_refreshes_hanging.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_refreshes_hanging ( + 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_refreshes_hanging", + "DELETE" + " FROM auditor_refreshes_hanging" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_refreshes_hanging", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_refreshes_hanging.h b/src/auditordb/pg_del_refreshes_hanging.h new file mode 100644 index 000000000..f2cdee95e --- /dev/null +++ b/src/auditordb/pg_del_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_DEL_REFRESHES_HANGING_H +#define SRC_PG_DEL_REFRESHES_HANGING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the refreshes hanging 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_refreshes_hanging ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_REFRESHES_HANGING_H diff --git a/src/auditordb/pg_del_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_del_reserve_balance_insufficient_inconsistency.c new file mode 100644 index 000000000..001969e51 --- /dev/null +++ b/src/auditordb/pg_del_reserve_balance_insufficient_inconsistency.c @@ -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/> + */ + +#include "pg_del_reserve_balance_insufficient_inconsistency.h" + + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_balance_insufficient_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_insufficient_inconsistency", + "DELETE" + " FROM auditor_reserve_balance_insufficient_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_reserve_balance_insufficient_inconsistency", + params); +}
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_balance_insufficient_inconsistency.h b/src/auditordb/pg_del_reserve_balance_insufficient_inconsistency.h new file mode 100644 index 000000000..783dea493 --- /dev/null +++ b/src/auditordb/pg_del_reserve_balance_insufficient_inconsistency.h @@ -0,0 +1,34 @@ +/* + 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_INSUFFICIENT_INCONSISTENCY_H +#define SRC_PG_DEL_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the reserve balance insufficient inconsistency 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_insufficient_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H 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..33a31c220 --- /dev/null +++ b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.c @@ -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/> + */ + + +#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); +} 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..aa08c193e --- /dev/null +++ b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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 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..a24f3c36e --- /dev/null +++ b/src/auditordb/pg_del_reserve_in_inconsistency.c @@ -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/> + */ + + +#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); +} 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..7db76b247 --- /dev/null +++ b/src/auditordb/pg_del_reserve_in_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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 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..25ebf7178 --- /dev/null +++ b/src/auditordb/pg_del_reserve_not_closed_inconsistency.c @@ -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/> + */ + + +#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); +} 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..dc71fb2c3 --- /dev/null +++ b/src/auditordb/pg_del_reserve_not_closed_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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 diff --git a/src/auditordb/pg_del_reserves.c b/src/auditordb/pg_del_reserves.c new file mode 100644 index 000000000..731cec48f --- /dev/null +++ b/src/auditordb/pg_del_reserves.c @@ -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/> + */ + + +#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); +} diff --git a/src/auditordb/pg_del_reserves.h b/src/auditordb/pg_del_reserves.h new file mode 100644 index 000000000..3e3136a69 --- /dev/null +++ b/src/auditordb/pg_del_reserves.h @@ -0,0 +1,36 @@ +/* + 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 diff --git a/src/auditordb/pg_del_row_inconsistency.c b/src/auditordb/pg_del_row_inconsistency.c new file mode 100644 index 000000000..f4ab9e068 --- /dev/null +++ b/src/auditordb/pg_del_row_inconsistency.c @@ -0,0 +1,40 @@ +/* + 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_inconsistency.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_row_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_row_inconsistency", + "DELETE" + " FROM auditor_row_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_row_inconsistency", + params); +} diff --git a/src/auditordb/pg_del_row_inconsistency.h b/src/auditordb/pg_del_row_inconsistency.h new file mode 100644 index 000000000..2584f5265 --- /dev/null +++ b/src/auditordb/pg_del_row_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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_INCONSISTENCY_H +#define SRC_PG_DEL_ROW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the deposit confirmations 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_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_ROW_INCONSISTENCY_H 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..00d8d58e8 --- /dev/null +++ b/src/auditordb/pg_del_row_minor_inconsistencies.c @@ -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/> + */ + + +#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); +} 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..06b719cd3 --- /dev/null +++ b/src/auditordb/pg_del_row_minor_inconsistencies.h @@ -0,0 +1,36 @@ +/* + 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 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..ec55a8bb6 --- /dev/null +++ b/src/auditordb/pg_del_wire_format_inconsistency.c @@ -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/> + */ + + +#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); +} 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..ca7384180 --- /dev/null +++ b/src/auditordb/pg_del_wire_format_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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 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..1e318a5be --- /dev/null +++ b/src/auditordb/pg_del_wire_out_inconsistency.c @@ -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/> + */ + + +#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); +} 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..759459424 --- /dev/null +++ b/src/auditordb/pg_del_wire_out_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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 diff --git a/src/auditordb/pg_delete_deposit_confirmations.c b/src/auditordb/pg_delete_deposit_confirmations.c index 6cb76d4e9..b337239c8 100644 --- a/src/auditordb/pg_delete_deposit_confirmations.c +++ b/src/auditordb/pg_delete_deposit_confirmations.c @@ -39,7 +39,7 @@ TAH_PG_delete_deposit_confirmation ( PREPARE (pg,
"auditor_delete_deposit_confirmation",
"DELETE"
- " FROM deposit_confirmations"
+ " FROM auditor_deposit_confirmations"
" WHERE deposit_confirmation_serial_id=$1;");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_delete_deposit_confirmation",
diff --git a/src/auditordb/pg_get_amount_arithmetic_inconsistency.c b/src/auditordb/pg_get_amount_arithmetic_inconsistency.c new file mode 100644 index 000000000..4b09ee39b --- /dev/null +++ b/src/auditordb/pg_get_amount_arithmetic_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_amount_arithmetic_inconsistency.h" + +/** + * Closure for #deposit_confirmation_cb(). + */ +struct AmountArithmeticInconsistencyContext +{ + + /** + * Function to call for each deposit confirmation. + */ + TALER_AUDITORDB_AmountArithmeticInconsistencyCallback 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_deposit_confirmations(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct DepositConfirmationContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +amount_arithmetic_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct AmountArithmeticInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_AmountArithmeticInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("row_id", + &serial_id), + // TODO: what type is this exactly + GNUNET_PQ_result_spec_string ("operation", + &dc.operation), + 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 ("profitable", + &dc.profitable), + + 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_amount_arithmetic_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, + void *cb_cls) +{ + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct AmountArithmeticInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_amount_arithmetic_inconsistency_select_desc", + "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 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, + (limit > 0) ? + "auditor_amount_arithmetic_inconsistency_select_asc" + : + "auditor_amount_arithmetic_inconsistency_select_desc", + params, + &amount_arithmetic_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_amount_arithmetic_inconsistency.h b/src/auditordb/pg_get_amount_arithmetic_inconsistency.h new file mode 100644 index 000000000..7cf4260fe --- /dev/null +++ b/src/auditordb/pg_get_amount_arithmetic_inconsistency.h @@ -0,0 +1,43 @@ +/* + 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_AMOUNT_ARITHMETIC_INCONSISTENCY_H +#define SRC_PG_GET_AMOUNT_ARITHMETIC_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about deposit confirmations 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_amount_arithmetic_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_AMOUNT_ARITHMETIC_INCONSISTENCY_H diff --git a/src/auditordb/pg_get_auditor_closure_lags.c b/src/auditordb/pg_get_auditor_closure_lags.c new file mode 100644 index 000000000..751ff2641 --- /dev/null +++ b/src/auditordb/pg_get_auditor_closure_lags.c @@ -0,0 +1,175 @@ +/* + 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_auditor_closure_lags.h" + + +struct ClosureLagsContext +{ + + /** + * Function to call for each closure lag . + */ + TALER_AUDITORDB_ClosureLagsCallback 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_closure_lags(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ClosureLagsContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +closure_lags_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ClosureLagsContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ClosureLags 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_absolute_time ("deadline", &dc.deadline), + GNUNET_PQ_result_spec_auto_from_type ("wtid", &dc.wtid), + GNUNET_PQ_result_spec_string ("account", &dc.account), + + 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_auditor_closure_lags ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ClosureLagsCallback cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + + struct ClosureLagsContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_closure_lags_get_desc", + "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 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, + (limit > 0) ? + "auditor_auditor_closure_lags_get_asc" + : + "auditor_auditor_closure_lags_get_desc", + params, + &closure_lags_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_auditor_closure_lags.h b/src/auditordb/pg_get_auditor_closure_lags.h new file mode 100644 index 000000000..03822864e --- /dev/null +++ b/src/auditordb/pg_get_auditor_closure_lags.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_GET_AUDITOR_CLOSURE_LAGS_H +#define SRC_PG_GET_AUDITOR_CLOSURE_LAGS_H + + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about auditor closure lags 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_auditor_closure_lags ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ClosureLagsCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_AUDITOR_CLOSURE_LAGS_H diff --git a/src/auditordb/pg_get_bad_sig_losses.c b/src/auditordb/pg_get_bad_sig_losses.c new file mode 100644 index 000000000..096739779 --- /dev/null +++ b/src/auditordb/pg_get_bad_sig_losses.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_bad_sig_losses.h" + + +struct BadSigLossesContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_BadSigLossesCallback 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_bad_sig_losses(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct BadSigLossesContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +bad_sig_losses_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct BadSigLossesContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "---found badsiglosses...\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "---num_results: %u\n", num_results); + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_BadSigLosses dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + GNUNET_PQ_result_spec_string ("operation", &dc.operation), + TALER_PQ_RESULT_SPEC_AMOUNT ("loss", &dc.loss), + GNUNET_PQ_result_spec_auto_from_type ("operation_specific_pub", + &dc.operation_specific_pub), + + 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_bad_sig_losses ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + bool filter_spec_pub, + struct GNUNET_CRYPTO_EddsaPublicKey op_spec_pub, + const char *op, + TALER_AUDITORDB_BadSigLossesCallback cb, + void *cb_cls) +{ + + /*if true, does not filter for an operation specific key*/ + bool any_spec_pub = ! filter_spec_pub; + + /*if true, does not filter for an operation*/ + bool any_op = true; + const char *o; + + if (op != NULL) + { + any_op = false; + o = op; + } + else + { + o = ""; + } + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_bool (any_spec_pub), + GNUNET_PQ_query_param_auto_from_type (&op_spec_pub), + GNUNET_PQ_query_param_bool (any_op), + GNUNET_PQ_query_param_string (o), + GNUNET_PQ_query_param_end + }; + struct BadSigLossesContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_bad_sig_losses_get_desc", + "SELECT" + " row_id" + ",operation" + ",loss" + ",operation_specific_pub" + " FROM auditor_bad_sig_losses" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " AND ($4 OR operation_specific_pub = $5)" + " AND ($6 OR operation = $7)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_bad_sig_losses_get_asc", + "SELECT" + " row_id" + ",operation" + ",loss" + ",operation_specific_pub" + " FROM auditor_bad_sig_losses" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " AND ($4 OR operation_specific_pub = $5)" + " AND ($6 OR operation = $7)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_bad_sig_losses_get_asc" + : "auditor_bad_sig_losses_get_desc", + params, + &bad_sig_losses_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_bad_sig_losses.h b/src/auditordb/pg_get_bad_sig_losses.h new file mode 100644 index 000000000..5694458d3 --- /dev/null +++ b/src/auditordb/pg_get_bad_sig_losses.h @@ -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/> + */ + +#ifndef SRC_PG_GET_BAD_SIG_LOSSES_H +#define SRC_PG_GET_BAD_SIG_LOSSES_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about bad signature losses 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_bad_sig_losses ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + bool filter_spec_pub, + struct GNUNET_CRYPTO_EddsaPublicKey op_spec_pub, + const char *op, + TALER_AUDITORDB_BadSigLossesCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_BAD_SIG_LOSSES_H diff --git a/src/auditordb/pg_get_balances.c b/src/auditordb/pg_get_balances.c new file mode 100644 index 000000000..8f8f2d682 --- /dev/null +++ b/src/auditordb/pg_get_balances.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_balances.h" + + +struct BalancesContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_BalancesCallback 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_balances(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct BalancesContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +balances_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct BalancesContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_Balances dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_string ("balance_key", &dc.balance_key), + TALER_PQ_RESULT_SPEC_AMOUNT ("balance_value", &dc.balance_value), + + + 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_balances ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + const char *balance_key, + TALER_AUDITORDB_BalancesCallback cb, + void *cb_cls) +{ + + + /*if true, does not filter for a specific balance*/ + bool any_balance = true; + const char *bk; + + if (balance_key != NULL) + { + any_balance = false; + bk = balance_key; + } + else + { + bk = ""; + } + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_uint64 (&plimit), + GNUNET_PQ_query_param_bool (any_balance), + GNUNET_PQ_query_param_string (bk), + GNUNET_PQ_query_param_end + }; + struct BalancesContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_balances_get_desc", + "SELECT" + " row_id," + " balance_key," + " balance_value" + " FROM auditor_balances" + " WHERE (row_id < $1)" + " AND ($3 OR balance_key = $4)" + " ORDER BY row_id DESC" + " LIMIT $2" + ); + PREPARE (pg, + "auditor_balances_get_asc", + "SELECT" + " row_id," + " balance_key," + " balance_value" + " FROM auditor_balances" + " WHERE (row_id > $1)" + " AND ($3 OR balance_key = $4)" + " ORDER BY row_id ASC" + " LIMIT $2" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_balances_get_asc" + : "auditor_balances_get_desc", + params, + &balances_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} diff --git a/src/auditordb/pg_get_balances.h b/src/auditordb/pg_get_balances.h new file mode 100644 index 000000000..48c9287b1 --- /dev/null +++ b/src/auditordb/pg_get_balances.h @@ -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/> + */ + + +#ifndef SRC_PG_GET_BALANCES_H +#define SRC_PG_GET_BALANCES_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about balances 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_balances ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + const char *balance_key, + TALER_AUDITORDB_BalancesCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_BALANCES_H diff --git a/src/auditordb/pg_get_coin_inconsistency.c b/src/auditordb/pg_get_coin_inconsistency.c new file mode 100644 index 000000000..eb2190db0 --- /dev/null +++ b/src/auditordb/pg_get_coin_inconsistency.c @@ -0,0 +1,187 @@ +/* + 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_coin_inconsistency.h" + +/** + * Closure for #deposit_confirmation_cb(). + */ +struct CoinInconsistencyContext +{ + + /** + * Function to call for each deposit confirmation. + */ + TALER_AUDITORDB_CoinInconsistencyCallback 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_deposit_confirmations(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct DepositConfirmationContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +coin_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct CoinInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_CoinInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("row_id", + &serial_id), + GNUNET_PQ_result_spec_string ("operation", + &dc.operation), + TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_amount", + &dc.exchange_amount), + TALER_PQ_RESULT_SPEC_AMOUNT ("auditor_amount", + &dc.auditor_amount), + GNUNET_PQ_result_spec_auto_from_type ("coin_pub", &dc.coin_pub), + GNUNET_PQ_result_spec_bool ("profitable", + &dc.profitable), + + 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_coin_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_CoinInconsistencyCallback cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct CoinInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + + PREPARE (pg, + "auditor_coin_inconsistency_select_desc", + "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 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, + (limit > 0) ? + "auditor_coin_inconsistency_select_asc" + : + "auditor_coin_inconsistency_select_desc", + params, + &coin_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_coin_inconsistency.h b/src/auditordb/pg_get_coin_inconsistency.h new file mode 100644 index 000000000..9bff05397 --- /dev/null +++ b/src/auditordb/pg_get_coin_inconsistency.h @@ -0,0 +1,44 @@ +/* + 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_COIN_INCONSISTENCY_H +#define SRC_PG_GET_COIN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about deposit confirmations 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_coin_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_CoinInconsistencyCallback cb, + void *cb_cls); + + +#endif // SRC_PG_GET_COIN_INCONSISTENCY_H diff --git a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c new file mode 100644 index 000000000..7449f35da --- /dev/null +++ b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c @@ -0,0 +1,177 @@ +/* + 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_key_validity_withdraw_inconsistency.h" + +/** + * Closure for #denomination_key_validity_withdraw_inconsistency_cb(). + */ +struct DenominationKeyValidityWithdrawInconsistencyContext +{ + + /** + * Function to call for each denomination key validity... + */ + TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback 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_deposit_confirmations(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct DepositConfirmationContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +denomination_key_validity_withdraw_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct DenominationKeyValidityWithdrawInconsistencyContext *dcc = cls; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + GNUNET_PQ_result_spec_absolute_time ("execution_date", + &dc.execution_date), + GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &dc.reserve_pub), + GNUNET_PQ_result_spec_auto_from_type ("denompub_h", &dc.denompub_h), + + 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_key_validity_withdraw_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback + cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct DenominationKeyValidityWithdrawInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "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)" + " 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, + (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, + &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_key_validity_withdraw_inconsistency.h b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h new file mode 100644 index 000000000..199e2c364 --- /dev/null +++ b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h @@ -0,0 +1,43 @@ +/* + 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_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H +#define SRC_PG_GET_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about denominations key validity withdraw 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_denomination_key_validity_withdraw_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H diff --git a/src/auditordb/pg_get_denomination_pending.c b/src/auditordb/pg_get_denomination_pending.c new file mode 100644 index 000000000..9ff92abef --- /dev/null +++ b/src/auditordb/pg_get_denomination_pending.c @@ -0,0 +1,183 @@ +/* + 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_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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_uint64 (&plimit), + 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" + " row_id," + " denom_pub_hash," + " denom_balance," + " denom_loss," + " num_issued," + " denom_risk," + " recoup_loss" + " FROM auditor_denomination_pending" + " WHERE (row_id < $1)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_denomination_pending_get_asc", + "SELECT" + " row_id," + " denom_pub_hash," + " denom_balance," + " denom_loss," + " num_issued," + " denom_risk," + " recoup_loss" + " FROM auditor_denomination_pending" + " WHERE (row_id > $1)" + " 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; +} diff --git a/src/auditordb/pg_get_denomination_pending.h b/src/auditordb/pg_get_denomination_pending.h new file mode 100644 index 000000000..f1578553b --- /dev/null +++ b/src/auditordb/pg_get_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_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 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..2bc3e5dc0 --- /dev/null +++ b/src/auditordb/pg_get_denominations_without_sigs.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_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_absolute_time ("start_time", &dc.start_time), + GNUNET_PQ_result_spec_absolute_time ("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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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; +} 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..63bb54583 --- /dev/null +++ b/src/auditordb/pg_get_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_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 diff --git a/src/auditordb/pg_get_deposit_confirmations.c b/src/auditordb/pg_get_deposit_confirmations.c index b8055a296..de9817919 100644 --- a/src/auditordb/pg_get_deposit_confirmations.c +++ b/src/auditordb/pg_get_deposit_confirmations.c @@ -13,6 +13,7 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ + /** * @file pg_get_deposit_confirmations.c * @brief Low-level (statement-level) Postgres database access for the exchange @@ -74,20 +75,22 @@ deposit_confirmation_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { uint64_t serial_id; - struct TALER_AUDITORDB_DepositConfirmation dc = { 0}; + struct TALER_AUDITORDB_DepositConfirmation dc = { 0 }; struct TALER_CoinSpendPublicKeyP *coin_pubs = NULL; struct TALER_CoinSpendSignatureP *coin_sigs = NULL; size_t num_pubs = 0; size_t num_sigs = 0; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_uint64 ("serial_id", + GNUNET_PQ_result_spec_uint64 ("deposit_confirmation_serial_id", &serial_id), + GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms", &dc.h_contract_terms), GNUNET_PQ_result_spec_auto_from_type ("h_policy", &dc.h_policy), GNUNET_PQ_result_spec_auto_from_type ("h_wire", &dc.h_wire), + GNUNET_PQ_result_spec_timestamp ("exchange_timestamp", &dc.exchange_timestamp), GNUNET_PQ_result_spec_timestamp ("refund_deadline", @@ -96,6 +99,7 @@ deposit_confirmation_cb (void *cls, &dc.wire_deadline), TALER_PQ_RESULT_SPEC_AMOUNT ("total_without_fee", &dc.total_without_fee), + GNUNET_PQ_result_spec_auto_array_from_type (pg->conn, "coin_pubs", &num_pubs, @@ -112,6 +116,7 @@ deposit_confirmation_cb (void *cls, &dc.exchange_pub), GNUNET_PQ_result_spec_auto_from_type ("master_sig", &dc.master_sig), + GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -149,15 +154,20 @@ deposit_confirmation_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_deposit_confirmations ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_DepositConfirmationCallback cb, void *cb_cls) { + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), + GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_uint64 (&plimit), GNUNET_PQ_query_param_end }; struct DepositConfirmationContext dcc = { @@ -168,7 +178,30 @@ TAH_PG_get_deposit_confirmations ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_deposit_confirmation_select", + "auditor_deposit_confirmation_select_desc", + "SELECT" + " deposit_confirmation_serial_id" + ",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" + " FROM auditor_deposit_confirmations" + " WHERE (deposit_confirmation_serial_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY deposit_confirmation_serial_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_deposit_confirmation_select_asc", "SELECT" " deposit_confirmation_serial_id" ",h_contract_terms" @@ -185,10 +218,16 @@ TAH_PG_get_deposit_confirmations ( ",exchange_pub" ",master_sig" " FROM auditor_deposit_confirmations" - " WHERE deposit_confirmation_serial_id>$1" - " AND ($2 OR NOT suppressed);"); + " WHERE (deposit_confirmation_serial_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY deposit_confirmation_serial_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_deposit_confirmation_select", + (limit > 0) ? + "auditor_deposit_confirmation_select_asc" + : + "auditor_deposit_confirmation_select_desc", params, &deposit_confirmation_cb, &dcc); diff --git a/src/auditordb/pg_get_deposit_confirmations.h b/src/auditordb/pg_get_deposit_confirmations.h index 6b33e9e6f..141f2a276 100644 --- a/src/auditordb/pg_get_deposit_confirmations.h +++ b/src/auditordb/pg_get_deposit_confirmations.h @@ -40,7 +40,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_deposit_confirmations ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_DepositConfirmationCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_emergency.c b/src/auditordb/pg_get_emergency.c new file mode 100644 index 000000000..a1e615ab2 --- /dev/null +++ b/src/auditordb/pg_get_emergency.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_emergency.h" + +/** + * Closure for #emergency_cb(). + */ +struct EmergencyContext +{ + + /** + * Function to call for each deposit confirmation. + */ + TALER_AUDITORDB_EmergencyCallback 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_emergency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct Emergency *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +emergency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct EmergencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_Emergency 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 ("denom_risk", &dc.denom_risk), + TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss", &dc.denom_loss), + GNUNET_PQ_result_spec_absolute_time ("deposit_start", &dc.deposit_start), + GNUNET_PQ_result_spec_absolute_time ("deposit_end", &dc.deposit_end), + TALER_PQ_RESULT_SPEC_AMOUNT ("value", &dc.value), + 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_emergency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_EmergencyCallback cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct EmergencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_emergency_get_desc", + "SELECT" + " row_id" + ",denompub_h" + ",denom_risk" + ",denom_loss" + ",deposit_start" + ",deposit_end" + ",value" + " FROM auditor_emergency" + " WHERE (row_id < $1)" + " ORDER BY row_id DESC" + " LIMIT $2" + ); + 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)" + " ORDER BY row_id ASC" + " LIMIT $2" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) ? + "auditor_emergency_get_asc" : + "auditor_emergency_get_desc", + params, + &emergency_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_emergency.h b/src/auditordb/pg_get_emergency.h new file mode 100644 index 000000000..09530920e --- /dev/null +++ b/src/auditordb/pg_get_emergency.h @@ -0,0 +1,43 @@ +/* + 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_EMERGENCY_H +#define SRC_PG_GET_EMERGENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about emergency 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_emergency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_EmergencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_EMERGENCY_H diff --git a/src/auditordb/pg_get_emergency_by_count.c b/src/auditordb/pg_get_emergency_by_count.c new file mode 100644 index 000000000..d141b81e3 --- /dev/null +++ b/src/auditordb/pg_get_emergency_by_count.c @@ -0,0 +1,186 @@ +/* + 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_emergency_by_count.h" + +/** + * Closure for #emergency_cb(). + */ +struct EmergencyByCountContext +{ + + /** + * Function to call for each deposit confirmation. + */ + TALER_AUDITORDB_EmergenciesByCountCallback 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_emergency_by_count(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct Emergency *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +emergency_by_count_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct EmergencyByCountContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_EmergenciesByCount 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), + GNUNET_PQ_result_spec_int64 ("num_issued", &dc.num_issued), + GNUNET_PQ_result_spec_int64 ("num_known", &dc.num_known), + TALER_PQ_RESULT_SPEC_AMOUNT ("risk", &dc.risk), + GNUNET_PQ_result_spec_absolute_time ("start", &dc.start), + GNUNET_PQ_result_spec_absolute_time ("deposit_end", &dc.deposit_end), + TALER_PQ_RESULT_SPEC_AMOUNT ("value", &dc.value), + + 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_emergency_by_count ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_EmergenciesByCountCallback cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct EmergencyByCountContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_emergency_by_count_get_desc", + "SELECT" + " row_id" + ",denompub_h" + ",num_issued" + ",num_known" + ",risk" + ",start" + ",deposit_end" + ",value" + " FROM auditor_emergency_by_count" + " 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_by_count" + " 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_emergency_by_count_get_asc" + : "auditor_emergency_by_count_get_desc", + params, + &emergency_by_count_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_emergency_by_count.h b/src/auditordb/pg_get_emergency_by_count.h new file mode 100644 index 000000000..2054e2aee --- /dev/null +++ b/src/auditordb/pg_get_emergency_by_count.h @@ -0,0 +1,43 @@ +/* + 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_EMERGENCY_BY_COUNT_H +#define SRC_PG_GET_EMERGENCY_BY_COUNT_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about emergency by count 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_emergency_by_count ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_EmergenciesByCountCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_EMERGENCY_BY_COUNT_H diff --git a/src/auditordb/pg_get_exchange_signkeys.c b/src/auditordb/pg_get_exchange_signkeys.c new file mode 100644 index 000000000..af0ab4a83 --- /dev/null +++ b/src/auditordb/pg_get_exchange_signkeys.c @@ -0,0 +1,187 @@ +/* + 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_absolute_time ("ep_valid_from", &dc.ep_valid_from), + GNUNET_PQ_result_spec_absolute_time ("ep_expire_sign", + &dc.ep_expire_sign), + GNUNET_PQ_result_spec_absolute_time ("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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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" + " row_id," + " 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" + " row_id," + " 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; +} diff --git a/src/auditordb/pg_get_exchange_signkeys.h b/src/auditordb/pg_get_exchange_signkeys.h new file mode 100644 index 000000000..e30602c48 --- /dev/null +++ b/src/auditordb/pg_get_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_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 diff --git a/src/auditordb/pg_get_fee_time_inconsistency.c b/src/auditordb/pg_get_fee_time_inconsistency.c new file mode 100644 index 000000000..ff1f570e8 --- /dev/null +++ b/src/auditordb/pg_get_fee_time_inconsistency.c @@ -0,0 +1,176 @@ +/* + 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_fee_time_inconsistency.h" + +/** + * Closure for #feetimeinconsistency_cb(). + */ +struct FeeTimeInconsistencyContext +{ + + /** + * Function to call for each fee time inconsistency + */ + TALER_AUDITORDB_FeeTimeInconsistencyCallback 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_emergency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct Emergency *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +fee_time_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct FeeTimeInconsistencyContext *dcc = cls; + // struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_FeeTimeInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_string ("type", &dc.type), + GNUNET_PQ_result_spec_absolute_time ("time", &dc.time), + GNUNET_PQ_result_spec_string ("diagnostic", &dc.diagnostic), + + 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_fee_time_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_FeeTimeInconsistencyCallback cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct FeeTimeInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_fee_time_inconsistency_get_desc", + "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 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, + (limit > 0) ? + "auditor_fee_time_inconsistency_get_asc" + : + "auditor_fee_time_inconsistency_get_desc", + params, + &fee_time_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_fee_time_inconsistency.h b/src/auditordb/pg_get_fee_time_inconsistency.h new file mode 100644 index 000000000..8874cffff --- /dev/null +++ b/src/auditordb/pg_get_fee_time_inconsistency.h @@ -0,0 +1,43 @@ +/* + 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_FEE_TIME_INCONSISTENCY_H +#define SRC_PG_GET_FEE_TIME_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about fee time 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_fee_time_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_FeeTimeInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_FEE_TIME_INCONSISTENCY_H 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..0e84c573e --- /dev/null +++ b/src/auditordb/pg_get_historic_denomination_revenue.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_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_absolute_time ("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_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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_uint64 (&plimit), + 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" + " row_id," + " denom_pub_hash," + " revenue_timestamp," + " revenue_balance," + " loss_balance" + " FROM auditor_historic_denomination_revenue" + " WHERE (row_id < $1)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_historic_denomination_revenue_get_asc", + "SELECT" + " row_id," + " denom_pub_hash," + " revenue_timestamp," + " revenue_balance," + " loss_balance" + " FROM auditor_historic_denomination_revenue" + " WHERE (row_id > $1)" + " 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; +} 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..c5847c667 --- /dev/null +++ b/src/auditordb/pg_get_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_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 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..684a78559 --- /dev/null +++ b/src/auditordb/pg_get_historic_reserve_summary.c @@ -0,0 +1,174 @@ +/* + 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_absolute_time ("start_date", &dc.start_date), + GNUNET_PQ_result_spec_absolute_time ("end_date", &dc.end_date), + TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_profits", &dc.reserve_profits), + + + 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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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" + " row_id," + " start_date," + " end_date," + " reserve_profits" + " FROM auditor_historic_reserve_summary" + " WHERE (row_id < $1)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_historic_reserve_summary_get_asc", + "SELECT" + " row_id," + " start_date," + " end_date," + " reserve_profits" + " FROM auditor_historic_reserve_summary" + " WHERE (row_id > $1)" + " 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; +} 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..2d4f16dbe --- /dev/null +++ b/src/auditordb/pg_get_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_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 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..a091c9b64 --- /dev/null +++ b/src/auditordb/pg_get_misattribution_in_inconsistency.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_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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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; +} 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..e8f7d4bf7 --- /dev/null +++ b/src/auditordb/pg_get_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_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 diff --git a/src/auditordb/pg_get_purse_not_closed_inconsistencies.c b/src/auditordb/pg_get_purse_not_closed_inconsistencies.c new file mode 100644 index 000000000..adf306ed5 --- /dev/null +++ b/src/auditordb/pg_get_purse_not_closed_inconsistencies.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_purse_not_closed_inconsistencies.h" + + +/** + * Closure for #purse_not_closed_inconsistencies_cb(). + */ +struct PurseNotClosedInconsistenciesContext +{ + + /** + * Function to call for each purse not closed_inconsistencies. + */ + TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback 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_purse_not_closed_inconsistencies(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct PurseNotClosedInconsistencies *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +purse_not_closed_inconsistencies_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct PurseNotClosedInconsistenciesContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_PurseNotClosedInconsistencies dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + GNUNET_PQ_result_spec_auto_from_type ("purse_pub", &dc.purse_pub), + TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &dc.amount), + GNUNET_PQ_result_spec_absolute_time ("expiration_date", + &dc.expiration_date), + + 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_purse_not_closed_inconsistencies ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct PurseNotClosedInconsistenciesContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "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)" + " 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, + (limit > 0) ? + "auditor_purse_not_closed_inconsistencies_get_asc" + : + "auditor_purse_not_closed_inconsistencies_get_desc", + params, + & + purse_not_closed_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_purse_not_closed_inconsistencies.h b/src/auditordb/pg_get_purse_not_closed_inconsistencies.h new file mode 100644 index 000000000..ef7bdb3ae --- /dev/null +++ b/src/auditordb/pg_get_purse_not_closed_inconsistencies.h @@ -0,0 +1,43 @@ +/* + 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_PURSE_NOT_CLOSED_INCONSISTENCIES_H +#define SRC_PG_GET_PURSE_NOT_CLOSED_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about purse not closed 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_purse_not_closed_inconsistencies ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_PURSE_NOT_CLOSED_INCONSISTENCIES_H diff --git a/src/auditordb/pg_get_purses.c b/src/auditordb/pg_get_purses.c new file mode 100644 index 000000000..44ef4d91b --- /dev/null +++ b/src/auditordb/pg_get_purses.c @@ -0,0 +1,174 @@ +/* + 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++) + { + + struct TALER_AUDITORDB_Purses dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + 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_absolute_time ("expiration_date", + &dc.expiration_date), + + + 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, + dc.auditor_purses_rowid, + &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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_uint64 (&plimit), + 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" + " FROM auditor_purses" + " WHERE (row_id < $1)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_purses_get_asc", + "SELECT" + " auditor_purses_rowid," + " purse_pub," + " balance," + " target," + " expiration_date" + " FROM auditor_purses" + " WHERE (row_id > $1)" + " 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; +} diff --git a/src/auditordb/pg_get_purses.h b/src/auditordb/pg_get_purses.h new file mode 100644 index 000000000..b0dc3183b --- /dev/null +++ b/src/auditordb/pg_get_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_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 diff --git a/src/auditordb/pg_get_refreshes_hanging.c b/src/auditordb/pg_get_refreshes_hanging.c new file mode 100644 index 000000000..353ac5e1e --- /dev/null +++ b/src/auditordb/pg_get_refreshes_hanging.c @@ -0,0 +1,172 @@ +/* + 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_refreshes_hanging.h" + +/** + * Closure for #refreshes_hanging_cb(). + */ +struct RefreshesHangingContext +{ + + /** + * Function to call for each RefreshesHanging. + */ + TALER_AUDITORDB_RefreshesHangingCallback 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_refreshes_hanging(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct RefreshesHanging *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +refreshes_hanging_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct RefreshesHangingContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_RefreshesHanging 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_auto_from_type ("coin_pub", &dc.coin_pub), + + 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_refreshes_hanging ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_RefreshesHangingCallback cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct RefreshesHangingContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_refreshes_hanging_get_desc", + "SELECT" + " row_id" + ",amount" + ",coin_pub" + " FROM auditor_refreshes_hanging" + " 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, + (limit > 0) ? + "auditor_refreshes_hanging_get_asc" + : "auditor_refreshes_hanging_get_desc", + params, + &refreshes_hanging_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_refreshes_hanging.h b/src/auditordb/pg_get_refreshes_hanging.h new file mode 100644 index 000000000..b4fd26708 --- /dev/null +++ b/src/auditordb/pg_get_refreshes_hanging.h @@ -0,0 +1,43 @@ +/* + 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_REFRESHES_HANGING_H +#define SRC_PG_GET_REFRESHES_HANGING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about hanging refreshes 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_refreshes_hanging ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_RefreshesHangingCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_REFRESHES_HANGING_H diff --git a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c new file mode 100644 index 000000000..f84d5bbaa --- /dev/null +++ b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c @@ -0,0 +1,177 @@ +/* + 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_insufficient_inconsistency.h" + +/** + * Closure for #reserve_balance_insufficient_inconsistency_cb(). + */ +struct ReserveBalanceInsufficientInconsistencyContext +{ + + /** + * Function to call for each ReserveBalanceInsufficientInconsistency. + */ + TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback 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_reserve_balance_insufficient_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ReserveBalanceInsufficientInconsistency *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +reserve_balance_insufficient_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ReserveBalanceInsufficientInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency 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), + GNUNET_PQ_result_spec_bool ("inconsistency_gain", &dc.inconsistency_gain), + TALER_PQ_RESULT_SPEC_AMOUNT ("inconsistency_amount", + &dc.inconsistency_amount), + + 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_insufficient_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct ReserveBalanceInsufficientInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "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)" + " 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, + (limit > 0) ? + "auditor_reserve_balance_insufficient_inconsistency_get_asc" + : + "auditor_reserve_balance_insufficient_inconsistency_get_desc", + params, + & + reserve_balance_insufficient_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_insufficient_inconsistency.h b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h new file mode 100644 index 000000000..d2e0fa3ed --- /dev/null +++ b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h @@ -0,0 +1,43 @@ +/* + 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_INSUFFICIENT_INCONSISTENCY_H +#define SRC_PG_GET_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about reserve balance insufficient 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_insufficient_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H 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..d41d1cbf9 --- /dev/null +++ b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,183 @@ +/* + 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; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "---found rbswi's in reserveblanace...\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "---num_results: %u\n", num_results); + + + 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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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; +} 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..8cafd4f44 --- /dev/null +++ b/src/auditordb/pg_get_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_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 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..017566f96 --- /dev/null +++ b/src/auditordb/pg_get_reserve_in_inconsistency.c @@ -0,0 +1,189 @@ +/* + 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_absolute_time ("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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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; +} 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..26244f67c --- /dev/null +++ b/src/auditordb/pg_get_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_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 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..e5583509e --- /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_absolute_time ("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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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; +} 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..623c98b89 --- /dev/null +++ b/src/auditordb/pg_get_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_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 diff --git a/src/auditordb/pg_get_reserves.c b/src/auditordb/pg_get_reserves.c new file mode 100644 index 000000000..dae01b547 --- /dev/null +++ b/src/auditordb/pg_get_reserves.c @@ -0,0 +1,194 @@ +/* + 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++) + { + + struct TALER_AUDITORDB_Reserves dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + 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_absolute_time ("expiration_date", + &dc.expiration_date), + GNUNET_PQ_result_spec_string ("origin_account", &dc.origin_account), + + + 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, + dc.auditor_reserves_rowid, + &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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_uint64 (&plimit), + 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" + " FROM auditor_reserves" + " WHERE (auditor_reserves_rowid < $1)" + " 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" + " FROM auditor_reserves" + " WHERE (auditor_reserves_rowid > $1)" + " 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; +} diff --git a/src/auditordb/pg_get_reserves.h b/src/auditordb/pg_get_reserves.h new file mode 100644 index 000000000..1af347a3e --- /dev/null +++ b/src/auditordb/pg_get_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_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 diff --git a/src/auditordb/pg_get_row_inconsistency.c b/src/auditordb/pg_get_row_inconsistency.c new file mode 100644 index 000000000..51115003e --- /dev/null +++ b/src/auditordb/pg_get_row_inconsistency.c @@ -0,0 +1,176 @@ +/* + 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_inconsistency.h" + +/** + * Closure for #deposit_confirmation_cb(). + */ +struct RowInconsistencyContext +{ + + /** + * Function to call for each deposit confirmation. + */ + TALER_AUDITORDB_RowInconsistencyCallback 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_deposit_confirmations(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct DepositConfirmationContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +row_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct RowInconsistencyContext *dcc = cls; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_RowInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_string ("row_table", &dc.row_table), + GNUNET_PQ_result_spec_string ("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_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_RowInconsistencyCallback cb, + void *cb_cls) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + GNUNET_PQ_query_param_end + }; + struct RowInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + + PREPARE (pg, + "auditor_row_inconsistency_select_desc", + "SELECT" + " row_id" + ",row_table" + ",diagnostic" + ",suppressed" + " FROM auditor_row_inconsistency" + " 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" + ",suppressed" + " 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, + (limit > 0) ? + "auditor_row_inconsistency_select_asc" + : + "auditor_row_inconsistency_select_desc", + params, + &row_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_row_inconsistency.h b/src/auditordb/pg_get_row_inconsistency.h new file mode 100644 index 000000000..4aa13e36d --- /dev/null +++ b/src/auditordb/pg_get_row_inconsistency.h @@ -0,0 +1,44 @@ +/* + 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_INCONSISTENCY_H +#define SRC_PG_GET_ROW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about deposit confirmations 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_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_RowInconsistencyCallback cb, + void *cb_cls); + + +#endif // SRC_PG_GET_ROW_INCONSISTENCY_H 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..c6a15b155 --- /dev/null +++ b/src/auditordb/pg_get_row_minor_inconsistencies.c @@ -0,0 +1,176 @@ +/* + 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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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; +} 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..0fee08db2 --- /dev/null +++ b/src/auditordb/pg_get_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_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 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..d94c851c8 --- /dev/null +++ b/src/auditordb/pg_get_wire_format_inconsistency.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_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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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; +} 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..87ba9d14b --- /dev/null +++ b/src/auditordb/pg_get_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_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 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..d885a2fa1 --- /dev/null +++ b/src/auditordb/pg_get_wire_out_inconsistency.c @@ -0,0 +1,180 @@ +/* + 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_string ("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) +{ + + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + + 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_uint64 (&plimit), + 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; +} 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..619f755a1 --- /dev/null +++ b/src/auditordb/pg_get_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_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 diff --git a/src/auditordb/pg_insert_amount_arithmetic_inconsistency.c b/src/auditordb/pg_insert_amount_arithmetic_inconsistency.c new file mode 100644 index 000000000..afc84e5ba --- /dev/null +++ b/src/auditordb/pg_insert_amount_arithmetic_inconsistency.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_amount_arithmetic_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_amount_arithmetic_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_AmountArithmeticInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_string (dc->operation), + 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->profitable), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_amount_arithmetic_inconsistency_insert", + "INSERT INTO auditor_amount_arithmetic_inconsistency " + "(operation" + ",exchange_amount" + ",auditor_amount" + ",profitable" + ") VALUES ($1,$2,$3,$4)" + " ON CONFLICT (operation) DO UPDATE" + " SET exchange_amount = excluded.exchange_amount," + " auditor_amount = excluded.auditor_amount," + " profitable = excluded.profitable," + " suppressed = false;" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_amount_arithmetic_inconsistency_insert", + params); +} diff --git a/src/auditordb/pg_insert_amount_arithmetic_inconsistency.h b/src/auditordb/pg_insert_amount_arithmetic_inconsistency.h new file mode 100644 index 000000000..31d94e279 --- /dev/null +++ b/src/auditordb/pg_insert_amount_arithmetic_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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_AMOUNT_ARITHMETIC_INCONSISTENCY_H +#define SRC_PG_INSERT_AMOUNT_ARITHMETIC_INCONSISTENCY_H + +#include "taler_util.h" +// #include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a deposit confirmation 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_amount_arithmetic_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_AmountArithmeticInconsistency *dc); + +#endif // SRC_PG_INSERT_AMOUNT_ARITHMETIC_INCONSISTENCY_H diff --git a/src/auditordb/pg_insert_auditor_closure_lags.c b/src/auditordb/pg_insert_auditor_closure_lags.c new file mode 100644 index 000000000..e858f5ac7 --- /dev/null +++ b/src/auditordb/pg_insert_auditor_closure_lags.c @@ -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/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_auditor_closure_lags.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_auditor_closure_lags ( + void *cls, + const struct TALER_AUDITORDB_ClosureLags *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + TALER_PQ_query_param_amount (pg->conn, &dc->amount), + GNUNET_PQ_query_param_absolute_time (&dc->deadline), + GNUNET_PQ_query_param_auto_from_type (&dc->wtid), + GNUNET_PQ_query_param_string (dc->account), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_closure_lags_insert", + "INSERT INTO auditor_closure_lags " + "(amount" + ",deadline" + ",wtid" + ",account" + ") VALUES ($1,$2,$3,$4);"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_closure_lags_insert", + params); +} diff --git a/src/auditordb/pg_insert_auditor_closure_lags.h b/src/auditordb/pg_insert_auditor_closure_lags.h new file mode 100644 index 000000000..745a95093 --- /dev/null +++ b/src/auditordb/pg_insert_auditor_closure_lags.h @@ -0,0 +1,36 @@ +/* + 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_AUDITOR_CLOSURE_LAGS_H +#define SRC_PG_INSERT_AUDITOR_CLOSURE_LAGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a closure 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_auditor_closure_lags ( + void *cls, + const struct TALER_AUDITORDB_ClosureLags *dc); + +#endif // SRC_PG_INSERT_AUDITOR_CLOSURE_LAGS_H diff --git a/src/auditordb/pg_insert_bad_sig_losses.c b/src/auditordb/pg_insert_bad_sig_losses.c new file mode 100644 index 000000000..88ce7d2aa --- /dev/null +++ b/src/auditordb/pg_insert_bad_sig_losses.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_bad_sig_losses.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_bad_sig_losses ( + void *cls, + const struct TALER_AUDITORDB_BadSigLosses *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_string (dc->operation), + TALER_PQ_query_param_amount (pg->conn, &dc->loss), + GNUNET_PQ_query_param_auto_from_type (&dc->operation_specific_pub), + + GNUNET_PQ_query_param_end + }; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "--storing new bsl\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "--operation %s\n", dc->operation); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "--loss %s\n", TALER_amount_to_string ( + &dc->loss)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "--operation_specific_pub %s\n", + TALER_B2S (&dc->operation_specific_pub)); + + PREPARE (pg, + "auditor_bad_sig_losses_insert", + "INSERT INTO auditor_bad_sig_losses " + "(operation" + ",loss" + ",operation_specific_pub" + ") VALUES ($1,$2,$3)" + " ON CONFLICT (operation, operation_specific_pub) DO UPDATE" + " SET loss = excluded.loss," + " suppressed = false;" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_bad_sig_losses_insert", + params); +} diff --git a/src/auditordb/pg_insert_bad_sig_losses.h b/src/auditordb/pg_insert_bad_sig_losses.h new file mode 100644 index 000000000..fdad6a38b --- /dev/null +++ b/src/auditordb/pg_insert_bad_sig_losses.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_INSERT_BAD_SIG_LOSSES_H +#define SRC_PG_INSERT_BAD_SIG_LOSSES_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_bad_sig_losses ( + void *cls, + const struct TALER_AUDITORDB_BadSigLosses *dc); + +#endif // SRC_PG_INSERT_BAD_SIG_LOSSES_H diff --git a/src/auditordb/pg_insert_balances.c b/src/auditordb/pg_insert_balances.c new file mode 100644 index 000000000..d6d4f35ce --- /dev/null +++ b/src/auditordb/pg_insert_balances.c @@ -0,0 +1,49 @@ +/* + 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_balances.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_balances ( + void *cls, + const struct TALER_AUDITORDB_Balances *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_string (dc->balance_key), + TALER_PQ_query_param_amount (pg->conn, &dc->balance_value), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_balances_insert", + "INSERT INTO auditor_balances " + "( balance_key," + " balance_value" + ") VALUES ($1,$2);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_balances_insert", + params); +} diff --git a/src/auditordb/pg_insert_balances.h b/src/auditordb/pg_insert_balances.h new file mode 100644 index 000000000..19d2bc046 --- /dev/null +++ b/src/auditordb/pg_insert_balances.h @@ -0,0 +1,37 @@ +/* + 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_BALANCES_H +#define SRC_PG_INSERT_BALANCES_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_balances ( + void *cls, + const struct TALER_AUDITORDB_Balances *dc); + +#endif // SRC_PG_INSERT_BALANCES_H diff --git a/src/auditordb/pg_insert_coin_inconsistency.c b/src/auditordb/pg_insert_coin_inconsistency.c new file mode 100644 index 000000000..32c57a3c8 --- /dev/null +++ b/src/auditordb/pg_insert_coin_inconsistency.c @@ -0,0 +1,63 @@ +/* + 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_coin_inconsistency.h" + + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_coin_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_CoinInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_string (dc->operation), + TALER_PQ_query_param_amount (pg->conn, + &dc->exchange_amount), + TALER_PQ_query_param_amount (pg->conn, + &dc->auditor_amount), + GNUNET_PQ_query_param_auto_from_type (&dc->coin_pub), + GNUNET_PQ_query_param_bool (dc->profitable), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_coin_inconsistency_insert", + "INSERT INTO auditor_coin_inconsistency " + "(operation" + ",exchange_amount" + ",auditor_amount" + ",coin_pub" + ",profitable" + ") VALUES ($1,$2,$3,$4,$5)" + " ON CONFLICT (operation, coin_pub) DO UPDATE" + " SET exchange_amount = excluded.exchange_amount," + " auditor_amount = excluded.auditor_amount," + " profitable = excluded.profitable," + " suppressed = false;" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_coin_inconsistency_insert", + params); +} diff --git a/src/auditordb/pg_insert_coin_inconsistency.h b/src/auditordb/pg_insert_coin_inconsistency.h new file mode 100644 index 000000000..64904a5b4 --- /dev/null +++ b/src/auditordb/pg_insert_coin_inconsistency.h @@ -0,0 +1,37 @@ +/* + 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_COIN_INCONSISTENCY_H +#define SRC_PG_INSERT_COIN_INCONSISTENCY_H + +#include "taler_util.h" +// #include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a deposit confirmation 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_coin_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_CoinInconsistency *dc); + +#endif // SRC_PG_INSERT_COIN_INCONSISTENCY_H diff --git a/src/auditordb/pg_insert_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_insert_denomination_key_validity_withdraw_inconsistency.c new file mode 100644 index 000000000..2d0cb3cf5 --- /dev/null +++ b/src/auditordb/pg_insert_denomination_key_validity_withdraw_inconsistency.c @@ -0,0 +1,49 @@ +/* + 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_key_validity_withdraw_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_denomination_key_validity_withdraw_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_absolute_time (&dc->execution_date), + GNUNET_PQ_query_param_auto_from_type (&dc->reserve_pub), + GNUNET_PQ_query_param_auto_from_type (&dc->denompub_h), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_denomination_key_validity_withdraw_inconsistency_insert", + "INSERT INTO auditor_denomination_key_validity_withdraw_inconsistency " + "(execution_date" + ",reserve_pub" + ",denompub_h" + ") VALUES ($1,$2,$3);"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_denomination_key_validity_withdraw_inconsistency_insert", + params); +} diff --git a/src/auditordb/pg_insert_denomination_key_validity_withdraw_inconsistency.h b/src/auditordb/pg_insert_denomination_key_validity_withdraw_inconsistency.h new file mode 100644 index 000000000..08484a5bf --- /dev/null +++ b/src/auditordb/pg_insert_denomination_key_validity_withdraw_inconsistency.h @@ -0,0 +1,37 @@ +/* + 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_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H +#define SRC_PG_INSERT_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a denomination key validity withdraw inconsistency 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_key_validity_withdraw_inconsistency ( + void *cls, + const struct + TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency *dc); + +#endif // SRC_PG_INSERT_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H diff --git a/src/auditordb/pg_insert_denomination_pending.c b/src/auditordb/pg_insert_denomination_pending.c new file mode 100644 index 000000000..d1fa00ef3 --- /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_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" + ") VALUES ($1,$2,$3,$4,$5,$6)" + " ON CONFLICT (denom_pub_hash) UPDATE" + " SET denom_balance = excluded.denom_balance, " + " denom_loss = excluded.denom_loss," + " num_issued = excluded.num_issued," + " denom_risk = excluded.denom_risk," + " recoup_loss = excluded.recoup_loss," + " suppressed = false;" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_denomination_pending_insert", + params); +} diff --git a/src/auditordb/pg_insert_denomination_pending.h b/src/auditordb/pg_insert_denomination_pending.h new file mode 100644 index 000000000..a52ddaa21 --- /dev/null +++ b/src/auditordb/pg_insert_denomination_pending.h @@ -0,0 +1,37 @@ +/* + 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 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..f06034602 --- /dev/null +++ b/src/auditordb/pg_insert_denominations_without_sigs.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_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_absolute_time (&dc->start_time), + GNUNET_PQ_query_param_absolute_time (&dc->end_time), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_denominations_without_sigs_insert", + "INSERT INTO auditor_denominations_without_sigs " + "(denompub_h," + " value," + " start_time," + " end_time" + ") VALUES ($1,$2,$3,$4)" + " ON CONFLICT (denompub_h) DO UPDATE" + " SET value = excluded.value," + " start_time = excluded.start_time," + " end_time = excluded.end_time," + " suppressed = false" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_denominations_without_sigs_insert", + params); +} 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..c3f927916 --- /dev/null +++ b/src/auditordb/pg_insert_denominations_without_sigs.h @@ -0,0 +1,37 @@ +/* + 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 diff --git a/src/auditordb/pg_insert_deposit_confirmation.c b/src/auditordb/pg_insert_deposit_confirmation.c index 1b5205782..dbca04fe1 100644 --- a/src/auditordb/pg_insert_deposit_confirmation.c +++ b/src/auditordb/pg_insert_deposit_confirmation.c @@ -56,7 +56,7 @@ TAH_PG_insert_deposit_confirmation ( PREPARE (pg, "auditor_deposit_confirmation_insert", - "INSERT INTO deposit_confirmations " + "INSERT INTO auditor_deposit_confirmations " "(h_contract_terms" ",h_policy" ",h_wire" diff --git a/src/auditordb/pg_insert_emergency.c b/src/auditordb/pg_insert_emergency.c new file mode 100644 index 000000000..a966be43b --- /dev/null +++ b/src/auditordb/pg_insert_emergency.c @@ -0,0 +1,55 @@ +/* + 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_emergency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_emergency ( + void *cls, + const struct TALER_AUDITORDB_Emergency *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->denom_risk), + TALER_PQ_query_param_amount (pg->conn, &dc->denom_loss), + GNUNET_PQ_query_param_absolute_time (&dc->deposit_start), + GNUNET_PQ_query_param_absolute_time (&dc->deposit_end), + TALER_PQ_query_param_amount (pg->conn,&dc->value), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_emergency_insert", + "INSERT INTO auditor_emergency " + "(denompub_h" + ",denom_risk" + ",denom_loss" + ",deposit_start" + ",deposit_end" + ",value" + ") VALUES ($1,$2,$3,$4,$5,$6);"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_emergency_insert", + params); +} diff --git a/src/auditordb/pg_insert_emergency.h b/src/auditordb/pg_insert_emergency.h new file mode 100644 index 000000000..077602a96 --- /dev/null +++ b/src/auditordb/pg_insert_emergency.h @@ -0,0 +1,36 @@ +/* + 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_EMERGENCY_H +#define SRC_PG_INSERT_EMERGENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a emergency 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_emergency ( + void *cls, + const struct TALER_AUDITORDB_Emergency *dc); + +#endif // SRC_PG_INSERT_EMERGENCY_H diff --git a/src/auditordb/pg_insert_emergency_by_count.c b/src/auditordb/pg_insert_emergency_by_count.c new file mode 100644 index 000000000..2cebc8cac --- /dev/null +++ b/src/auditordb/pg_insert_emergency_by_count.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_emergency_by_count.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_emergency_by_count ( + void *cls, + const struct TALER_AUDITORDB_EmergenciesByCount *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type (&dc->denompub_h), + GNUNET_PQ_query_param_int64 (&dc->num_issued), + GNUNET_PQ_query_param_int64 (&dc->num_known), + TALER_PQ_query_param_amount (pg->conn, &dc->risk), + GNUNET_PQ_query_param_absolute_time (&dc->start), + GNUNET_PQ_query_param_absolute_time (&dc->deposit_end), + TALER_PQ_query_param_amount (pg->conn, &dc->value), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_emergency_by_count_insert", + "INSERT INTO auditor_emergency_by_count " + "(denompub_h" + ",num_issued" + ",num_known" + ",risk" + ",start" + ",deposit_end" + ",value" + ") VALUES ($1,$2,$3,$4,$5,$6,$7);"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_emergency_by_count_insert", + params); +} diff --git a/src/auditordb/pg_insert_emergency_by_count.h b/src/auditordb/pg_insert_emergency_by_count.h new file mode 100644 index 000000000..7fc694243 --- /dev/null +++ b/src/auditordb/pg_insert_emergency_by_count.h @@ -0,0 +1,36 @@ +/* + 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_EMERGENCY_BY_COUNT_H +#define SRC_PG_INSERT_EMERGENCY_BY_COUNT_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a emergency 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_emergency_by_count ( + void *cls, + const struct TALER_AUDITORDB_EmergenciesByCount *dc); + +#endif // SRC_PG_INSERT_EMERGENCY_BY_COUNT_H diff --git a/src/auditordb/pg_insert_exchange_signkey.c b/src/auditordb/pg_insert_exchange_signkey.c index 8bf439da0..264b2b592 100644 --- a/src/auditordb/pg_insert_exchange_signkey.c +++ b/src/auditordb/pg_insert_exchange_signkey.c @@ -49,7 +49,14 @@ TAH_PG_insert_exchange_signkey ( ",ep_end" ",exchange_pub" ",master_sig" - ") VALUES ($1,$2,$3,$4,$5);"); + ") VALUES ($1,$2,$3,$4,$5)" + " ON CONFLICT (exchange_pub) DO UPDATE" + " SET ep_start = exclude.ep_start," + " ep_expire = exclude.ep_expire," + " ep_end = exclude.ep_end," + " master_sig = exclude.master_sig," + " suppressed = false;" + ); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_insert_exchange_signkey", params); diff --git a/src/auditordb/pg_insert_exchange_signkey.h b/src/auditordb/pg_insert_exchange_signkey.h index 1c1eefe35..6d92a95a3 100644 --- a/src/auditordb/pg_insert_exchange_signkey.h +++ b/src/auditordb/pg_insert_exchange_signkey.h @@ -18,13 +18,15 @@ * @brief implementation of the insert_exchange_signkey function * @author Christian Grothoff */ + +/* #ifndef PG_INSERT_EXCHANGE_SIGNKEY_H #define PG_INSERT_EXCHANGE_SIGNKEY_H #include "taler_util.h" #include "taler_json_lib.h" #include "taler_auditordb_plugin.h" - +*/ /** * Insert information about a signing key of the exchange. * @@ -32,6 +34,7 @@ * @param sk signing key information to store * @return query result status */ +/* enum GNUNET_DB_QueryStatus TAH_PG_insert_exchange_signkey ( void *cls, @@ -39,3 +42,4 @@ TAH_PG_insert_exchange_signkey ( #endif +*/
\ 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..892f8bc3a --- /dev/null +++ b/src/auditordb/pg_insert_exchange_signkeys.c @@ -0,0 +1,55 @@ +/* + 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_absolute_time (&dc->ep_valid_from), + GNUNET_PQ_query_param_absolute_time (&dc->ep_expire_sign), + GNUNET_PQ_query_param_absolute_time (&dc->ep_expire_legal), + + + 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" + ") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_exchange_signkeys_insert", + params); +} diff --git a/src/auditordb/pg_insert_exchange_signkeys.h b/src/auditordb/pg_insert_exchange_signkeys.h new file mode 100644 index 000000000..584c83ce2 --- /dev/null +++ b/src/auditordb/pg_insert_exchange_signkeys.h @@ -0,0 +1,37 @@ +/* + 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 diff --git a/src/auditordb/pg_insert_fee_time_inconsistency.c b/src/auditordb/pg_insert_fee_time_inconsistency.c new file mode 100644 index 000000000..ad1a8b25f --- /dev/null +++ b/src/auditordb/pg_insert_fee_time_inconsistency.c @@ -0,0 +1,50 @@ +/* + 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_fee_time_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_fee_time_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_FeeTimeInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + + GNUNET_PQ_query_param_string (dc->type), + GNUNET_PQ_query_param_absolute_time (&dc->time), + GNUNET_PQ_query_param_string (dc->diagnostic), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_fee_time_inconsistency_insert", + "INSERT INTO auditor_fee_time_inconsistency " + "(type" + ",time" + ",diagnostic" + ") VALUES ($1,$2,$3);"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_fee_time_inconsistency_insert", + params); +} diff --git a/src/auditordb/pg_insert_fee_time_inconsistency.h b/src/auditordb/pg_insert_fee_time_inconsistency.h new file mode 100644 index 000000000..0d90fca41 --- /dev/null +++ b/src/auditordb/pg_insert_fee_time_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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_FEE_TIME_INCONSISTENCY_H +#define SRC_PG_INSERT_FEE_TIME_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a fee time inconsistency 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_fee_time_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_FeeTimeInconsistency *dc); + +#endif // SRC_PG_INSERT_FEE_TIME_INCONSISTENCY_H diff --git a/src/auditordb/pg_insert_historic_denom_revenue.h b/src/auditordb/pg_insert_historic_denom_revenue.h index 02567119b..abc19f868 100644 --- a/src/auditordb/pg_insert_historic_denom_revenue.h +++ b/src/auditordb/pg_insert_historic_denom_revenue.h @@ -18,6 +18,7 @@ * @brief implementation of the insert_historic_denom_revenue function * @author Christian Grothoff */ +/* #ifndef PG_INSERT_HISTORIC_DENOM_REVENUE_H #define PG_INSERT_HISTORIC_DENOM_REVENUE_H @@ -25,7 +26,7 @@ #include "taler_json_lib.h" #include "taler_auditordb_plugin.h" - +*/ /** * Insert information about an exchange's historic * revenue about a denomination key. @@ -39,6 +40,7 @@ * @param loss_balance total losses suffered by the exchange at the time * @return transaction status code */ +/* enum GNUNET_DB_QueryStatus TAH_PG_insert_historic_denom_revenue ( void *cls, @@ -48,3 +50,4 @@ TAH_PG_insert_historic_denom_revenue ( const struct TALER_Amount *loss_balance); #endif +*/
\ 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..3067e6ea9 --- /dev/null +++ b/src/auditordb/pg_insert_historic_denomination_revenue.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_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_absolute_time (&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_end + }; + + PREPARE (pg, + "auditor_historic_denomination_revenue_insert", + "INSERT INTO auditor_historic_denomination_revenue " + "( denom_pub_hash," + " revenue_timestamp," + " revenue_balance," + " loss_balance" + ") VALUES ($1,$2,$3,$4)" + " ON CONFLICT (denom_pub_hash) DO UPDATE" + " SET revenue_timestamp = excluded.revenue_timestamp," + " revenue_balance = excluded.revenue_balance," + " loss_balance = excluded.loss_balance," + " suppresssed = false;" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_historic_denomination_revenue_insert", + params); +} 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..bc81f5a9b --- /dev/null +++ b/src/auditordb/pg_insert_historic_denomination_revenue.h @@ -0,0 +1,37 @@ +/* + 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 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..1f49ae0d2 --- /dev/null +++ b/src/auditordb/pg_insert_historic_reserve_summary.c @@ -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/> + */ + + +#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_absolute_time (&dc->start_date), + GNUNET_PQ_query_param_absolute_time (&dc->end_date), + TALER_PQ_query_param_amount (pg->conn, &dc->reserve_profits), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_historic_reserve_summary_insert", + "INSERT INTO auditor_historic_reserve_summary " + "( start_date," + " end_date," + " reserve_profits" + ") VALUES ($1,$2,$3);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_historic_reserve_summary_insert", + params); +} 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..c10c2989f --- /dev/null +++ b/src/auditordb/pg_insert_historic_reserve_summary.h @@ -0,0 +1,37 @@ +/* + 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 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..843b8933e --- /dev/null +++ b/src/auditordb/pg_insert_misattribution_in_inconsistency.c @@ -0,0 +1,52 @@ +/* + 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_end + }; + + PREPARE (pg, + "auditor_misattribution_in_inconsistency_insert", + "INSERT INTO auditor_misattribution_in_inconsistency " + "( row_id," + " amount," + " bank_row," + " reserve_pub" + ") VALUES ($1,$2,$3,$4);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_misattribution_in_inconsistency_insert", + params); +} 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..a3a97f643 --- /dev/null +++ b/src/auditordb/pg_insert_misattribution_in_inconsistency.h @@ -0,0 +1,37 @@ +/* + 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 diff --git a/src/auditordb/pg_insert_purse_not_closed_inconsistencies.c b/src/auditordb/pg_insert_purse_not_closed_inconsistencies.c new file mode 100644 index 000000000..7ae2dc7d8 --- /dev/null +++ b/src/auditordb/pg_insert_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_insert_purse_not_closed_inconsistencies.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_purse_not_closed_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type (&dc->purse_pub), + TALER_PQ_query_param_amount (pg->conn, &dc->amount), + GNUNET_PQ_query_param_absolute_time (&dc->expiration_date), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_purse_not_closed_inconsistencies_insert", + "INSERT INTO auditor_purse_not_closed_inconsistencies " + "(purse_pub" + ",amount" + ",expiration_date" + ") VALUES ($1,$2,$3)" + " ON CONFLICT (purse_pub) DO UPDATE" + " SET amount = excluded.amount," + " expiration_date = excluded.expiration_date," + " suppressed = false;" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_purse_not_closed_inconsistencies_insert", + params); +} diff --git a/src/auditordb/pg_insert_purse_not_closed_inconsistencies.h b/src/auditordb/pg_insert_purse_not_closed_inconsistencies.h new file mode 100644 index 000000000..61705b69b --- /dev/null +++ b/src/auditordb/pg_insert_purse_not_closed_inconsistencies.h @@ -0,0 +1,36 @@ +/* + 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_PURSE_NOT_CLOSED_INCONSISTENCIES_H +#define SRC_PG_INSERT_PURSE_NOT_CLOSED_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a purse not closed inconsistencies 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_purse_not_closed_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc); + +#endif // SRC_PG_INSERT_PURSE_NOT_CLOSED_INCONSISTENCIES_H diff --git a/src/auditordb/pg_insert_purses.c b/src/auditordb/pg_insert_purses.c new file mode 100644 index 000000000..2bbf096fe --- /dev/null +++ b/src/auditordb/pg_insert_purses.c @@ -0,0 +1,55 @@ +/* + 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_absolute_time (&dc->expiration_date), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_purses_insert", + "INSERT INTO auditor_purses " + "( auditor_purses_rowid," + " purse_pub," + " balance," + " target," + " expiration_date" + ") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_purses_insert", + params); +} diff --git a/src/auditordb/pg_insert_purses.h b/src/auditordb/pg_insert_purses.h new file mode 100644 index 000000000..14f5e838f --- /dev/null +++ b/src/auditordb/pg_insert_purses.h @@ -0,0 +1,37 @@ +/* + 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 diff --git a/src/auditordb/pg_insert_refreshes_hanging.c b/src/auditordb/pg_insert_refreshes_hanging.c new file mode 100644 index 000000000..5a7fe018c --- /dev/null +++ b/src/auditordb/pg_insert_refreshes_hanging.c @@ -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/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_refreshes_hanging.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_refreshes_hanging ( + void *cls, + const struct TALER_AUDITORDB_RefreshesHanging *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + TALER_PQ_query_param_amount (pg->conn, &dc->amount), + GNUNET_PQ_query_param_auto_from_type (&dc->coin_pub), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_refreshes_hanging_insert", + "INSERT INTO auditor_refreshes_hanging " + "(amount" + ",coin_pub" + ") VALUES ($1,$2)" + " ON CONFLICT (coin_pub) DO UPDATE" + " SET amount = excluded.amount," + " suppressed = false;" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_refreshes_hanging_insert", + params); +} diff --git a/src/auditordb/pg_insert_refreshes_hanging.h b/src/auditordb/pg_insert_refreshes_hanging.h new file mode 100644 index 000000000..9965a5f62 --- /dev/null +++ b/src/auditordb/pg_insert_refreshes_hanging.h @@ -0,0 +1,36 @@ +/* + 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_REFRESHES_HANGING_H +#define SRC_PG_INSERT_REFRESHES_HANGING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a refreshes hanging 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_refreshes_hanging ( + void *cls, + const struct TALER_AUDITORDB_RefreshesHanging *dc); + +#endif // SRC_PG_INSERT_REFRESHES_HANGING_H diff --git a/src/auditordb/pg_insert_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_insert_reserve_balance_insufficient_inconsistency.c new file mode 100644 index 000000000..d50da9fde --- /dev/null +++ b/src/auditordb/pg_insert_reserve_balance_insufficient_inconsistency.c @@ -0,0 +1,49 @@ +/* + 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_insufficient_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_balance_insufficient_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type (&dc->reserve_pub), + GNUNET_PQ_query_param_bool (dc->inconsistency_gain), + TALER_PQ_query_param_amount (pg->conn, &dc->inconsistency_amount), + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserve_balance_insufficient_inconsistency_insert", + "INSERT INTO auditor_reserve_balance_insufficient_inconsistency " + "(reserve_pub" + ",inconsistency_gain" + ",inconsistency_amount" + ") VALUES ($1,$2,$3);"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_balance_insufficient_inconsistency_insert", + params); +} diff --git a/src/auditordb/pg_insert_reserve_balance_insufficient_inconsistency.h b/src/auditordb/pg_insert_reserve_balance_insufficient_inconsistency.h new file mode 100644 index 000000000..49f262707 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_balance_insufficient_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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_INSUFFICIENT_INCONSISTENCY_H +#define SRC_PG_INSERT_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a reserve balance inconsistency 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_insufficient_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency *dc); + +#endif // SRC_PG_INSERT_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H 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..d5002d793 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,50 @@ +/* + 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_end + }; + + PREPARE (pg, + "auditor_reserve_balance_summary_wrong_inconsistency_insert", + "INSERT INTO auditor_reserve_balance_summary_wrong_inconsistency " + "(reserve_pub," + " exchange_amount," + " auditor_amount" + ") VALUES ($1,$2,$3);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_balance_summary_wrong_inconsistency_insert", + params); +} 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..ac5ba5d58 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,37 @@ +/* + 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 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..9c98b7ace --- /dev/null +++ b/src/auditordb/pg_insert_reserve_in_inconsistency.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_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_absolute_time (&dc->timestamp), + GNUNET_PQ_query_param_auto_from_type (&dc->account), + GNUNET_PQ_query_param_auto_from_type (&dc->diagnostic), + + + 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" + ") VALUES ($1,$2,$3,$4,$5,$6,$7);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_in_inconsistency_insert", + params); +} 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..5e26ce3bf --- /dev/null +++ b/src/auditordb/pg_insert_reserve_in_inconsistency.h @@ -0,0 +1,37 @@ +/* + 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 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..86d1393cb --- /dev/null +++ b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c @@ -0,0 +1,53 @@ +/* + 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_absolute_time (&dc->expiration_time), + GNUNET_PQ_query_param_auto_from_type (&dc->diagnostic), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserve_not_closed_inconsistency_insert", + "INSERT INTO auditor_reserve_not_closed_inconsistency " + "( reserve_pub," + " balance," + " expiration_time," + " diagnostic" + ") VALUES ($1,$2,$3,$4);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_not_closed_inconsistency_insert", + params); +} 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..27cb35e77 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.h @@ -0,0 +1,37 @@ +/* + 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 diff --git a/src/auditordb/pg_insert_reserves.c b/src/auditordb/pg_insert_reserves.c new file mode 100644 index 000000000..cda4df72a --- /dev/null +++ b/src/auditordb/pg_insert_reserves.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_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_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_absolute_time (&dc->expiration_date), + GNUNET_PQ_query_param_string (dc->origin_account), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserves_insert", + "INSERT INTO auditor_reserves " + " ( 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" + ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserves_insert", + params); +} diff --git a/src/auditordb/pg_insert_reserves.h b/src/auditordb/pg_insert_reserves.h new file mode 100644 index 000000000..feeca07d1 --- /dev/null +++ b/src/auditordb/pg_insert_reserves.h @@ -0,0 +1,37 @@ +/* + 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 diff --git a/src/auditordb/pg_insert_row_inconsistency.c b/src/auditordb/pg_insert_row_inconsistency.c new file mode 100644 index 000000000..d9155d68c --- /dev/null +++ b/src/auditordb/pg_insert_row_inconsistency.c @@ -0,0 +1,46 @@ +/* + 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_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_row_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_RowInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_string (dc->row_table), + GNUNET_PQ_query_param_string (dc->diagnostic), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_deposit_confirmation_insert", + "INSERT INTO auditor_row_inconsistency " + "(row_table" + ",diagnostic" + ") VALUES ($1,$2);"); + + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_deposit_confirmation_insert", + params); +} diff --git a/src/auditordb/pg_insert_row_inconsistency.h b/src/auditordb/pg_insert_row_inconsistency.h new file mode 100644 index 000000000..280ef2f04 --- /dev/null +++ b/src/auditordb/pg_insert_row_inconsistency.h @@ -0,0 +1,36 @@ +/* + 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_INCONSISTENCY_H +#define SRC_PG_INSERT_ROW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a deposit confirmation 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_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_RowInconsistency *dc); + +#endif // SRC_PG_INSERT_ROW_INCONSISTENCY_H 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..84607fa3c --- /dev/null +++ b/src/auditordb/pg_insert_row_minor_inconsistencies.c @@ -0,0 +1,50 @@ +/* + 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_end + }; + + PREPARE (pg, + "auditor_row_minor_inconsistencies_insert", + "INSERT INTO auditor_row_minor_inconsistencies " + "( row_id," + " row_table," + " diagnostic" + ") VALUES ($1,$2,$3);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_row_minor_inconsistencies_insert", + params); +} 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..8d4832163 --- /dev/null +++ b/src/auditordb/pg_insert_row_minor_inconsistencies.h @@ -0,0 +1,37 @@ +/* + 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 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..c4b5b16dc --- /dev/null +++ b/src/auditordb/pg_insert_wire_format_inconsistency.c @@ -0,0 +1,52 @@ +/* + 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_end + }; + + PREPARE (pg, + "auditor_wire_format_inconsistency_insert", + "INSERT INTO auditor_wire_format_inconsistency " + "( row_id," + " amount," + " wire_offset," + " diagnostic" + ") VALUES ($1,$2,$3,$4);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_wire_format_inconsistency_insert", + params); +} 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..5487738f6 --- /dev/null +++ b/src/auditordb/pg_insert_wire_format_inconsistency.h @@ -0,0 +1,37 @@ +/* + 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 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..828aa3293 --- /dev/null +++ b/src/auditordb/pg_insert_wire_out_inconsistency.c @@ -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/> + */ + + +#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_string (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_end + }; + + PREPARE (pg, + "auditor_wire_out_inconsistency_insert", + "INSERT INTO auditor_wire_out_inconsistency " + "( destination_account," + " expected," + " claimed" + ") VALUES ($1,$2,$3);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_wire_out_inconsistency_insert", + params); +} 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..96c0b3ad3 --- /dev/null +++ b/src/auditordb/pg_insert_wire_out_inconsistency.h @@ -0,0 +1,37 @@ +/* + 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 diff --git a/src/auditordb/pg_select_purse_expired.c b/src/auditordb/pg_select_purse_expired.c index 77c6d3b26..5fda60103 100644 --- a/src/auditordb/pg_select_purse_expired.c +++ b/src/auditordb/pg_select_purse_expired.c @@ -133,7 +133,7 @@ TAH_PG_select_purse_expired ( ",expiration_date" ",balance" " FROM auditor_purses" - " AND expiration_date<$1;"); + " WHERE expiration_date<$1;"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "auditor_select_expired_purses", params, diff --git a/src/auditordb/pg_update_amount_arithmetic_inconsistency.c b/src/auditordb/pg_update_amount_arithmetic_inconsistency.c new file mode 100644 index 000000000..581d5c4d8 --- /dev/null +++ b/src/auditordb/pg_update_amount_arithmetic_inconsistency.c @@ -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/> + */ + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_amount_arithmetic_inconsistency.h" + + +enum GNUNET_DB_QueryStatus +TAH_PG_update_amount_arithmetic_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_amount_arithmetic_inconsistency", + "UPDATE auditor_amount_arithmetic_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_amount_arithmetic_inconsistency", + params); +} diff --git a/src/auditordb/pg_update_amount_arithmetic_inconsistency.h b/src/auditordb/pg_update_amount_arithmetic_inconsistency.h new file mode 100644 index 000000000..2ad99ea41 --- /dev/null +++ b/src/auditordb/pg_update_amount_arithmetic_inconsistency.h @@ -0,0 +1,28 @@ +/* + 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_AMOUNT_ARITHMETIC_INCONSISTENCY_H +#define SRC_PG_UPDATE_AMOUNT_ARITHMETIC_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_amount_arithmetic_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_AMOUNT_ARITHMETIC_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_bad_sig_losses.c b/src/auditordb/pg_update_bad_sig_losses.c new file mode 100644 index 000000000..4fdb1ae94 --- /dev/null +++ b/src/auditordb/pg_update_bad_sig_losses.c @@ -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/> + */ + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_bad_sig_losses.h" + + +enum GNUNET_DB_QueryStatus +TAH_PG_update_bad_sig_losses ( + 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_bad_sig_losses", + "UPDATE auditor_bad_sig_losses SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_bad_sig_losses", + params); +} diff --git a/src/auditordb/pg_update_bad_sig_losses.h b/src/auditordb/pg_update_bad_sig_losses.h new file mode 100644 index 000000000..aa36bb847 --- /dev/null +++ b/src/auditordb/pg_update_bad_sig_losses.h @@ -0,0 +1,28 @@ +/* + 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_BAD_SIG_LOSSES_H +#define SRC_PG_UPDATE_BAD_SIG_LOSSES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_bad_sig_losses ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_BAD_SIG_LOSSES_H diff --git a/src/auditordb/pg_update_balances.c b/src/auditordb/pg_update_balances.c new file mode 100644 index 000000000..110184ed0 --- /dev/null +++ b/src/auditordb/pg_update_balances.c @@ -0,0 +1,48 @@ +/* + 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_balances.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_balances ( + 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_balances", + "UPDATE auditor_balances SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_balances", + params); +} diff --git a/src/auditordb/pg_update_balances.h b/src/auditordb/pg_update_balances.h new file mode 100644 index 000000000..4253897e5 --- /dev/null +++ b/src/auditordb/pg_update_balances.h @@ -0,0 +1,29 @@ +/* + 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_BALANCES_H +#define SRC_PG_UPDATE_BALANCES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_balances ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_BALANCES_H diff --git a/src/auditordb/pg_update_closure_lags.c b/src/auditordb/pg_update_closure_lags.c new file mode 100644 index 000000000..a49d29f3e --- /dev/null +++ b/src/auditordb/pg_update_closure_lags.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_closure_lags.h b/src/auditordb/pg_update_closure_lags.h new file mode 100644 index 000000000..61c9e264a --- /dev/null +++ b/src/auditordb/pg_update_closure_lags.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_coin_inconsistency.c b/src/auditordb/pg_update_coin_inconsistency.c new file mode 100644 index 000000000..e9d845690 --- /dev/null +++ b/src/auditordb/pg_update_coin_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_coin_inconsistency.h b/src/auditordb/pg_update_coin_inconsistency.h new file mode 100644 index 000000000..73c5223e8 --- /dev/null +++ b/src/auditordb/pg_update_coin_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 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..a9b3f820f --- /dev/null +++ b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..574f67b22 --- /dev/null +++ b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_denomination_pending.c b/src/auditordb/pg_update_denomination_pending.c new file mode 100644 index 000000000..62129aeaf --- /dev/null +++ b/src/auditordb/pg_update_denomination_pending.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_denomination_pending.h b/src/auditordb/pg_update_denomination_pending.h new file mode 100644 index 000000000..eebed2b0c --- /dev/null +++ b/src/auditordb/pg_update_denomination_pending.h @@ -0,0 +1,29 @@ +/* + 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 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..39a26a694 --- /dev/null +++ b/src/auditordb/pg_update_denominations_without_sigs.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..bb126224e --- /dev/null +++ b/src/auditordb/pg_update_denominations_without_sigs.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_deposit_confirmations.c b/src/auditordb/pg_update_deposit_confirmations.c new file mode 100644 index 000000000..f8774069f --- /dev/null +++ b/src/auditordb/pg_update_deposit_confirmations.c @@ -0,0 +1,48 @@ +/* + 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_deposit_confirmations.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_deposit_confirmations ( + 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_deposit_confirmations", + "UPDATE auditor_deposit_confirmations SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_deposit_confirmations", + params); +} diff --git a/src/auditordb/pg_update_deposit_confirmations.h b/src/auditordb/pg_update_deposit_confirmations.h new file mode 100644 index 000000000..0d2e81d60 --- /dev/null +++ b/src/auditordb/pg_update_deposit_confirmations.h @@ -0,0 +1,29 @@ +/* + 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_DEPOSIT_CONFIRMATIONS_H +#define SRC_PG_UPDATE_DEPOSIT_CONFIRMATIONS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_deposit_confirmations ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_DEPOSIT_CONFIRMATIONS_H diff --git a/src/auditordb/pg_update_emergency.c b/src/auditordb/pg_update_emergency.c new file mode 100644 index 000000000..41956675d --- /dev/null +++ b/src/auditordb/pg_update_emergency.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_emergency.h b/src/auditordb/pg_update_emergency.h new file mode 100644 index 000000000..98028dfca --- /dev/null +++ b/src/auditordb/pg_update_emergency.h @@ -0,0 +1,29 @@ +/* + 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 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..d2c67831c --- /dev/null +++ b/src/auditordb/pg_update_emergency_by_count.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..fa60241d2 --- /dev/null +++ b/src/auditordb/pg_update_emergency_by_count.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_exchange_signkeys.c b/src/auditordb/pg_update_exchange_signkeys.c new file mode 100644 index 000000000..d0b91f8f9 --- /dev/null +++ b/src/auditordb/pg_update_exchange_signkeys.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_exchange_signkeys.h b/src/auditordb/pg_update_exchange_signkeys.h new file mode 100644 index 000000000..266c383c1 --- /dev/null +++ b/src/auditordb/pg_update_exchange_signkeys.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_fee_time_inconsistency.c b/src/auditordb/pg_update_fee_time_inconsistency.c new file mode 100644 index 000000000..fe324edf8 --- /dev/null +++ b/src/auditordb/pg_update_fee_time_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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_fee_time_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_fee_time_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_fee_time_inconsistency", + "UPDATE auditor_fee_time_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_fee_time_inconsistency", + params); +} diff --git a/src/auditordb/pg_update_fee_time_inconsistency.h b/src/auditordb/pg_update_fee_time_inconsistency.h new file mode 100644 index 000000000..ef55de19f --- /dev/null +++ b/src/auditordb/pg_update_fee_time_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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_FEE_TIME_INCONSISTENCY_H +#define SRC_PG_UPDATE_FEE_TIME_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_fee_time_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_FEE_TIME_INCONSISTENCY_H 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..376fa744e --- /dev/null +++ b/src/auditordb/pg_update_historic_denomination_revenue.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..c2e27f709 --- /dev/null +++ b/src/auditordb/pg_update_historic_denomination_revenue.h @@ -0,0 +1,29 @@ +/* + 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 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..f3eeff102 --- /dev/null +++ b/src/auditordb/pg_update_historic_reserve_summary.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..8267666a0 --- /dev/null +++ b/src/auditordb/pg_update_historic_reserve_summary.h @@ -0,0 +1,29 @@ +/* + 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 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..5b1b46b04 --- /dev/null +++ b/src/auditordb/pg_update_misattribution_in_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..840168fcc --- /dev/null +++ b/src/auditordb/pg_update_misattribution_in_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_progress.c b/src/auditordb/pg_update_progress.c new file mode 100644 index 000000000..75786c536 --- /dev/null +++ b/src/auditordb/pg_update_progress.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_progress.h b/src/auditordb/pg_update_progress.h new file mode 100644 index 000000000..3f5abedf1 --- /dev/null +++ b/src/auditordb/pg_update_progress.h @@ -0,0 +1,29 @@ +/* + 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 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..97d661d3d --- /dev/null +++ b/src/auditordb/pg_update_purse_not_closed_inconsistencies.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..66a677476 --- /dev/null +++ b/src/auditordb/pg_update_purse_not_closed_inconsistencies.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_purses.c b/src/auditordb/pg_update_purses.c new file mode 100644 index 000000000..f0147e0c4 --- /dev/null +++ b/src/auditordb/pg_update_purses.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_purses.h b/src/auditordb/pg_update_purses.h new file mode 100644 index 000000000..22820fcb5 --- /dev/null +++ b/src/auditordb/pg_update_purses.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_refreshes_hanging.c b/src/auditordb/pg_update_refreshes_hanging.c new file mode 100644 index 000000000..f2dfd0789 --- /dev/null +++ b/src/auditordb/pg_update_refreshes_hanging.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_refreshes_hanging.h b/src/auditordb/pg_update_refreshes_hanging.h new file mode 100644 index 000000000..071add3cd --- /dev/null +++ b/src/auditordb/pg_update_refreshes_hanging.h @@ -0,0 +1,29 @@ +/* + 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 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..93302c51f --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..ccc8d0715 --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 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..ff95de80c --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..341acac1e --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 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..f905e3750 --- /dev/null +++ b/src/auditordb/pg_update_reserve_in_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..5eacb68da --- /dev/null +++ b/src/auditordb/pg_update_reserve_in_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 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..4eea64fee --- /dev/null +++ b/src/auditordb/pg_update_reserve_not_closed_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..4739bc5f6 --- /dev/null +++ b/src/auditordb/pg_update_reserve_not_closed_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_reserves.c b/src/auditordb/pg_update_reserves.c new file mode 100644 index 000000000..7a6d7d6aa --- /dev/null +++ b/src/auditordb/pg_update_reserves.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_reserves.h b/src/auditordb/pg_update_reserves.h new file mode 100644 index 000000000..567037b78 --- /dev/null +++ b/src/auditordb/pg_update_reserves.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/pg_update_row_inconsistency.c b/src/auditordb/pg_update_row_inconsistency.c new file mode 100644 index 000000000..985f7e2ee --- /dev/null +++ b/src/auditordb/pg_update_row_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} diff --git a/src/auditordb/pg_update_row_inconsistency.h b/src/auditordb/pg_update_row_inconsistency.h new file mode 100644 index 000000000..d6431558f --- /dev/null +++ b/src/auditordb/pg_update_row_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 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..36ba5d62f --- /dev/null +++ b/src/auditordb/pg_update_row_minor_inconsistencies.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..fccb9fa99 --- /dev/null +++ b/src/auditordb/pg_update_row_minor_inconsistencies.h @@ -0,0 +1,29 @@ +/* + 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 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..70953582d --- /dev/null +++ b/src/auditordb/pg_update_wire_format_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..32a612afc --- /dev/null +++ b/src/auditordb/pg_update_wire_format_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 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..543ce3cc6 --- /dev/null +++ b/src/auditordb/pg_update_wire_out_inconsistency.c @@ -0,0 +1,48 @@ +/* + 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); +} 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..3032a6c0e --- /dev/null +++ b/src/auditordb/pg_update_wire_out_inconsistency.h @@ -0,0 +1,29 @@ +/* + 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 diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index f5c405d8d..0e8c6ed44 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -56,7 +56,146 @@ #include "pg_update_purse_info.h" #include "pg_update_reserve_info.h" #include "pg_update_wire_fee_summary.h" - +#include "pg_get_amount_arithmetic_inconsistency.h" +#include "pg_get_coin_inconsistency.h" +#include "pg_get_row_inconsistency.h" +#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" +#include "pg_del_row_inconsistency.h" + +#include "pg_insert_coin_inconsistency.h" +#include "pg_insert_row_inconsistency.h" +#include "pg_insert_amount_arithmetic_inconsistency.h" + +#include "pg_get_auditor_closure_lags.h" +#include "pg_del_auditor_closure_lags.h" +#include "pg_insert_auditor_closure_lags.h" + +#include "pg_get_emergency_by_count.h" +#include "pg_del_emergency_by_count.h" +#include "pg_insert_emergency_by_count.h" + +#include "pg_get_emergency.h" +#include "pg_del_emergency.h" +#include "pg_insert_emergency.h" + +#include "pg_del_auditor_progress.h" + +#include "pg_get_bad_sig_losses.h" +#include "pg_del_bad_sig_losses.h" +#include "pg_insert_bad_sig_losses.h" +#include "pg_update_bad_sig_losses.h" + +#include "pg_get_denomination_key_validity_withdraw_inconsistency.h" +#include "pg_del_denomination_key_validity_withdraw_inconsistency.h" +#include "pg_insert_denomination_key_validity_withdraw_inconsistency.h" + +#include "pg_get_fee_time_inconsistency.h" +#include "pg_del_fee_time_inconsistency.h" +#include "pg_insert_fee_time_inconsistency.h" +#include "pg_update_fee_time_inconsistency.h" + +#include "pg_get_purse_not_closed_inconsistencies.h" +#include "pg_del_purse_not_closed_inconsistencies.h" +#include "pg_insert_purse_not_closed_inconsistencies.h" + +#include "pg_get_refreshes_hanging.h" +#include "pg_del_refreshes_hanging.h" +#include "pg_insert_refreshes_hanging.h" + +#include "pg_get_reserve_balance_insufficient_inconsistency.h" +#include "pg_del_reserve_balance_insufficient_inconsistency.h" +#include "pg_insert_reserve_balance_insufficient_inconsistency.h" + +#include "pg_get_reserve_in_inconsistency.h" +#include "pg_del_reserve_in_inconsistency.h" +#include "pg_insert_reserve_in_inconsistency.h" +#include "pg_update_reserve_in_inconsistency.h" + +#include "pg_get_reserve_not_closed_inconsistency.h" +#include "pg_del_reserve_not_closed_inconsistency.h" +#include "pg_insert_reserve_not_closed_inconsistency.h" +#include "pg_update_reserve_not_closed_inconsistency.h" + +#include "pg_get_denominations_without_sigs.h" +#include "pg_del_denominations_without_sigs.h" +#include "pg_insert_denominations_without_sigs.h" +#include "pg_update_denominations_without_sigs.h" + +#include "pg_get_misattribution_in_inconsistency.h" +#include "pg_del_misattribution_in_inconsistency.h" +#include "pg_insert_misattribution_in_inconsistency.h" +#include "pg_update_misattribution_in_inconsistency.h" + +#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" + +#include "pg_get_balances.h" +#include "pg_del_balances.h" +#include "pg_insert_balances.h" +#include "pg_update_balances.h" + +#include "pg_update_amount_arithmetic_inconsistency.h" +#include "pg_update_deposit_confirmations.h" #define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", \ __VA_ARGS__) @@ -449,6 +588,9 @@ libtaler_plugin_auditordb_postgres_init (void *cls) GNUNET_free (pg); return NULL; } + + // MARK: CRUD + plugin = GNUNET_new (struct TALER_AUDITORDB_Plugin); plugin->cls = pg; plugin->preflight = &postgres_preflight; @@ -464,8 +606,9 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->get_auditor_progress = &TAH_PG_get_auditor_progress; - plugin->get_balance - = &TAH_PG_get_balance; + + plugin->get_balance = &TAH_PG_get_balance; + plugin->insert_auditor_progress = &TAH_PG_insert_auditor_progress; plugin->insert_balance @@ -474,9 +617,10 @@ libtaler_plugin_auditordb_postgres_init (void *cls) = &TAH_PG_update_auditor_progress; plugin->update_balance = &TAH_PG_update_balance; - +/* plugin->insert_exchange_signkey = &TAH_PG_insert_exchange_signkey; + */ plugin->insert_deposit_confirmation = &TAH_PG_insert_deposit_confirmation; plugin->get_deposit_confirmations @@ -484,6 +628,30 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->delete_deposit_confirmation = &TAH_PG_delete_deposit_confirmation; + + plugin->get_amount_arithmetic_inconsistency + = &TAH_PG_get_amount_arithmetic_inconsistency; + plugin->get_coin_inconsistency + = &TAH_PG_get_coin_inconsistency; + plugin->get_row_inconsistency + = &TAH_PG_get_row_inconsistency; + + + plugin->delete_row_inconsistency + = &TAH_PG_del_row_inconsistency; + plugin->delete_coin_inconsistency + = &TAH_PG_del_coin_inconsistency; + plugin->delete_amount_arithmetic_inconsistency + = &TAH_PG_del_amount_arithmetic_inconsistency; + + + plugin->insert_amount_arithmetic_inconsistency + = &TAH_PG_insert_amount_arithmetic_inconsistency; + plugin->insert_coin_inconsistency + = &TAH_PG_insert_coin_inconsistency; + plugin->insert_row_inconsistency + = &TAH_PG_insert_row_inconsistency; + plugin->insert_reserve_info = &TAH_PG_insert_reserve_info; plugin->update_reserve_info @@ -519,9 +687,10 @@ libtaler_plugin_auditordb_postgres_init (void *cls) = &TAH_PG_del_denomination_balance; plugin->get_denomination_balance = &TAH_PG_get_denomination_balance; - +/* plugin->insert_historic_denom_revenue = &TAH_PG_insert_historic_denom_revenue; + */ plugin->select_historic_denom_revenue = &TAH_PG_select_historic_denom_revenue; @@ -530,6 +699,199 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->select_historic_reserve_revenue = &TAH_PG_select_historic_reserve_revenue; + + plugin->delete_emergency = &TAH_PG_del_emergency; + plugin->insert_emergency = &TAH_PG_insert_emergency; + plugin->get_emergency = &TAH_PG_get_emergency; + + plugin->delete_emergency_by_count = &TAH_PG_del_emergency_by_count; + plugin->insert_emergency_by_count = &TAH_PG_insert_emergency_by_count; + plugin->get_emergency_by_count = &TAH_PG_get_emergency_by_count; + + + plugin->delete_denomination_key_validity_withdraw_inconsistency = + &TAH_PG_del_denomination_key_validity_withdraw_inconsistency; + plugin->insert_denomination_key_validity_withdraw_inconsistency = + &TAH_PG_insert_denomination_key_validity_withdraw_inconsistency; + plugin->get_denomination_key_validity_withdraw_inconsistency = + &TAH_PG_get_denomination_key_validity_withdraw_inconsistency; + + plugin->delete_purse_not_closed_inconsistencies = + &TAH_PG_del_purse_not_closed_inconsistencies; + plugin->insert_purse_not_closed_inconsistencies = + &TAH_PG_insert_purse_not_closed_inconsistencies; + plugin->get_purse_not_closed_inconsistencies = + &TAH_PG_get_purse_not_closed_inconsistencies; + + + plugin->delete_reserve_balance_insufficient_inconsistency = + &TAH_PG_del_reserve_balance_insufficient_inconsistency; + plugin->insert_reserve_balance_insufficient_inconsistency = + &TAH_PG_insert_reserve_balance_insufficient_inconsistency; + plugin->get_reserve_balance_insufficient_inconsistency = + &TAH_PG_get_reserve_balance_insufficient_inconsistency; + + plugin->delete_bad_sig_losses = &TAH_PG_del_bad_sig_losses; + plugin->insert_bad_sig_losses = &TAH_PG_insert_bad_sig_losses; + plugin->get_bad_sig_losses = &TAH_PG_get_bad_sig_losses; + plugin->update_bad_sig_losses = &TAH_PG_update_bad_sig_losses; + + plugin->delete_auditor_closure_lags = &TAH_PG_del_auditor_closure_lags; + plugin->insert_auditor_closure_lags = &TAH_PG_insert_auditor_closure_lags; + plugin->get_auditor_closure_lags = &TAH_PG_get_auditor_closure_lags; + + + plugin->delete_progress = &TAH_PG_del_progress; + + + plugin->delete_refreshes_hanging = &TAH_PG_del_refreshes_hanging; + plugin->insert_refreshes_hanging = &TAH_PG_insert_refreshes_hanging; + plugin->get_refreshes_hanging = &TAH_PG_get_refreshes_hanging; + + 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; + + plugin->delete_fee_time_inconsistency = &TAH_PG_del_fee_time_inconsistency; + plugin->insert_fee_time_inconsistency = &TAH_PG_insert_fee_time_inconsistency; + plugin->get_fee_time_inconsistency = &TAH_PG_get_fee_time_inconsistency; + plugin->update_fee_time_inconsistency = &TAH_PG_update_fee_time_inconsistency; + + plugin->delete_balances = &TAH_PG_del_balances; + plugin->insert_balances = &TAH_PG_insert_balances; + plugin->get_balances = &TAH_PG_get_balances; + plugin->update_balances = &TAH_PG_update_balances; + + plugin->update_deposit_confirmations = &TAH_PG_update_deposit_confirmations; + plugin->update_amount_arithmetic_inconsistency = + &TAH_PG_update_amount_arithmetic_inconsistency; + return plugin; } |