exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit d16350ef1085bc16f2ef04eb8fe60edeb0f6978d
parent 94339b2d73c6df0d61ee18f60e2a4b16bc56c750
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 28 Aug 2024 22:42:33 +0200

fix patch from Nic and also fix various other auditor bugs found during review

Diffstat:
Msrc/auditor/taler-helper-auditor-aggregation.c | 8+++++---
Msrc/auditor/taler-helper-auditor-coins.c | 12+++++++++++-
Msrc/auditor/taler-helper-auditor-purses.c | 9+++++----
Msrc/auditor/taler-helper-auditor-reserves.c | 16++++++++--------
Msrc/auditor/taler-helper-auditor-wire-debit.c | 1+
Msrc/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql | 8++------
Msrc/auditordb/0002-auditor_bad_sig_losses.sql | 6++----
Msrc/auditordb/0002-auditor_closure_lags.sql | 3+--
Msrc/auditordb/0002-auditor_coin_inconsistency.sql | 8+++-----
Msrc/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql | 7+++----
Msrc/auditordb/0002-auditor_denominations_without_sigs.sql | 2--
Msrc/auditordb/0002-auditor_deposit_confirmations.sql | 1-
Msrc/auditordb/0002-auditor_emergency.sql | 9+++------
Msrc/auditordb/0002-auditor_emergency_by_count.sql | 6++----
Msrc/auditordb/0002-auditor_fee_time_inconsistency.sql | 1-
Msrc/auditordb/0002-auditor_historic_denomination_revenue.sql | 5++---
Msrc/auditordb/0002-auditor_historic_reserve_summary.sql | 3---
Msrc/auditordb/0002-auditor_misattribution_in_inconsistency.sql | 5++---
Msrc/auditordb/0002-auditor_pending_deposits.sql | 1-
Msrc/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql | 7+++----
Msrc/auditordb/0002-auditor_purses.sql | 3+--
Msrc/auditordb/0002-auditor_refreshes_hanging.sql | 5++---
Msrc/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql | 2--
Msrc/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql | 5++---
Msrc/auditordb/0002-auditor_reserve_in_inconsistency.sql | 2+-
Msrc/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql | 4+---
Msrc/auditordb/0002-auditor_reserves.sql | 1-
Msrc/auditordb/0002-auditor_row_inconsistency.sql | 3+--
Msrc/auditordb/0002-auditor_wire_format_inconsistency.sql | 5++---
Msrc/auditordb/0002-auditor_wire_out_inconsistency.sql | 1-
Msrc/auditordb/pg_helper.c | 1+
Msrc/auditordb/pg_helper.h | 28++++++++++++++--------------
Msrc/auditordb/pg_insert_amount_arithmetic_inconsistency.c | 20+++++++-------------
Msrc/auditordb/pg_insert_auditor_closure_lags.c | 13++++++-------
Msrc/auditordb/pg_insert_bad_sig_losses.c | 22++++++----------------
Msrc/auditordb/pg_insert_coin_inconsistency.c | 14++------------
Msrc/auditordb/pg_insert_denomination_key_validity_withdraw_inconsistency.c | 9++++-----
Msrc/auditordb/pg_insert_denominations_without_sigs.c | 7+------
Msrc/auditordb/pg_insert_emergency.c | 15+++++++--------
Msrc/auditordb/pg_insert_fee_time_inconsistency.c | 11++++-------
Msrc/auditordb/pg_insert_misattribution_in_inconsistency.c | 1+
Msrc/auditordb/pg_insert_purse_not_closed_inconsistencies.c | 13+++----------
Msrc/auditordb/pg_insert_refreshes_hanging.c | 16++++++----------
Msrc/auditordb/pg_insert_row_inconsistency.c | 1+
Msrc/auditordb/pg_insert_wire_format_inconsistency.c | 9++++-----
Msrc/auditordb/plugin_auditordb_postgres.c | 2+-
Msrc/include/taler_auditordb_plugin.h | 8++++++--
47 files changed, 137 insertions(+), 202 deletions(-)

diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c @@ -140,13 +140,14 @@ report_amount_arithmetic_inconsistency ( } { - enum GNUNET_DB_QueryStatus qs; struct TALER_AUDITORDB_AmountArithmeticInconsistency aai = { + .problem_row_id = rowid, .profitable = profitable, .operation = (char *) operation, .exchange_amount = *exchange, .auditor_amount = *auditor }; + enum GNUNET_DB_QueryStatus qs; qs = TALER_ARL_adb->insert_amount_arithmetic_inconsistency ( TALER_ARL_adb->cls, @@ -899,7 +900,7 @@ wire_transfer_information_cb ( denom_pub)) { struct TALER_AUDITORDB_BadSigLosses bsl = { - .row_id = rowid, + .problem_row_id = rowid, .operation = "wire", .loss = *coin_value, .operation_specific_pub = coin.coin_pub.eddsa_pub @@ -1128,6 +1129,7 @@ get_wire_fee (struct AggregationContext *ac, wfi->start_date)) { struct TALER_AUDITORDB_FeeTimeInconsistency ftib = { + .problem_row_id = 0, /* FIXME: fetch above! */ .diagnostic = "start date before previous end date", .time = wfi->start_date.abs_time, .type = (char *) method @@ -1136,7 +1138,6 @@ get_wire_fee (struct AggregationContext *ac, qs = TALER_ARL_adb->insert_fee_time_inconsistency ( TALER_ARL_adb->cls, &ftib); - if (qs < 0) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -1150,6 +1151,7 @@ get_wire_fee (struct AggregationContext *ac, wfi->end_date)) { struct TALER_AUDITORDB_FeeTimeInconsistency ftia = { + .problem_row_id = 0, /* FIXME: fetch above! */ .diagnostic = "end date date after next start date", .time = wfi->end_date.abs_time, .type = (char *) method diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c @@ -364,6 +364,7 @@ report_amount_arithmetic_inconsistency ( { struct TALER_AUDITORDB_AmountArithmeticInconsistency aai = { .profitable = profitable, + .problem_row_id = rowid, .operation = (char *) operation, .exchange_amount = *exchange, .auditor_amount = *auditor @@ -1207,6 +1208,7 @@ check_known_coin ( denom_pub)) { struct TALER_AUDITORDB_BadSigLosses bsl = { + .problem_row_id = rowid, .operation = (char *) operation, .loss = *loss_potential, .operation_specific_pub = coin_pub->eddsa_pub @@ -1386,6 +1388,7 @@ refresh_session_cb (void *cls, coin_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { + .problem_row_id = rowid, .operation = "melt", .loss = *amount_with_fee, .operation_specific_pub = coin_pub->eddsa_pub @@ -1442,7 +1445,7 @@ refresh_session_cb (void *cls, with invalid data, even if the exchange is correctly operating. We still report it. */ struct TALER_AUDITORDB_RefreshesHanging rh = { - .row_id = rowid, + .problem_row_id = rowid, .amount = *amount_with_fee, .coin_pub = coin_pub->eddsa_pub }; @@ -1731,6 +1734,7 @@ deposit_cb (void *cls, &deposit->csig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { + .problem_row_id = rowid, .operation = "deposit", .loss = deposit->amount_with_fee, .operation_specific_pub = deposit->coin.coin_pub.eddsa_pub @@ -1867,6 +1871,7 @@ refund_cb (void *cls, merchant_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { + .problem_row_id = rowid, .operation = "refund", .loss = *amount_with_fee, .operation_specific_pub = coin_pub->eddsa_pub @@ -2145,6 +2150,7 @@ check_recoup (struct CoinContext *cc, denom_pub)) { struct TALER_AUDITORDB_BadSigLosses bsl = { + .problem_row_id = rowid, .operation = (char *) operation, .loss = *amount, .operation_specific_pub = coin->coin_pub.eddsa_pub @@ -2217,6 +2223,7 @@ check_recoup (struct CoinContext *cc, if (! ds->was_revoked) { struct TALER_AUDITORDB_BadSigLosses bsldnr = { + .problem_row_id = rowid, .operation = (char *) operation, .loss = *amount, .operation_specific_pub = coin->coin_pub.eddsa_pub @@ -2286,6 +2293,7 @@ recoup_cb (void *cls, coin_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { + .problem_row_id = rowid, .operation = "recoup", .loss = *amount, .operation_specific_pub = coin->coin_pub.eddsa_pub @@ -2416,6 +2424,7 @@ recoup_refresh_cb (void *cls, coin_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { + .problem_row_id = rowid, .operation = "recoup-refresh", .loss = *amount, .operation_specific_pub = coin->coin_pub.eddsa_pub @@ -2607,6 +2616,7 @@ purse_deposit_cb ( &deposit->coin_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { + .problem_row_id = rowid, .operation = "purse-deposit", .loss = deposit->amount, .operation_specific_pub = deposit->coin_pub.eddsa_pub diff --git a/src/auditor/taler-helper-auditor-purses.c b/src/auditor/taler-helper-auditor-purses.c @@ -146,6 +146,7 @@ report_amount_arithmetic_inconsistency ( { struct TALER_AUDITORDB_AmountArithmeticInconsistency aai = { .profitable = profitable, + .problem_row_id = rowid, .operation = (char *) operation, .exchange_amount = *exchange, .auditor_amount = *auditor @@ -504,7 +505,7 @@ handle_purse_requested ( purse_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { - .row_id = rowid, + .problem_row_id = rowid, .operation = "purse-request", .loss = *target_amount, .operation_specific_pub = purse_pub->eddsa_pub @@ -629,7 +630,7 @@ handle_purse_deposits ( &deposit->coin_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { - .row_id = rowid, + .problem_row_id = rowid, .operation = "purse-deposit", .loss = deposit->amount, .operation_specific_pub = deposit->coin_pub.eddsa_pub @@ -736,7 +737,7 @@ handle_purse_merged ( merge_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { - .row_id = rowid, + .problem_row_id = rowid, .operation = "merge-purse", .loss = *amount, .operation_specific_pub = merge_pub->eddsa_pub @@ -845,7 +846,7 @@ handle_account_merged ( reserve_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { - .row_id = rowid, + .problem_row_id = rowid, .operation = "account-merge", .loss = *purse_fee, .operation_specific_pub = reserve_pub->eddsa_pub diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c @@ -170,7 +170,7 @@ report_amount_arithmetic_inconsistency ( { struct TALER_AUDITORDB_AmountArithmeticInconsistency aai = { - .row_id = rowid, + .problem_row_id = rowid, .profitable = profitable, .operation = (char *) operation, .exchange_amount = *exchange, @@ -581,7 +581,7 @@ handle_reserve_out ( execution_date)) { struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency dkvwi ={ - .row_id = rowid, + .problem_row_id = rowid, .execution_date = execution_date.abs_time, .denompub_h = *&h_denom_pub, .reserve_pub = *reserve_pub @@ -609,7 +609,7 @@ handle_reserve_out ( reserve_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { - .row_id = rowid, + .problem_row_id = rowid, .operation = "withdraw", .loss = *amount_with_fee, .operation_specific_pub = reserve_pub->eddsa_pub @@ -720,7 +720,7 @@ handle_recoup_by_reserve ( coin_sig)) { struct TALER_AUDITORDB_BadSigLosses bslr = { - .row_id = rowid, + .problem_row_id = rowid, .operation = "recoup", .loss = *amount, .operation_specific_pub = coin->coin_pub.eddsa_pub @@ -799,7 +799,7 @@ handle_recoup_by_reserve ( "master signature invalid"))) { struct TALER_AUDITORDB_BadSigLosses bslrm = { - .row_id = rev_rowid, + .problem_row_id = rev_rowid, .operation = "recoup-master", .loss = *amount, .operation_specific_pub = TALER_ARL_master_pub.eddsa_pub @@ -945,7 +945,7 @@ handle_reserve_open ( reserve_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { - .row_id = rowid, + .problem_row_id = rowid, .operation = "reserve-open", .loss = *reserve_payment, .operation_specific_pub = reserve_pub->eddsa_pub @@ -1100,7 +1100,7 @@ handle_reserve_closed ( &reserve_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { - .row_id = close_request_row, + .problem_row_id = close_request_row, .operation = "close-request", .loss = *amount_with_fee, .operation_specific_pub = reserve_pub->eddsa_pub @@ -1246,7 +1246,7 @@ handle_account_merged ( reserve_sig)) { struct TALER_AUDITORDB_BadSigLosses bsl = { - .row_id = rowid, + .problem_row_id = rowid, .operation = "account-merge", .loss = *purse_fee, .operation_specific_pub = reserve_pub->eddsa_pub diff --git a/src/auditor/taler-helper-auditor-wire-debit.c b/src/auditor/taler-helper-auditor-wire-debit.c @@ -455,6 +455,7 @@ check_pending_rc (void *cls, if (! TALER_amount_is_zero (&rc->amount)) { struct TALER_AUDITORDB_ClosureLags cl = { + .problem_row_id = rc->rowid, .account = rc->receiver_account, .amount = rc->amount, .deadline = rc->execution_date.abs_time, diff --git a/src/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql b/src/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql @@ -14,15 +14,11 @@ -- 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, + row_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, problem_row_id BIGINT NOT NULL, - -- TODO: correct constraintcheck, currently wrong - --operation BYTEA NOT NULL CHECK (LENGTH(operation)=16), - operation TEXT NOT NULL PRIMARY KEY, + operation TEXT NOT NULL, exchange_amount taler_amount NOT NULL, auditor_amount taler_amount NOT NULL, profitable BOOLEAN NOT NULL, diff --git a/src/auditordb/0002-auditor_bad_sig_losses.sql b/src/auditordb/0002-auditor_bad_sig_losses.sql @@ -14,16 +14,14 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_bad_sig_losses ( - row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, + row_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, problem_row_id BIGINT NOT NULL, operation TEXT NOT NULL, loss taler_amount NOT NULL, operation_specific_pub BYTEA NOT NULL CHECK (LENGTH(operation_specific_pub)=32), - suppressed BOOLEAN NOT NULL DEFAULT FALSE, - PRIMARY KEY (operation, operation_specific_pub) + suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_bad_sig_losses IS 'Report a (serious) inconsistency with losses due to bad signatures'; diff --git a/src/auditordb/0002-auditor_closure_lags.sql b/src/auditordb/0002-auditor_closure_lags.sql @@ -14,14 +14,13 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_closure_lags ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, problem_row_id BIGINT NOT NULL, amount taler_amount NOT NULL, deadline BIGINT NOT NULL, - wtid BYTEA NOT NULL, + wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32), account BYTEA NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); diff --git a/src/auditordb/0002-auditor_coin_inconsistency.sql b/src/auditordb/0002-auditor_coin_inconsistency.sql @@ -14,18 +14,16 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; + CREATE TABLE IF NOT EXISTS auditor_coin_inconsistency ( - row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, - problem_row_id BIGINT NOT NULL, + row_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, operation TEXT NOT NULL, exchange_amount taler_amount NOT NULL, auditor_amount taler_amount NOT NULL, coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32), profitable BOOLEAN NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE, - PRIMARY KEY (operation, coin_pub) + suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_coin_inconsistency IS 'Report a (serious) inconsistency in the exchange''s database with respect to calculations involving amounts'; diff --git a/src/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql b/src/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql @@ -14,14 +14,13 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_denomination_key_validity_withdraw_inconsistency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, problem_row_id BIGINT NOT NULL, - execution_date BIGINT, - reserve_pub BYTEA NOT NULL, - denompub_h BYTEA NOT NULL, + execution_date BIGINT NOT NULL, + reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), + denompub_h BYTEA NOT NULL CHECK (LENGTH(denompub_h)=64), suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_denomination_key_validity_withdraw_inconsistency diff --git a/src/auditordb/0002-auditor_denominations_without_sigs.sql b/src/auditordb/0002-auditor_denominations_without_sigs.sql @@ -14,11 +14,9 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_denominations_without_sigs ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, - problem_row_id BIGINT NOT NULL, denompub_h BYTEA PRIMARY KEY, value taler_amount NOT NULL, start_time BIGINT NOT NULL, diff --git a/src/auditordb/0002-auditor_deposit_confirmations.sql b/src/auditordb/0002-auditor_deposit_confirmations.sql @@ -16,7 +16,6 @@ CREATE TABLE auditor_deposit_confirmations (deposit_confirmation_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE - ,problem_row_id BIGINT NOT NULL ,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) diff --git a/src/auditordb/0002-auditor_emergency.sql b/src/auditordb/0002-auditor_emergency.sql @@ -1,5 +1,3 @@ - - -- -- This file is part of TALER -- Copyright (C) 2014--2024 Taler Systems SA @@ -16,17 +14,16 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_emergency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, - problem_row_id BIGINT NOT NULL, denompub_h BYTEA CHECK (LENGTH(denompub_h)=64), denom_risk taler_amount NOT NULL, denom_loss taler_amount NOT NULL, deposit_start BIGINT NOT NULL, - deposit_end BIGINT, - value taler_amount NOT NULL + deposit_end BIGINT NOT NULL, + value taler_amount NOT NULL, + suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_emergency IS 'Report an emergency denomination.'; diff --git a/src/auditordb/0002-auditor_emergency_by_count.sql b/src/auditordb/0002-auditor_emergency_by_count.sql @@ -14,17 +14,15 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_emergency_by_count ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, - problem_row_id BIGINT NOT NULL, - denompub_h BYTEA NOT NULL, + denompub_h BYTEA NOT NULL CHECK (LENGTH(denompub_h)=64), num_issued BIGINT NOT NULL, num_known BIGINT NOT NULL, risk taler_amount NOT NULL, start BIGINT NOT NULL, - deposit_end BIGINT, + deposit_end BIGINT NOT NULL, value taler_amount NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); diff --git a/src/auditordb/0002-auditor_fee_time_inconsistency.sql b/src/auditordb/0002-auditor_fee_time_inconsistency.sql @@ -14,7 +14,6 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_fee_time_inconsistency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, diff --git a/src/auditordb/0002-auditor_historic_denomination_revenue.sql b/src/auditordb/0002-auditor_historic_denomination_revenue.sql @@ -15,9 +15,8 @@ -- CREATE TABLE auditor_historic_denomination_revenue - (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, - problem_row_id BIGINT NOT NULL, - 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) ,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 @@ -14,16 +14,13 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, - problem_row_id BIGINT NOT NULL, start_date BIGINT NOT NULL, 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 @@ -14,14 +14,13 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; + CREATE TABLE IF NOT EXISTS auditor_misattribution_in_inconsistency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, - problem_row_id BIGINT NOT NULL, amount taler_amount NOT NULL, bank_row BIGINT NOT NULL, - reserve_pub BYTEA NOT NULL, + reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_misattribution_in_inconsistency diff --git a/src/auditordb/0002-auditor_pending_deposits.sql b/src/auditordb/0002-auditor_pending_deposits.sql @@ -17,7 +17,6 @@ CREATE TABLE IF NOT EXISTS auditor_pending_deposits ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, - problem_row_id BIGINT NOT NULL, total_amount taler_amount NOT NULL, wire_target_payto TEXT NOT NULL, batch_deposit_serial_id BIGINT NOT NULL, diff --git a/src/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql b/src/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql @@ -14,12 +14,11 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; + CREATE TABLE IF NOT EXISTS auditor_purse_not_closed_inconsistencies ( - row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, - problem_row_id BIGINT NOT NULL, - purse_pub BYTEA PRIMARY KEY NOT NULL, + row_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + purse_pub BYTEA NOT NULL CHECK (LENGTH(purse_pub)=32), amount taler_amount NOT NULL, expiration_date BIGINT NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE diff --git a/src/auditordb/0002-auditor_purses.sql b/src/auditordb/0002-auditor_purses.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2022 Taler Systems SA +-- Copyright (C) 2014--2024 Taler Systems SA -- -- TALER is free software; you can redistribute it and/or modify it under the -- terms of the GNU General Public License as published by the Free Software @@ -16,7 +16,6 @@ CREATE TABLE auditor_purses (auditor_purses_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE NOT NULL - ,problem_row_id BIGINT NOT NULL ,purse_pub BYTEA PRIMARY KEY CHECK(LENGTH(purse_pub)=32) NOT NULL ,balance taler_amount NOT NULL DEFAULT(0,0) ,target taler_amount NOT NULL diff --git a/src/auditordb/0002-auditor_refreshes_hanging.sql b/src/auditordb/0002-auditor_refreshes_hanging.sql @@ -14,13 +14,12 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; + CREATE TABLE IF NOT EXISTS auditor_refreshes_hanging ( - row_id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY UNIQUE, + row_id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, problem_row_id BIGINT NOT NULL, amount taler_amount NOT NULL, - coin_pub BYTEA PRIMARY KEY NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_refreshes_hanging diff --git a/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql b/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql @@ -14,11 +14,9 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -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, - problem_row_id BIGINT NOT NULL, reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), inconsistency_gain BOOLEAN NOT NULL, inconsistency_amount taler_amount NOT NULL, diff --git a/src/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql b/src/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql @@ -14,12 +14,11 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; + CREATE TABLE IF NOT EXISTS auditor_reserve_balance_summary_wrong_inconsistency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, - problem_row_id BIGINT NOT NULL, - reserve_pub BYTEA NOT NULL, + reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), exchange_amount taler_amount NOT NULL, auditor_amount taler_amount NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE diff --git a/src/auditordb/0002-auditor_reserve_in_inconsistency.sql b/src/auditordb/0002-auditor_reserve_in_inconsistency.sql @@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS auditor_reserve_in_inconsistency bank_row_id INT8 NOT NULL, amount_exchange_expected taler_amount NOT NULL, amount_wired taler_amount NOT NULL, - reserve_pub BYTEA NOT NULL, + reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), timestamp BIGINT NOT NULL, account BYTEA NOT NULL, diagnostic BYTEA NOT NULL, diff --git a/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql b/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql @@ -14,12 +14,10 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_reserve_not_closed_inconsistency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE , - problem_row_id BIGINT NOT NULL, - reserve_pub BYTEA PRIMARY KEY NOT NULL, + reserve_pub BYTEA PRIMARY KEY NOT NULL CHECK (LENGTH(reserve_pub)=32), balance taler_amount NOT NULL, expiration_time BIGINT, diagnostic BYTEA, diff --git a/src/auditordb/0002-auditor_reserves.sql b/src/auditordb/0002-auditor_reserves.sql @@ -16,7 +16,6 @@ CREATE TABLE auditor_reserves (auditor_reserves_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE - ,problem_row_id BIGINT NOT NULL ,reserve_pub BYTEA PRIMARY KEY CHECK(LENGTH(reserve_pub)=32) ,reserve_balance taler_amount NOT NULL ,reserve_loss taler_amount NOT NULL diff --git a/src/auditordb/0002-auditor_row_inconsistency.sql b/src/auditordb/0002-auditor_row_inconsistency.sql @@ -14,11 +14,10 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; + CREATE TABLE IF NOT EXISTS auditor_row_inconsistency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, - problem_row_id BIGINT NOT NULL, row_table TEXT NOT NULL, diagnostic TEXT NOT NULL, problem_row_id INT8 NOT NULL, diff --git a/src/auditordb/0002-auditor_wire_format_inconsistency.sql b/src/auditordb/0002-auditor_wire_format_inconsistency.sql @@ -14,14 +14,13 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; + CREATE TABLE IF NOT EXISTS auditor_wire_format_inconsistency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, - problem_row_id BIGINT NOT NULL, amount taler_amount NOT NULL, wire_offset BIGINT NOT NULL, - diagnostic BYTEA, + diagnostic BYTEA NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_wire_format_inconsistency diff --git a/src/auditordb/0002-auditor_wire_out_inconsistency.sql b/src/auditordb/0002-auditor_wire_out_inconsistency.sql @@ -17,7 +17,6 @@ CREATE TABLE IF NOT EXISTS auditor_wire_out_inconsistency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, - problem_row_id BIGINT NOT NULL, destination_account TEXT NOT NULL, diagnostic TEXT NOT NULL, wire_out_serial_id INT8 NOT NULL, diff --git a/src/auditordb/pg_helper.c b/src/auditordb/pg_helper.c @@ -22,6 +22,7 @@ #include "platform.h" #include "taler_auditordb_plugin.h" #include <ltdl.h> +#include "pg_helper.h" const char * diff --git a/src/auditordb/pg_helper.h b/src/auditordb/pg_helper.h @@ -75,27 +75,27 @@ struct PostgresClosure * @param name name to prepare the statement under * @param sql actual SQL text */ -#define PREPARE(pg,name,sql) \ +#define PREPARE(pg,name,sql) \ do { \ static struct { \ unsigned long long cnt; \ struct PostgresClosure *pg; \ - } preps[2]; /* 2 ctrs for taler-auditor-sync*/ \ - unsigned int off = 0; \ - \ - while ( (NULL != preps[off].pg) && \ - (pg != preps[off].pg) && \ - (off < sizeof(preps) / sizeof(*preps)) ) \ - off++; \ - GNUNET_assert (off < \ - sizeof(preps) / sizeof(*preps)); \ - if (preps[off].cnt < pg->prep_gen) \ + } preps_[2]; /* 2 ctrs for taler-auditor-sync*/ \ + unsigned int off_ = 0; \ + \ + while ( (NULL != preps_[off_].pg) && \ + (pg != preps_[off_].pg) && \ + (off_ < sizeof(preps_) / sizeof(*preps_)) ) \ + off_++; \ + GNUNET_assert (off_ < \ + sizeof(preps_) / sizeof(*preps_)); \ + if (preps_[off_].cnt < pg->prep_gen) \ { \ struct GNUNET_PQ_PreparedStatement ps[] = { \ GNUNET_PQ_make_prepare (name, sql), \ GNUNET_PQ_PREPARED_STATEMENT_END \ }; \ - \ + \ if (GNUNET_OK != \ GNUNET_PQ_prepare_statements (pg->conn, \ ps)) \ @@ -103,8 +103,8 @@ struct PostgresClosure GNUNET_break (0); \ return GNUNET_DB_STATUS_HARD_ERROR; \ } \ - preps[off].pg = pg; \ - preps[off].cnt = pg->prep_gen; \ + preps_[off_].pg = pg; \ + preps_[off_].cnt = pg->prep_gen; \ } \ } while (0) diff --git a/src/auditordb/pg_insert_amount_arithmetic_inconsistency.c b/src/auditordb/pg_insert_amount_arithmetic_inconsistency.c @@ -13,12 +13,9 @@ You should have 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 @@ -28,12 +25,13 @@ TAH_PG_insert_amount_arithmetic_inconsistency ( { 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_uint64 (&dc->problem_row_id), + 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 }; @@ -41,15 +39,11 @@ TAH_PG_insert_amount_arithmetic_inconsistency ( "auditor_amount_arithmetic_inconsistency_insert", "INSERT INTO auditor_amount_arithmetic_inconsistency " "(operation" + ",problem_row_id" ",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;" + ") VALUES ($1,$2,$3,$4,$5);" ); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_amount_arithmetic_inconsistency_insert", diff --git a/src/auditordb/pg_insert_auditor_closure_lags.c b/src/auditordb/pg_insert_auditor_closure_lags.c @@ -13,14 +13,12 @@ You should have 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, @@ -28,12 +26,12 @@ TAH_PG_insert_auditor_closure_lags ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - - TALER_PQ_query_param_amount (pg->conn, &dc->amount), + TALER_PQ_query_param_amount (pg->conn, + &dc->amount), + GNUNET_PQ_query_param_uint64 (&dc->problem_row_id), 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 }; @@ -41,10 +39,11 @@ TAH_PG_insert_auditor_closure_lags ( "auditor_closure_lags_insert", "INSERT INTO auditor_closure_lags " "(amount" + ",problem_row_id" ",deadline" ",wtid" ",account" - ") VALUES ($1,$2,$3,$4);"); + ") VALUES ($1,$2,$3,$4,$5);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_closure_lags_insert", params); diff --git a/src/auditordb/pg_insert_bad_sig_losses.c b/src/auditordb/pg_insert_bad_sig_losses.c @@ -13,14 +13,12 @@ You should have 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, @@ -28,30 +26,22 @@ TAH_PG_insert_bad_sig_losses ( { 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_uint64 (&dc->problem_row_id), + 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" + ",problem_row_id" ",loss" ",operation_specific_pub" - ") VALUES ($1,$2,$3)" - " ON CONFLICT (operation, operation_specific_pub) DO UPDATE" - " SET loss = excluded.loss," - " suppressed = false;" + ") VALUES ($1,$2,$3,$4);" ); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_bad_sig_losses_insert", diff --git a/src/auditordb/pg_insert_coin_inconsistency.c b/src/auditordb/pg_insert_coin_inconsistency.c @@ -13,13 +13,9 @@ You should have 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" @@ -30,7 +26,6 @@ TAH_PG_insert_coin_inconsistency ( { 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), @@ -38,7 +33,6 @@ TAH_PG_insert_coin_inconsistency ( &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 }; @@ -46,16 +40,12 @@ TAH_PG_insert_coin_inconsistency ( "auditor_coin_inconsistency_insert", "INSERT INTO auditor_coin_inconsistency " "(operation" + ",problem_row_id" ",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;" + ") VALUES ($1,$2,$3,$4,$5,$6)" ); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_coin_inconsistency_insert", diff --git a/src/auditordb/pg_insert_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_insert_denomination_key_validity_withdraw_inconsistency.c @@ -13,14 +13,12 @@ You should have 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, @@ -28,8 +26,8 @@ TAH_PG_insert_denomination_key_validity_withdraw_inconsistency ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_absolute_time (&dc->execution_date), + GNUNET_PQ_query_param_uint64 (&dc->problem_row_id), GNUNET_PQ_query_param_auto_from_type (&dc->reserve_pub), GNUNET_PQ_query_param_auto_from_type (&dc->denompub_h), @@ -40,9 +38,10 @@ TAH_PG_insert_denomination_key_validity_withdraw_inconsistency ( "auditor_denomination_key_validity_withdraw_inconsistency_insert", "INSERT INTO auditor_denomination_key_validity_withdraw_inconsistency " "(execution_date" + ",problem_row_id" ",reserve_pub" ",denompub_h" - ") VALUES ($1,$2,$3);"); + ") VALUES ($1,$2,$3,$4);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_denomination_key_validity_withdraw_inconsistency_insert", params); diff --git a/src/auditordb/pg_insert_denominations_without_sigs.c b/src/auditordb/pg_insert_denominations_without_sigs.c @@ -13,14 +13,12 @@ You should have 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, @@ -28,13 +26,10 @@ TAH_PG_insert_denominations_without_sigs ( { 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 }; diff --git a/src/auditordb/pg_insert_emergency.c b/src/auditordb/pg_insert_emergency.c @@ -13,14 +13,12 @@ You should have 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, @@ -28,14 +26,15 @@ TAH_PG_insert_emergency ( { 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), + 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), - + TALER_PQ_query_param_amount (pg->conn, + &dc->value), GNUNET_PQ_query_param_end }; diff --git a/src/auditordb/pg_insert_fee_time_inconsistency.c b/src/auditordb/pg_insert_fee_time_inconsistency.c @@ -13,14 +13,12 @@ You should have 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, @@ -28,12 +26,10 @@ TAH_PG_insert_fee_time_inconsistency ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - - GNUNET_PQ_query_param_string (dc->type), + GNUNET_PQ_query_param_uint64 (&dc->problem_row_id), GNUNET_PQ_query_param_absolute_time (&dc->time), GNUNET_PQ_query_param_string (dc->diagnostic), - GNUNET_PQ_query_param_end }; @@ -41,9 +37,10 @@ TAH_PG_insert_fee_time_inconsistency ( "auditor_fee_time_inconsistency_insert", "INSERT INTO auditor_fee_time_inconsistency " "(type" + ",problem_row_id" ",time" ",diagnostic" - ") VALUES ($1,$2,$3);"); + ") VALUES ($1,$2,$3,$4);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_fee_time_inconsistency_insert", params); diff --git a/src/auditordb/pg_insert_misattribution_in_inconsistency.c b/src/auditordb/pg_insert_misattribution_in_inconsistency.c @@ -18,6 +18,7 @@ #include "pg_helper.h" #include "pg_insert_misattribution_in_inconsistency.h" + enum GNUNET_DB_QueryStatus TAH_PG_insert_misattribution_in_inconsistency ( void *cls, diff --git a/src/auditordb/pg_insert_purse_not_closed_inconsistencies.c b/src/auditordb/pg_insert_purse_not_closed_inconsistencies.c @@ -13,14 +13,12 @@ You should have 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, @@ -28,11 +26,10 @@ TAH_PG_insert_purse_not_closed_inconsistencies ( { 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), + TALER_PQ_query_param_amount (pg->conn, + &dc->amount), GNUNET_PQ_query_param_absolute_time (&dc->expiration_date), - GNUNET_PQ_query_param_end }; @@ -43,10 +40,6 @@ TAH_PG_insert_purse_not_closed_inconsistencies ( ",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", diff --git a/src/auditordb/pg_insert_refreshes_hanging.c b/src/auditordb/pg_insert_refreshes_hanging.c @@ -13,14 +13,12 @@ You should have 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, @@ -28,10 +26,10 @@ TAH_PG_insert_refreshes_hanging ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - - TALER_PQ_query_param_amount (pg->conn, &dc->amount), + TALER_PQ_query_param_amount (pg->conn, + &dc->amount), + GNUNET_PQ_query_param_uint64 (&dc->problem_row_id), GNUNET_PQ_query_param_auto_from_type (&dc->coin_pub), - GNUNET_PQ_query_param_end }; @@ -39,11 +37,9 @@ TAH_PG_insert_refreshes_hanging ( "auditor_refreshes_hanging_insert", "INSERT INTO auditor_refreshes_hanging " "(amount" + ",problem_row_id" ",coin_pub" - ") VALUES ($1,$2)" - " ON CONFLICT (coin_pub) DO UPDATE" - " SET amount = excluded.amount," - " suppressed = false;" + ") VALUES ($1,$2);" ); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_refreshes_hanging_insert", diff --git a/src/auditordb/pg_insert_row_inconsistency.c b/src/auditordb/pg_insert_row_inconsistency.c @@ -19,6 +19,7 @@ #include "pg_helper.h" #include "pg_insert_row_inconsistency.h" + enum GNUNET_DB_QueryStatus TAH_PG_insert_row_inconsistency ( void *cls, diff --git a/src/auditordb/pg_insert_wire_format_inconsistency.c b/src/auditordb/pg_insert_wire_format_inconsistency.c @@ -26,8 +26,8 @@ TAH_PG_insert_wire_format_inconsistency ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - - TALER_PQ_query_param_amount (pg->conn, &dc->amount), + TALER_PQ_query_param_amount (pg->conn, + &dc->amount), GNUNET_PQ_query_param_uint64 (&dc->wire_offset), GNUNET_PQ_query_param_auto_from_type (&dc->diagnostic), GNUNET_PQ_query_param_end @@ -36,11 +36,10 @@ TAH_PG_insert_wire_format_inconsistency ( PREPARE (pg, "auditor_wire_format_inconsistency_insert", "INSERT INTO auditor_wire_format_inconsistency " - "(row_id," - " amount," + "(amount," " wire_offset," " diagnostic" - ") VALUES ($1,$2,$3,$4);" + ") VALUES ($1,$2,$3);" ); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_wire_format_inconsistency_insert", diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c @@ -477,7 +477,7 @@ postgres_rollback (void *cls) * @param cls the `struct PostgresClosure` with the plugin-specific state * @return transaction status code */ -enum GNUNET_DB_QueryStatus +static enum GNUNET_DB_QueryStatus postgres_commit (void *cls) { struct PostgresClosure *pg = cls; diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h @@ -215,8 +215,8 @@ struct TALER_AUDITORDB_Generic_Update */ struct TALER_AUDITORDB_AmountArithmeticInconsistency { - // FIXME: which row? uint64_t row_id; + uint64_t problem_row_id; char *operation; struct TALER_Amount exchange_amount; struct TALER_Amount auditor_amount; @@ -253,6 +253,7 @@ struct TALER_AUDITORDB_RowInconsistency struct TALER_AUDITORDB_BadSigLosses { uint64_t row_id; + uint64_t problem_row_id; char *operation; struct TALER_Amount loss; struct GNUNET_CRYPTO_EddsaPublicKey operation_specific_pub; @@ -264,6 +265,7 @@ struct TALER_AUDITORDB_BadSigLosses struct TALER_AUDITORDB_ClosureLags { uint64_t row_id; + uint64_t problem_row_id; struct TALER_Amount amount; struct GNUNET_TIME_Absolute deadline; struct TALER_WireTransferIdentifierRawP wtid; @@ -316,6 +318,7 @@ struct TALER_AUDITORDB_Progress struct TALER_AUDITORDB_RefreshesHanging { uint64_t row_id; + uint64_t problem_row_id; struct TALER_Amount amount; struct GNUNET_CRYPTO_EddsaPublicKey coin_pub; }; @@ -326,6 +329,7 @@ struct TALER_AUDITORDB_RefreshesHanging struct TALER_AUDITORDB_FeeTimeInconsistency { uint64_t row_id; + uint64_t problem_row_id; char *type; struct GNUNET_TIME_Absolute time; char *diagnostic; @@ -337,6 +341,7 @@ struct TALER_AUDITORDB_FeeTimeInconsistency struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency { uint64_t row_id; + uint64_t problem_row_id; struct GNUNET_TIME_Absolute execution_date; struct TALER_ReservePublicKeyP reserve_pub; struct TALER_DenominationHashP denompub_h; @@ -688,7 +693,6 @@ struct TALER_AUDITORDB_DenominationsWithoutSigs struct GNUNET_TIME_Absolute start_time; struct GNUNET_TIME_Absolute end_time; bool suppressed; - }; struct TALER_AUDITORDB_MisattributionInInconsistency