aboutsummaryrefslogtreecommitdiff
path: root/src/auditordb
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditordb')
-rw-r--r--src/auditordb/9999.sql53
-rw-r--r--src/auditordb/auditor-0001.sql78
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c760
-rw-r--r--src/auditordb/test_auditordb.c823
4 files changed, 933 insertions, 781 deletions
diff --git a/src/auditordb/9999.sql b/src/auditordb/9999.sql
deleted file mode 100644
index d6add4b20..000000000
--- a/src/auditordb/9999.sql
+++ /dev/null
@@ -1,53 +0,0 @@
---
--- This file is part of TALER
--- Copyright (C) 2014--2020 Taler Systems SA
---
--- TALER is free software; you can redistribute it and/or modify it under the
--- terms of the GNU General Public License as published by the Free Software
--- Foundation; either version 3, or (at your option) any later version.
---
--- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
--- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
--- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License along with
--- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
---
-
--- Everything in one big transaction
-BEGIN;
-
-NOTE: This code is not yet ready / in use. It was archived here
-as we might want this kind of table in the future. It is NOT
-to be installed in a production system (hence in EXTRA_DIST and
-not in the SQL target!)
-
--- Check patch versioning is in place.
-SELECT _v.register_patch('auditor-9999', NULL, NULL);
-
-
--- Table with historic business ledger; basically, when the exchange
--- operator decides to use operating costs for anything but wire
--- transfers to merchants, it goes in here. This happens when the
--- operator users transaction fees for business expenses. purpose
--- is free-form but should be a human-readable wire transfer
--- identifier. This is NOT yet used and outside of the scope of
--- the core auditing logic. However, once we do take fees to use
--- operating costs, and if we still want auditor_predicted_result to match
--- the tables overall, we'll need a command-line tool to insert rows
--- into this table and update auditor_predicted_result accordingly.
--- (So this table for now just exists as a reminder of what we'll
--- need in the long term.)
-CREATE TABLE IF NOT EXISTS auditor_historic_ledger
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,purpose VARCHAR NOT NULL
- ,timestamp INT8 NOT NULL
- ,balance_val INT8 NOT NULL
- ,balance_frac INT4 NOT NULL
- );
-CREATE INDEX history_ledger_by_master_pub_and_time
- ON auditor_historic_ledger
- (master_pub
- ,timestamp);
-
-COMMIT;
diff --git a/src/auditordb/auditor-0001.sql b/src/auditordb/auditor-0001.sql
index 483f4f1e3..7bd5531e8 100644
--- a/src/auditordb/auditor-0001.sql
+++ b/src/auditordb/auditor-0001.sql
@@ -1,6 +1,6 @@
--
-- This file is part of TALER
--- Copyright (C) 2014--2020 Taler Systems SA
+-- 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
@@ -52,16 +52,29 @@ CREATE TABLE IF NOT EXISTS auditor_progress_reserve
,last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0
,last_reserve_out_serial_id INT8 NOT NULL DEFAULT 0
,last_reserve_recoup_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_reserve_open_serial_id INT8 NOT NULL DEFAULT 0
,last_reserve_close_serial_id INT8 NOT NULL DEFAULT 0
- ,last_purse_merges_serial_id INT8 NOT NULL DEFAULT 0
- ,last_purse_deposits_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_decision_serial_id INT8 NOT NULL DEFAULT 0
,last_account_merges_serial_id INT8 NOT NULL DEFAULT 0
,last_history_requests_serial_id INT8 NOT NULL DEFAULT 0
- ,last_close_requests_serial_id INT8 NOT NULL DEFAULT 0
,PRIMARY KEY (master_pub)
);
COMMENT ON TABLE auditor_progress_reserve
- IS 'information as to which transactions the auditor has processed in the exchange database. Used for SELECTing the
+ IS 'information as to which transactions the reserve auditor has processed in the exchange database. Used for SELECTing the
+ statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
+
+
+CREATE TABLE IF NOT EXISTS auditor_progress_purse
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ ,last_purse_request_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_decision_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_merges_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_account_merges_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_deposits_serial_id INT8 NOT NULL DEFAULT 0
+ ,PRIMARY KEY (master_pub)
+ );
+COMMENT ON TABLE auditor_progress_purse
+ IS 'information as to which purses the purse auditor has processed in the exchange database. Used for SELECTing the
statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
@@ -93,8 +106,9 @@ CREATE TABLE IF NOT EXISTS auditor_progress_coin
,last_refund_serial_id INT8 NOT NULL DEFAULT 0
,last_recoup_serial_id INT8 NOT NULL DEFAULT 0
,last_recoup_refresh_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_open_deposits_serial_id INT8 NOT NULL DEFAULT 0
,last_purse_deposits_serial_id INT8 NOT NULL DEFAULT 0
- ,last_purse_refunds_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_decision_serial_id INT8 NOT NULL DEFAULT 0
,PRIMARY KEY (master_pub)
);
COMMENT ON TABLE auditor_progress_coin
@@ -129,10 +143,20 @@ CREATE TABLE IF NOT EXISTS auditor_reserves
,master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,reserve_balance_val INT8 NOT NULL
,reserve_balance_frac INT4 NOT NULL
+ ,reserve_loss_val INT8 NOT NULL
+ ,reserve_loss_frac INT4 NOT NULL
,withdraw_fee_balance_val INT8 NOT NULL
,withdraw_fee_balance_frac INT4 NOT NULL
+ ,close_fee_balance_val INT8 NOT NULL
+ ,close_fee_balance_frac INT4 NOT NULL
+ ,purse_fee_balance_val INT8 NOT NULL
+ ,purse_fee_balance_frac INT4 NOT NULL
+ ,open_fee_balance_val INT8 NOT NULL
+ ,open_fee_balance_frac INT4 NOT NULL
+ ,history_fee_balance_val INT8 NOT NULL
+ ,history_fee_balance_frac INT4 NOT NULL
,expiration_date INT8 NOT NULL
- ,auditor_reserves_rowid BIGSERIAL UNIQUE
+ ,auditor_reserves_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
,origin_account TEXT
);
COMMENT ON TABLE auditor_reserves
@@ -143,14 +167,38 @@ CREATE INDEX IF NOT EXISTS auditor_reserves_by_reserve_pub
(reserve_pub);
+CREATE TABLE IF NOT EXISTS auditor_purses
+ (purse_pub BYTEA NOT NULL CHECK(LENGTH(purse_pub)=32)
+ ,master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ ,balance_val INT8 NOT NULL
+ ,balance_frac INT4 NOT NULL
+ ,target_val INT8 NOT NULL
+ ,target_frac INT4 NOT NULL
+ ,expiration_date INT8 NOT NULL
+ ,auditor_purses_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
+ );
+COMMENT ON TABLE auditor_purses
+ IS 'all of the purses and their respective balances that the auditor is aware of';
+
+CREATE INDEX IF NOT EXISTS auditor_purses_by_purse_pub
+ ON auditor_purses
+ (purse_pub);
+
+
CREATE TABLE IF NOT EXISTS auditor_reserve_balance
(master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,reserve_balance_val INT8 NOT NULL
,reserve_balance_frac INT4 NOT NULL
+ ,reserve_loss_val INT8 NOT NULL
+ ,reserve_loss_frac INT4 NOT NULL
,withdraw_fee_balance_val INT8 NOT NULL
,withdraw_fee_balance_frac INT4 NOT NULL
+ ,close_fee_balance_val INT8 NOT NULL
+ ,close_fee_balance_frac INT4 NOT NULL
,purse_fee_balance_val INT8 NOT NULL
,purse_fee_balance_frac INT4 NOT NULL
+ ,open_fee_balance_val INT8 NOT NULL
+ ,open_fee_balance_frac INT4 NOT NULL
,history_fee_balance_val INT8 NOT NULL
,history_fee_balance_frac INT4 NOT NULL
);
@@ -185,8 +233,10 @@ COMMENT ON COLUMN auditor_denomination_pending.num_issued
IS 'counts the number of coins issued (withdraw, refresh) of this denomination';
COMMENT ON COLUMN auditor_denomination_pending.denom_risk_val
IS 'amount that could theoretically be lost in the future due to recoup operations';
+COMMENT ON COLUMN auditor_denomination_pending.denom_loss_val
+ IS 'amount that was lost due to failures by the exchange';
COMMENT ON COLUMN auditor_denomination_pending.recoup_loss_val
- IS 'amount actually lost due to recoup operations past revocation';
+ IS 'amount actually lost due to recoup operations after a revocation';
CREATE TABLE IF NOT EXISTS auditor_balance_summary
@@ -199,15 +249,21 @@ CREATE TABLE IF NOT EXISTS auditor_balance_summary
,melt_fee_balance_frac INT4 NOT NULL
,refund_fee_balance_val INT8 NOT NULL
,refund_fee_balance_frac INT4 NOT NULL
+ ,purse_fee_balance_val INT8 NOT NULL
+ ,purse_fee_balance_frac INT4 NOT NULL
+ ,open_deposit_fee_balance_val INT8 NOT NULL
+ ,open_deposit_fee_balance_frac INT4 NOT NULL
,risk_val INT8 NOT NULL
,risk_frac INT4 NOT NULL
,loss_val INT8 NOT NULL
,loss_frac INT4 NOT NULL
- ,irregular_recoup_val INT8 NOT NULL
- ,irregular_recoup_frac INT4 NOT NULL
+ ,irregular_loss_val INT8 NOT NULL
+ ,irregular_loss_frac INT4 NOT NULL
);
COMMENT ON TABLE auditor_balance_summary
IS 'the sum of the outstanding coins from auditor_denomination_pending (denom_pubs must belong to the respectives exchange master public key); it represents the auditor_balance_summary of the exchange at this point (modulo unexpected historic_loss-style events where denomination keys are compromised)';
+COMMENT ON COLUMN auditor_balance_summary.denom_balance_frac
+ IS 'total amount we should have in escrow for all denominations';
CREATE TABLE IF NOT EXISTS auditor_historic_denomination_revenue
@@ -243,7 +299,7 @@ CREATE INDEX IF NOT EXISTS auditor_historic_reserve_summary_by_master_pub_start_
CREATE TABLE IF NOT EXISTS deposit_confirmations
(master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,serial_id BIGSERIAL NOT NULL UNIQUE
+ ,serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)
,h_extensions BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)
,h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index cf8d0b5d0..9a4f95f35 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -229,13 +229,12 @@ setup_connection (struct PostgresClosure *pg)
" last_reserve_in_serial_id=$1"
",last_reserve_out_serial_id=$2"
",last_reserve_recoup_serial_id=$3"
- ",last_reserve_close_serial_id=$4"
- ",last_purse_merges_serial_id=$5"
- ",last_purse_deposits_serial_id=$6"
+ ",last_reserve_open_serial_id=$4"
+ ",last_reserve_close_serial_id=$5"
+ ",last_purse_decision_serial_id=$6"
",last_account_merges_serial_id=$7"
",last_history_requests_serial_id=$8"
- ",last_close_requests_serial_id=$9"
- " WHERE master_pub=$10"),
+ " WHERE master_pub=$9"),
/* Used in #postgres_get_auditor_progress_reserve() */
GNUNET_PQ_make_prepare ("auditor_progress_select_reserve",
"SELECT"
@@ -243,11 +242,10 @@ setup_connection (struct PostgresClosure *pg)
",last_reserve_out_serial_id"
",last_reserve_recoup_serial_id"
",last_reserve_close_serial_id"
- ",last_purse_merges_serial_id"
- ",last_purse_deposits_serial_id"
+ ",last_purse_decision_serial_id"
",last_account_merges_serial_id"
",last_history_requests_serial_id"
- ",last_close_requests_serial_id"
+ ",last_reserve_open_serial_id"
" FROM auditor_progress_reserve"
" WHERE master_pub=$1;"),
/* Used in #postgres_insert_auditor_progress_reserve() */
@@ -257,13 +255,41 @@ setup_connection (struct PostgresClosure *pg)
",last_reserve_in_serial_id"
",last_reserve_out_serial_id"
",last_reserve_recoup_serial_id"
+ ",last_reserve_open_serial_id"
",last_reserve_close_serial_id"
+ ",last_purse_decision_serial_id"
+ ",last_account_merges_serial_id"
+ ",last_history_requests_serial_id"
+ ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);"),
+ /* Used in #postgres_update_auditor_progress_purse() */
+ GNUNET_PQ_make_prepare ("auditor_progress_update_purse",
+ "UPDATE auditor_progress_purse SET "
+ " last_purse_request_serial_id=$1"
+ ",last_purse_decision_serial_id=$2"
+ ",last_purse_merges_serial_id=$3"
+ ",last_account_merges_serial_id=$4"
+ ",last_purse_deposits_serial_id=$5"
+ " WHERE master_pub=$6"),
+ /* Used in #postgres_get_auditor_progress_purse() */
+ GNUNET_PQ_make_prepare ("auditor_progress_select_purse",
+ "SELECT"
+ " last_purse_request_serial_id"
+ ",last_purse_decision_serial_id"
",last_purse_merges_serial_id"
+ ",last_account_merges_serial_id"
",last_purse_deposits_serial_id"
+ " FROM auditor_progress_purse"
+ " WHERE master_pub=$1;"),
+ /* Used in #postgres_insert_auditor_progress_purse() */
+ GNUNET_PQ_make_prepare ("auditor_progress_insert_purse",
+ "INSERT INTO auditor_progress_purse "
+ "(master_pub"
+ ",last_purse_request_serial_id"
+ ",last_purse_decision_serial_id"
+ ",last_purse_merges_serial_id"
",last_account_merges_serial_id"
- ",last_history_requests_serial_id"
- ",last_close_requests_serial_id"
- ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);"),
+ ",last_purse_deposits_serial_id"
+ ") VALUES ($1,$2,$3,$4,$5,$6);"),
/* Used in #postgres_update_auditor_progress_aggregation() */
GNUNET_PQ_make_prepare ("auditor_progress_update_aggregation",
"UPDATE auditor_progress_aggregation SET "
@@ -308,7 +334,7 @@ setup_connection (struct PostgresClosure *pg)
",last_recoup_serial_id=$5"
",last_recoup_refresh_serial_id=$6"
",last_purse_deposits_serial_id=$7"
- ",last_purse_refunds_serial_id=$8"
+ ",last_purse_decision_serial_id=$8"
" WHERE master_pub=$9"),
/* Used in #postgres_get_auditor_progress_coin() */
GNUNET_PQ_make_prepare ("auditor_progress_select_coin",
@@ -320,7 +346,7 @@ setup_connection (struct PostgresClosure *pg)
",last_recoup_serial_id"
",last_recoup_refresh_serial_id"
",last_purse_deposits_serial_id"
- ",last_purse_refunds_serial_id"
+ ",last_purse_decision_serial_id"
" FROM auditor_progress_coin"
" WHERE master_pub=$1;"),
/* Used in #postgres_insert_auditor_progress() */
@@ -334,7 +360,7 @@ setup_connection (struct PostgresClosure *pg)
",last_recoup_serial_id"
",last_recoup_refresh_serial_id"
",last_purse_deposits_serial_id"
- ",last_purse_refunds_serial_id"
+ ",last_purse_decision_serial_id"
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);"),
/* Used in #postgres_insert_wire_auditor_account_progress() */
GNUNET_PQ_make_prepare ("wire_auditor_account_progress_insert",
@@ -390,27 +416,57 @@ setup_connection (struct PostgresClosure *pg)
",master_pub"
",reserve_balance_val"
",reserve_balance_frac"
+ ",reserve_loss_val"
+ ",reserve_loss_frac"
",withdraw_fee_balance_val"
",withdraw_fee_balance_frac"
+ ",close_fee_balance_val"
+ ",close_fee_balance_frac"
+ ",purse_fee_balance_val"
+ ",purse_fee_balance_frac"
+ ",open_fee_balance_val"
+ ",open_fee_balance_frac"
+ ",history_fee_balance_val"
+ ",history_fee_balance_frac"
",expiration_date"
",origin_account"
- ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);"),
+ ") VALUES "
+ "($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18);"),
/* Used in #postgres_update_reserve_info() */
GNUNET_PQ_make_prepare ("auditor_reserves_update",
"UPDATE auditor_reserves SET"
" reserve_balance_val=$1"
",reserve_balance_frac=$2"
- ",withdraw_fee_balance_val=$3"
- ",withdraw_fee_balance_frac=$4"
- ",expiration_date=$5"
- " WHERE reserve_pub=$6 AND master_pub=$7;"),
+ ",reserve_loss_val=$3"
+ ",reserve_loss_frac=$4"
+ ",withdraw_fee_balance_val=$5"
+ ",withdraw_fee_balance_frac=$6"
+ ",purse_fee_balance_val=$7"
+ ",purse_fee_balance_frac=$8"
+ ",open_fee_balance_val=$9"
+ ",open_fee_balance_frac=$10"
+ ",history_fee_balance_val=$11"
+ ",history_fee_balance_frac=$12"
+ ",expiration_date=$13"
+ " WHERE reserve_pub=$14"
+ " AND master_pub=$15;"),
/* Used in #postgres_get_reserve_info() */
GNUNET_PQ_make_prepare ("auditor_reserves_select",
"SELECT"
" reserve_balance_val"
",reserve_balance_frac"
+ ",reserve_loss_val"
+ ",reserve_loss_frac"
",withdraw_fee_balance_val"
",withdraw_fee_balance_frac"
+ ",close_fee_balance_val"
+ ",close_fee_balance_frac"
+ ",purse_fee_balance_val"
+ ",purse_fee_balance_frac"
+ ",open_fee_balance_val"
+ ",open_fee_balance_frac"
+ ",history_fee_balance_val"
+ ",history_fee_balance_frac"
",expiration_date"
",auditor_reserves_rowid"
",origin_account"
@@ -427,34 +483,53 @@ setup_connection (struct PostgresClosure *pg)
"(master_pub"
",reserve_balance_val"
",reserve_balance_frac"
+ ",reserve_loss_val"
+ ",reserve_loss_frac"
",withdraw_fee_balance_val"
",withdraw_fee_balance_frac"
+ ",close_fee_balance_val"
+ ",close_fee_balance_frac"
",purse_fee_balance_val"
",purse_fee_balance_frac"
+ ",open_fee_balance_val"
+ ",open_fee_balance_frac"
",history_fee_balance_val"
",history_fee_balance_frac"
- ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)"),
+ ") VALUES "
+ "($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)"),
/* Used in #postgres_update_reserve_summary() */
GNUNET_PQ_make_prepare ("auditor_reserve_balance_update",
"UPDATE auditor_reserve_balance SET"
" reserve_balance_val=$1"
",reserve_balance_frac=$2"
- ",withdraw_fee_balance_val=$3"
- ",withdraw_fee_balance_frac=$4"
- ",purse_fee_balance_val=$5"
- ",purse_fee_balance_frac=$6"
- ",history_fee_balance_val=$7"
- ",history_fee_balance_frac=$8"
- " WHERE master_pub=$9;"),
+ ",reserve_loss_val=$3"
+ ",reserve_loss_frac=$4"
+ ",withdraw_fee_balance_val=$5"
+ ",withdraw_fee_balance_frac=$6"
+ ",close_fee_balance_val=$7"
+ ",close_fee_balance_frac=$8"
+ ",purse_fee_balance_val=$9"
+ ",purse_fee_balance_frac=$10"
+ ",open_fee_balance_val=$11"
+ ",open_fee_balance_frac=$12"
+ ",history_fee_balance_val=$13"
+ ",history_fee_balance_frac=$14"
+ " WHERE master_pub=$15;"),
/* Used in #postgres_get_reserve_summary() */
GNUNET_PQ_make_prepare ("auditor_reserve_balance_select",
"SELECT"
" reserve_balance_val"
",reserve_balance_frac"
+ ",reserve_loss_val"
+ ",reserve_loss_frac"
",withdraw_fee_balance_val"
",withdraw_fee_balance_frac"
+ ",close_fee_balance_val"
+ ",close_fee_balance_frac"
",purse_fee_balance_val"
",purse_fee_balance_frac"
+ ",open_fee_balance_val"
+ ",open_fee_balance_frac"
",history_fee_balance_val"
",history_fee_balance_frac"
" FROM auditor_reserve_balance"
@@ -534,14 +609,18 @@ setup_connection (struct PostgresClosure *pg)
",melt_fee_balance_frac"
",refund_fee_balance_val"
",refund_fee_balance_frac"
+ ",purse_fee_balance_val"
+ ",purse_fee_balance_frac"
+ ",open_deposit_fee_balance_val"
+ ",open_deposit_fee_balance_frac"
",risk_val"
",risk_frac"
",loss_val"
",loss_frac"
- ",irregular_recoup_val"
- ",irregular_recoup_frac"
+ ",irregular_loss_val"
+ ",irregular_loss_frac"
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,"
- " $11,$12,$13,$14,$15);"),
+ " $11,$12,$13,$14,$15,$16,$17,$18,$19);"),
/* Used in #postgres_update_balance_summary() */
GNUNET_PQ_make_prepare ("auditor_balance_summary_update",
"UPDATE auditor_balance_summary SET"
@@ -553,13 +632,17 @@ setup_connection (struct PostgresClosure *pg)
",melt_fee_balance_frac=$6"
",refund_fee_balance_val=$7"
",refund_fee_balance_frac=$8"
- ",risk_val=$9"
- ",risk_frac=$10"
- ",loss_val=$11"
- ",loss_frac=$12"
- ",irregular_recoup_val=$13"
- ",irregular_recoup_frac=$14"
- " WHERE master_pub=$15;"),
+ ",purse_fee_balance_val=$9"
+ ",purse_fee_balance_frac=$10"
+ ",open_deposit_fee_balance_val=$11"
+ ",open_deposit_fee_balance_frac=$12"
+ ",risk_val=$13"
+ ",risk_frac=$14"
+ ",loss_val=$15"
+ ",loss_frac=$16"
+ ",irregular_loss_val=$17"
+ ",irregular_loss_frac=$18"
+ " WHERE master_pub=$19;"),
/* Used in #postgres_get_balance_summary() */
GNUNET_PQ_make_prepare ("auditor_balance_summary_select",
"SELECT"
@@ -571,12 +654,16 @@ setup_connection (struct PostgresClosure *pg)
",melt_fee_balance_frac"
",refund_fee_balance_val"
",refund_fee_balance_frac"
+ ",purse_fee_balance_val"
+ ",purse_fee_balance_frac"
+ ",open_deposit_fee_balance_val"
+ ",open_deposit_fee_balance_frac"
",risk_val"
",risk_frac"
",loss_val"
",loss_frac"
- ",irregular_recoup_val"
- ",irregular_recoup_frac"
+ ",irregular_loss_val"
+ ",irregular_loss_frac"
" FROM auditor_balance_summary"
" WHERE master_pub=$1;"),
/* Used in #postgres_insert_historic_denom_revenue() */
@@ -1230,12 +1317,11 @@ postgres_insert_auditor_progress_reserve (
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_out_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_recoup_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_open_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_close_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_purse_merges_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_purse_deposits_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppr->last_purse_decisions_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_account_merges_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_history_requests_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_close_requests_serial_id),
GNUNET_PQ_query_param_end
};
@@ -1265,12 +1351,11 @@ postgres_update_auditor_progress_reserve (
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_out_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_recoup_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_open_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_close_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_purse_merges_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_purse_deposits_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppr->last_purse_decisions_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_account_merges_serial_id),
GNUNET_PQ_query_param_uint64 (&ppr->last_history_requests_serial_id),
- GNUNET_PQ_query_param_uint64 (&ppr->last_close_requests_serial_id),
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
@@ -1307,18 +1392,16 @@ postgres_get_auditor_progress_reserve (
&ppr->last_reserve_out_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_reserve_recoup_serial_id",
&ppr->last_reserve_recoup_serial_id),
+ GNUNET_PQ_result_spec_uint64 ("last_reserve_open_serial_id",
+ &ppr->last_reserve_open_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_reserve_close_serial_id",
&ppr->last_reserve_close_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_purse_merges_serial_id",
- &ppr->last_purse_merges_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_purse_deposits_serial_id",
- &ppr->last_purse_deposits_serial_id),
+ GNUNET_PQ_result_spec_uint64 ("last_purse_decision_serial_id",
+ &ppr->last_purse_decisions_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_account_merges_serial_id",
&ppr->last_account_merges_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_history_requests_serial_id",
&ppr->last_history_requests_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_close_requests_serial_id",
- &ppr->last_close_requests_serial_id),
GNUNET_PQ_result_spec_end
};
@@ -1335,6 +1418,110 @@ postgres_get_auditor_progress_reserve (
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param master_pub master key of the exchange
+ * @param ppp where is the auditor in processing
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_insert_auditor_progress_purse (
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct TALER_AUDITORDB_ProgressPointPurse *ppp)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (master_pub),
+ GNUNET_PQ_query_param_uint64 (&ppp->last_purse_request_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppp->last_purse_decision_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppp->last_purse_merge_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppp->last_account_merge_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppp->last_purse_deposits_serial_id),
+ GNUNET_PQ_query_param_end
+ };
+
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "auditor_progress_insert_purse",
+ params);
+}
+
+
+/**
+ * Update information about the progress of the auditor. There
+ * must be an existing record for the exchange.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param master_pub master key of the exchange
+ * @param ppp where is the auditor in processing
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_update_auditor_progress_purse (
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct TALER_AUDITORDB_ProgressPointPurse *ppp)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_uint64 (&ppp->last_purse_request_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppp->last_purse_decision_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppp->last_purse_merge_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppp->last_account_merge_serial_id),
+ GNUNET_PQ_query_param_uint64 (&ppp->last_purse_deposits_serial_id),
+ GNUNET_PQ_query_param_auto_from_type (master_pub),
+ GNUNET_PQ_query_param_end
+ };
+
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "auditor_progress_update_purse",
+ params);
+}
+
+
+/**
+ * Get information about the progress of the auditor.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param master_pub master key of the exchange
+ * @param[out] ppp set to where the auditor is in processing
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_get_auditor_progress_purse (
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ struct TALER_AUDITORDB_ProgressPointPurse *ppp)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (master_pub),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_uint64 ("last_purse_request_serial_id",
+ &ppp->last_purse_request_serial_id),
+ GNUNET_PQ_result_spec_uint64 ("last_purse_decision_serial_id",
+ &ppp->last_purse_decision_serial_id),
+ GNUNET_PQ_result_spec_uint64 ("last_purse_merges_serial_id",
+ &ppp->last_purse_merge_serial_id),
+ GNUNET_PQ_result_spec_uint64 ("last_account_merges_serial_id",
+ &ppp->last_account_merge_serial_id),
+ GNUNET_PQ_result_spec_uint64 ("last_purse_deposits_serial_id",
+ &ppp->last_purse_deposits_serial_id),
+ GNUNET_PQ_result_spec_end
+ };
+
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "auditor_progress_select_purse",
+ params,
+ rs);
+}
+
+
+/**
+ * Insert information about the auditor's progress with an exchange's
+ * data.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param master_pub master key of the exchange
* @param ppa where is the auditor in processing
* @return transaction status code
*/
@@ -1609,7 +1796,7 @@ postgres_get_auditor_progress_coin (
&ppc->last_recoup_refresh_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_purse_deposits_serial_id",
&ppc->last_purse_deposits_serial_id),
- GNUNET_PQ_result_spec_uint64 ("last_purse_refunds_serial_id",
+ GNUNET_PQ_result_spec_uint64 ("last_purse_decision_serial_id",
&ppc->last_purse_refunds_serial_id),
GNUNET_PQ_result_spec_end
};
@@ -1629,8 +1816,7 @@ postgres_get_auditor_progress_coin (
* @param master_pub master key of the exchange
* @param account_name name of the wire account we are auditing
* @param pp how far are we in the auditor's tables
- * @param in_wire_off how far are we in the incoming wire transfers
- * @param out_wire_off how far are we in the outgoing wire transfers
+ * @param bapp progress in wire transaction histories
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -1639,8 +1825,7 @@ postgres_insert_wire_auditor_account_progress (
const struct TALER_MasterPublicKeyP *master_pub,
const char *account_name,
const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- uint64_t in_wire_off,
- uint64_t out_wire_off)
+ const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@@ -1648,8 +1833,8 @@ postgres_insert_wire_auditor_account_progress (
GNUNET_PQ_query_param_string (account_name),
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),
- GNUNET_PQ_query_param_uint64 (&in_wire_off),
- GNUNET_PQ_query_param_uint64 (&out_wire_off),
+ GNUNET_PQ_query_param_uint64 (&bapp->in_wire_off),
+ GNUNET_PQ_query_param_uint64 (&bapp->out_wire_off),
GNUNET_PQ_query_param_end
};
@@ -1667,8 +1852,7 @@ postgres_insert_wire_auditor_account_progress (
* @param master_pub master key of the exchange
* @param account_name name of the wire account we are auditing
* @param pp where is the auditor in processing
- * @param in_wire_off how far are we in the incoming wire transaction history
- * @param out_wire_off how far are we in the outgoing wire transaction history
+ * @param bapp progress in wire transaction histories
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -1677,15 +1861,14 @@ postgres_update_wire_auditor_account_progress (
const struct TALER_MasterPublicKeyP *master_pub,
const char *account_name,
const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- uint64_t in_wire_off,
- uint64_t out_wire_off)
+ const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),
- GNUNET_PQ_query_param_uint64 (&in_wire_off),
- GNUNET_PQ_query_param_uint64 (&out_wire_off),
+ GNUNET_PQ_query_param_uint64 (&bapp->in_wire_off),
+ GNUNET_PQ_query_param_uint64 (&bapp->out_wire_off),
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_string (account_name),
GNUNET_PQ_query_param_end
@@ -1704,8 +1887,7 @@ postgres_update_wire_auditor_account_progress (
* @param master_pub master key of the exchange
* @param account_name name of the wire account we are auditing
* @param[out] pp where is the auditor in processing
- * @param[out] in_wire_off how far are we in the incoming wire transaction history
- * @param[out] out_wire_off how far are we in the outgoing wire transaction history
+ * @param[out] bapp how far are we in the wire transaction histories
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -1714,8 +1896,7 @@ postgres_get_wire_auditor_account_progress (
const struct TALER_MasterPublicKeyP *master_pub,
const char *account_name,
struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
- uint64_t *in_wire_off,
- uint64_t *out_wire_off)
+ struct TALER_AUDITORDB_BankAccountProgressPoint *bapp)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@@ -1729,9 +1910,9 @@ postgres_get_wire_auditor_account_progress (
GNUNET_PQ_result_spec_uint64 ("last_wire_wire_out_serial_id",
&pp->last_wire_out_serial_id),
GNUNET_PQ_result_spec_uint64 ("wire_in_off",
- in_wire_off),
+ &bapp->in_wire_off),
GNUNET_PQ_result_spec_uint64 ("wire_out_off",
- out_wire_off),
+ &bapp->out_wire_off),
GNUNET_PQ_result_spec_end
};
@@ -1842,36 +2023,37 @@ postgres_get_wire_auditor_progress (
* @param reserve_pub public key of the reserve
* @param master_pub master public key of the exchange
* @param reserve_balance amount stored in the reserve
- * @param withdraw_fee_balance amount the exchange gained in withdraw fees
- * due to withdrawals from this reserve
- * @param expiration_date expiration date of the reserve
+ * @param rfb amounts for the reserve
* @param origin_account where did the money in the reserve originally come from
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
-postgres_insert_reserve_info (void *cls,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *reserve_balance,
- const struct TALER_Amount *withdraw_fee_balance,
- struct GNUNET_TIME_Timestamp expiration_date,
- const char *origin_account)
+postgres_insert_reserve_info (
+ void *cls,
+ const struct TALER_ReservePublicKeyP *reserve_pub,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
+ struct GNUNET_TIME_Timestamp expiration_date,
+ const char *origin_account)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
GNUNET_PQ_query_param_auto_from_type (master_pub),
- TALER_PQ_query_param_amount (reserve_balance),
- TALER_PQ_query_param_amount (withdraw_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->reserve_balance),
+ TALER_PQ_query_param_amount (&rfb->reserve_loss),
+ TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->close_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->purse_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->open_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->history_fee_balance),
GNUNET_PQ_query_param_timestamp (&expiration_date),
- GNUNET_PQ_query_param_string (origin_account),
+ NULL == origin_account
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (origin_account),
GNUNET_PQ_query_param_end
};
- GNUNET_assert (GNUNET_YES ==
- TALER_amount_cmp_currency (reserve_balance,
- withdraw_fee_balance));
-
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_reserves_insert",
params);
@@ -1885,34 +2067,32 @@ postgres_insert_reserve_info (void *cls,
* @param cls the @e cls of this struct with the plugin-specific state
* @param reserve_pub public key of the reserve
* @param master_pub master public key of the exchange
- * @param reserve_balance amount stored in the reserve
- * @param withdraw_fee_balance amount the exchange gained in withdraw fees
- * due to withdrawals from this reserve
+ * @param rfb amounts for the reserve
* @param expiration_date expiration date of the reserve
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
-postgres_update_reserve_info (void *cls,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *reserve_balance,
- const struct TALER_Amount *withdraw_fee_balance,
- struct GNUNET_TIME_Timestamp expiration_date)
+postgres_update_reserve_info (
+ void *cls,
+ const struct TALER_ReservePublicKeyP *reserve_pub,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
+ struct GNUNET_TIME_Timestamp expiration_date)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- TALER_PQ_query_param_amount (reserve_balance),
- TALER_PQ_query_param_amount (withdraw_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->reserve_balance),
+ TALER_PQ_query_param_amount (&rfb->reserve_loss),
+ TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->purse_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->open_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->history_fee_balance),
GNUNET_PQ_query_param_timestamp (&expiration_date),
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
- GNUNET_assert (GNUNET_YES ==
- TALER_amount_cmp_currency (reserve_balance,
- withdraw_fee_balance));
-
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_reserves_update",
params);
@@ -1952,9 +2132,7 @@ postgres_del_reserve_info (void *cls,
* @param reserve_pub public key of the reserve
* @param master_pub master public key of the exchange
* @param[out] rowid which row did we get the information from
- * @param[out] reserve_balance amount stored in the reserve
- * @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees
- * due to withdrawals from this reserve
+ * @param[out] rfb where to store the reserve balance summary
* @param[out] expiration_date expiration date of the reserve
* @param[out] sender_account from where did the money in the reserve originally come from
* @return transaction status code
@@ -1964,8 +2142,7 @@ postgres_get_reserve_info (void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_MasterPublicKeyP *master_pub,
uint64_t *rowid,
- struct TALER_Amount *reserve_balance,
- struct TALER_Amount *withdraw_fee_balance,
+ struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
struct GNUNET_TIME_Timestamp *expiration_date,
char **sender_account)
{
@@ -1976,14 +2153,32 @@ postgres_get_reserve_info (void *cls,
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance", reserve_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance", withdraw_fee_balance),
- GNUNET_PQ_result_spec_timestamp ("expiration_date", expiration_date),
- GNUNET_PQ_result_spec_uint64 ("auditor_reserves_rowid", rowid),
- GNUNET_PQ_result_spec_string ("origin_account", sender_account),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance",
+ &rfb->reserve_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss",
+ &rfb->reserve_loss),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance",
+ &rfb->withdraw_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance",
+ &rfb->close_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
+ &rfb->purse_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance",
+ &rfb->open_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee_balance",
+ &rfb->history_fee_balance),
+ GNUNET_PQ_result_spec_timestamp ("expiration_date",
+ expiration_date),
+ GNUNET_PQ_result_spec_uint64 ("auditor_reserves_rowid",
+ rowid),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_string ("origin_account",
+ sender_account),
+ NULL),
GNUNET_PQ_result_spec_end
};
+ *sender_account = NULL;
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"auditor_reserves_select",
params,
@@ -1997,34 +2192,31 @@ postgres_get_reserve_info (void *cls,
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param master_pub master public key of the exchange
- * @param reserve_balance amount stored in the reserve
- * @param withdraw_fee_balance amount the exchange gained in withdraw fees
- * @param purse_fee_balance amount the exchange gained in purse fees
- * @param history_fee_balance amount the exchange gained in history fees
+ * @param rfb balances to be stored for the reserve
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
postgres_insert_reserve_summary (
void *cls,
const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *reserve_balance,
- const struct TALER_Amount *withdraw_fee_balance,
- const struct TALER_Amount *purse_fee_balance,
- const struct TALER_Amount *history_fee_balance)
+ const struct TALER_AUDITORDB_ReserveFeeBalance *rfb)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (master_pub),
- TALER_PQ_query_param_amount (reserve_balance),
- TALER_PQ_query_param_amount (withdraw_fee_balance),
- TALER_PQ_query_param_amount (purse_fee_balance),
- TALER_PQ_query_param_amount (history_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->reserve_balance),
+ TALER_PQ_query_param_amount (&rfb->reserve_loss),
+ TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->close_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->purse_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->open_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->history_fee_balance),
GNUNET_PQ_query_param_end
};
GNUNET_assert (GNUNET_YES ==
- TALER_amount_cmp_currency (reserve_balance,
- withdraw_fee_balance));
+ TALER_amount_cmp_currency (&rfb->reserve_balance,
+ &rfb->withdraw_fee_balance));
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_reserve_balance_insert",
@@ -2038,28 +2230,24 @@ postgres_insert_reserve_summary (
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param master_pub master public key of the exchange
- * @param reserve_balance amount stored in the reserve
- * @param withdraw_fee_balance amount the exchange gained in withdraw fees
- * due to withdrawals from this reserve
- * @param purse_fee_balance amount the exchange gained in purse fees
- * @param history_fee_balance amount the exchange gained in history fees
+ * @param rfb balances to be stored for the reserve
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
postgres_update_reserve_summary (
void *cls,
const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *reserve_balance,
- const struct TALER_Amount *withdraw_fee_balance,
- const struct TALER_Amount *purse_fee_balance,
- const struct TALER_Amount *history_fee_balance)
+ const struct TALER_AUDITORDB_ReserveFeeBalance *rfb)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- TALER_PQ_query_param_amount (reserve_balance),
- TALER_PQ_query_param_amount (withdraw_fee_balance),
- TALER_PQ_query_param_amount (purse_fee_balance),
- TALER_PQ_query_param_amount (history_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->reserve_balance),
+ TALER_PQ_query_param_amount (&rfb->reserve_loss),
+ TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->close_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->purse_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->open_fee_balance),
+ TALER_PQ_query_param_amount (&rfb->history_fee_balance),
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
@@ -2075,19 +2263,13 @@ postgres_update_reserve_summary (
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param master_pub master public key of the exchange
- * @param[out] reserve_balance amount stored in reserves
- * @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees
- * @param[out] purse_fee_balance amount the exchange gained in purse fees
- * @param[out] history_fee_balance amount the exchange gained in history fees
+ * @param[out] rfb balances are returned here
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
postgres_get_reserve_summary (void *cls,
const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_Amount *reserve_balance,
- struct TALER_Amount *withdraw_fee_balance,
- struct TALER_Amount *purse_fee_balance,
- struct TALER_Amount *history_fee_balance)
+ struct TALER_AUDITORDB_ReserveFeeBalance *rfb)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@@ -2095,10 +2277,20 @@ postgres_get_reserve_summary (void *cls,
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance", reserve_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance", withdraw_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance", purse_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee_balance", history_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance",
+ &rfb->reserve_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss",
+ &rfb->reserve_loss),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance",
+ &rfb->withdraw_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance",
+ &rfb->close_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
+ &rfb->purse_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance",
+ &rfb->open_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee_balance",
+ &rfb->history_fee_balance),
GNUNET_PQ_result_spec_end
};
@@ -2202,31 +2394,23 @@ postgres_get_wire_fee_summary (void *cls,
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param denom_pub_hash hash of the denomination public key
- * @param denom_balance value of coins outstanding with this denomination key
- * @param denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance)
- * @param denom_risk value of coins issued with this denomination key
- * @param recoup_loss losses from recoup (if this denomination was revoked)
- * @param num_issued how many coins of this denomination did the exchange blind-sign
+ * @param dcd circulation data to store
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
postgres_insert_denomination_balance (
void *cls,
const struct TALER_DenominationHashP *denom_pub_hash,
- const struct TALER_Amount *denom_balance,
- const struct TALER_Amount *denom_loss,
- const struct TALER_Amount *denom_risk,
- const struct TALER_Amount *recoup_loss,
- uint64_t num_issued)
+ const struct TALER_AUDITORDB_DenominationCirculationData *dcd)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
- TALER_PQ_query_param_amount (denom_balance),
- TALER_PQ_query_param_amount (denom_loss),
- GNUNET_PQ_query_param_uint64 (&num_issued),
- TALER_PQ_query_param_amount (denom_risk),
- TALER_PQ_query_param_amount (recoup_loss),
+ TALER_PQ_query_param_amount (&dcd->denom_balance),
+ TALER_PQ_query_param_amount (&dcd->denom_loss),
+ GNUNET_PQ_query_param_uint64 (&dcd->num_issued),
+ TALER_PQ_query_param_amount (&dcd->denom_risk),
+ TALER_PQ_query_param_amount (&dcd->recoup_loss),
GNUNET_PQ_query_param_end
};
@@ -2242,30 +2426,22 @@ postgres_insert_denomination_balance (
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param denom_pub_hash hash of the denomination public key
- * @param denom_balance value of coins outstanding with this denomination key
- * @param denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance)
-* @param denom_risk value of coins issued with this denomination key
- * @param recoup_loss losses from recoup (if this denomination was revoked)
- * @param num_issued how many coins of this denomination did the exchange blind-sign
+ * @param dcd circulation data to store
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
postgres_update_denomination_balance (
void *cls,
const struct TALER_DenominationHashP *denom_pub_hash,
- const struct TALER_Amount *denom_balance,
- const struct TALER_Amount *denom_loss,
- const struct TALER_Amount *denom_risk,
- const struct TALER_Amount *recoup_loss,
- uint64_t num_issued)
+ const struct TALER_AUDITORDB_DenominationCirculationData *dcd)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- TALER_PQ_query_param_amount (denom_balance),
- TALER_PQ_query_param_amount (denom_loss),
- GNUNET_PQ_query_param_uint64 (&num_issued),
- TALER_PQ_query_param_amount (denom_risk),
- TALER_PQ_query_param_amount (recoup_loss),
+ TALER_PQ_query_param_amount (&dcd->denom_balance),
+ TALER_PQ_query_param_amount (&dcd->denom_loss),
+ GNUNET_PQ_query_param_uint64 (&dcd->num_issued),
+ TALER_PQ_query_param_amount (&dcd->denom_risk),
+ TALER_PQ_query_param_amount (&dcd->recoup_loss),
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
GNUNET_PQ_query_param_end
};
@@ -2281,22 +2457,14 @@ postgres_update_denomination_balance (
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param denom_pub_hash hash of the denomination public key
- * @param[out] denom_balance value of coins outstanding with this denomination key
- * @param[out] denom_risk value of coins issued with this denomination key
- * @param[out] denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance)
- * @param[out] recoup_loss losses from recoup (if this denomination was revoked)
- * @param[out] num_issued how many coins of this denomination did the exchange blind-sign
+ * @param[out] dcd circulation data to initialize
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
postgres_get_denomination_balance (
void *cls,
const struct TALER_DenominationHashP *denom_pub_hash,
- struct TALER_Amount *denom_balance,
- struct TALER_Amount *denom_loss,
- struct TALER_Amount *denom_risk,
- struct TALER_Amount *recoup_loss,
- uint64_t *num_issued)
+ struct TALER_AUDITORDB_DenominationCirculationData *dcd)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@@ -2304,11 +2472,16 @@ postgres_get_denomination_balance (
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance", denom_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss", denom_loss),
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk", denom_risk),
- TALER_PQ_RESULT_SPEC_AMOUNT ("recoup_loss", recoup_loss),
- GNUNET_PQ_result_spec_uint64 ("num_issued", num_issued),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance",
+ &dcd->denom_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss",
+ &dcd->denom_loss),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk",
+ &dcd->denom_risk),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("recoup_loss",
+ &dcd->recoup_loss),
+ GNUNET_PQ_result_spec_uint64 ("num_issued",
+ &dcd->num_issued),
GNUNET_PQ_result_spec_end
};
@@ -2325,51 +2498,30 @@ postgres_get_denomination_balance (
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param master_pub master key of the exchange
- * @param denom_balance value of coins outstanding with this denomination key
- * @param deposit_fee_balance total deposit fees collected for this DK
- * @param melt_fee_balance total melt fees collected for this DK
- * @param refund_fee_balance total refund fees collected for this DK
- * @param risk maximum risk exposure of the exchange
- * @param loss materialized @a risk from recoup
- * @param irregular_recoup recoups on non-revoked coins
+ * @param dfb denomination balance data to store
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
postgres_insert_balance_summary (
void *cls,
const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *denom_balance,
- const struct TALER_Amount *deposit_fee_balance,
- const struct TALER_Amount *melt_fee_balance,
- const struct TALER_Amount *refund_fee_balance,
- const struct TALER_Amount *risk,
- const struct TALER_Amount *loss,
- const struct TALER_Amount *irregular_recoup)
+ const struct TALER_AUDITORDB_GlobalCoinBalance *dfb)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (master_pub),
- TALER_PQ_query_param_amount (denom_balance),
- TALER_PQ_query_param_amount (deposit_fee_balance),
- TALER_PQ_query_param_amount (melt_fee_balance),
- TALER_PQ_query_param_amount (refund_fee_balance),
- TALER_PQ_query_param_amount (risk),
- TALER_PQ_query_param_amount (loss),
- TALER_PQ_query_param_amount (irregular_recoup),
+ TALER_PQ_query_param_amount (&dfb->total_escrowed),
+ TALER_PQ_query_param_amount (&dfb->deposit_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->melt_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->refund_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->purse_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->open_deposit_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->risk),
+ TALER_PQ_query_param_amount (&dfb->loss),
+ TALER_PQ_query_param_amount (&dfb->irregular_loss),
GNUNET_PQ_query_param_end
};
- GNUNET_assert (GNUNET_YES ==
- TALER_amount_cmp_currency (denom_balance,
- deposit_fee_balance));
- GNUNET_assert (GNUNET_YES ==
- TALER_amount_cmp_currency (denom_balance,
- melt_fee_balance));
-
- GNUNET_assert (GNUNET_YES ==
- TALER_amount_cmp_currency (denom_balance,
- refund_fee_balance));
-
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"auditor_balance_summary_insert",
params);
@@ -2382,36 +2534,26 @@ postgres_insert_balance_summary (
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param master_pub master key of the exchange
- * @param denom_balance value of coins outstanding with this denomination key
- * @param deposit_fee_balance total deposit fees collected for this DK
- * @param melt_fee_balance total melt fees collected for this DK
- * @param refund_fee_balance total refund fees collected for this DK
- * @param risk maximum risk exposure of the exchange
- * @param loss materialized @a risk from recoup
- * @param irregular_recoup recoups made on non-revoked coins
+ * @param dfb denomination balance data to store
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
postgres_update_balance_summary (
void *cls,
const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_Amount *denom_balance,
- const struct TALER_Amount *deposit_fee_balance,
- const struct TALER_Amount *melt_fee_balance,
- const struct TALER_Amount *refund_fee_balance,
- const struct TALER_Amount *risk,
- const struct TALER_Amount *loss,
- const struct TALER_Amount *irregular_recoup)
+ const struct TALER_AUDITORDB_GlobalCoinBalance *dfb)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- TALER_PQ_query_param_amount (denom_balance),
- TALER_PQ_query_param_amount (deposit_fee_balance),
- TALER_PQ_query_param_amount (melt_fee_balance),
- TALER_PQ_query_param_amount (refund_fee_balance),
- TALER_PQ_query_param_amount (risk),
- TALER_PQ_query_param_amount (loss),
- TALER_PQ_query_param_amount (irregular_recoup),
+ TALER_PQ_query_param_amount (&dfb->total_escrowed),
+ TALER_PQ_query_param_amount (&dfb->deposit_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->melt_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->refund_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->purse_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->open_deposit_fee_balance),
+ TALER_PQ_query_param_amount (&dfb->risk),
+ TALER_PQ_query_param_amount (&dfb->loss),
+ TALER_PQ_query_param_amount (&dfb->irregular_loss),
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
@@ -2427,25 +2569,14 @@ postgres_update_balance_summary (
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param master_pub master key of the exchange
- * @param[out] denom_balance value of coins outstanding with this denomination key
- * @param[out] deposit_fee_balance total deposit fees collected for this DK
- * @param[out] melt_fee_balance total melt fees collected for this DK
- * @param[out] refund_fee_balance total refund fees collected for this DK
- * @param[out] risk maximum risk exposure of the exchange
- * @param[out] loss losses from recoup (on revoked denominations)
- * @param[out] irregular_recoup recoups on NOT revoked denominations
+ * @param[out] dfb where to return the denomination balances
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
-postgres_get_balance_summary (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- struct TALER_Amount *denom_balance,
- struct TALER_Amount *deposit_fee_balance,
- struct TALER_Amount *melt_fee_balance,
- struct TALER_Amount *refund_fee_balance,
- struct TALER_Amount *risk,
- struct TALER_Amount *loss,
- struct TALER_Amount *irregular_recoup)
+postgres_get_balance_summary (
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ struct TALER_AUDITORDB_GlobalCoinBalance *dfb)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@@ -2453,13 +2584,24 @@ postgres_get_balance_summary (void *cls,
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance", denom_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("deposit_fee_balance", deposit_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("melt_fee_balance", melt_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("refund_fee_balance", refund_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("risk", risk),
- TALER_PQ_RESULT_SPEC_AMOUNT ("loss", loss),
- TALER_PQ_RESULT_SPEC_AMOUNT ("irregular_recoup", irregular_recoup),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance",
+ &dfb->total_escrowed),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("deposit_fee_balance",
+ &dfb->deposit_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("melt_fee_balance",
+ &dfb->melt_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("refund_fee_balance",
+ &dfb->refund_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
+ &dfb->purse_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("open_deposit_fee_balance",
+ &dfb->open_deposit_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("risk",
+ &dfb->risk),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("loss",
+ &dfb->loss),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("irregular_loss",
+ &dfb->irregular_loss),
GNUNET_PQ_result_spec_end
};
@@ -2920,33 +3062,45 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
plugin->insert_deposit_confirmation = &postgres_insert_deposit_confirmation;
plugin->get_deposit_confirmations = &postgres_get_deposit_confirmations;
- plugin->get_auditor_progress_reserve = &postgres_get_auditor_progress_reserve;
- plugin->update_auditor_progress_reserve =
- &postgres_update_auditor_progress_reserve;
- plugin->insert_auditor_progress_reserve =
- &postgres_insert_auditor_progress_reserve;
- plugin->get_auditor_progress_aggregation =
- &postgres_get_auditor_progress_aggregation;
- plugin->update_auditor_progress_aggregation =
- &postgres_update_auditor_progress_aggregation;
- plugin->insert_auditor_progress_aggregation =
- &postgres_insert_auditor_progress_aggregation;
- plugin->get_auditor_progress_deposit_confirmation =
- &postgres_get_auditor_progress_deposit_confirmation;
- plugin->update_auditor_progress_deposit_confirmation =
- &postgres_update_auditor_progress_deposit_confirmation;
- plugin->insert_auditor_progress_deposit_confirmation =
- &postgres_insert_auditor_progress_deposit_confirmation;
+ plugin->get_auditor_progress_reserve
+ = &postgres_get_auditor_progress_reserve;
+ plugin->update_auditor_progress_reserve
+ = &postgres_update_auditor_progress_reserve;
+ plugin->insert_auditor_progress_reserve
+ = &postgres_insert_auditor_progress_reserve;
+
+ plugin->get_auditor_progress_purse
+ = &postgres_get_auditor_progress_purse;
+ plugin->update_auditor_progress_purse
+ = &postgres_update_auditor_progress_purse;
+ plugin->insert_auditor_progress_purse
+ = &postgres_insert_auditor_progress_purse;
+
+ plugin->get_auditor_progress_aggregation
+ = &postgres_get_auditor_progress_aggregation;
+ plugin->update_auditor_progress_aggregation
+ = &postgres_update_auditor_progress_aggregation;
+ plugin->insert_auditor_progress_aggregation
+ = &postgres_insert_auditor_progress_aggregation;
+
+ plugin->get_auditor_progress_deposit_confirmation
+ = &postgres_get_auditor_progress_deposit_confirmation;
+ plugin->update_auditor_progress_deposit_confirmation
+ = &postgres_update_auditor_progress_deposit_confirmation;
+ plugin->insert_auditor_progress_deposit_confirmation
+ = &postgres_insert_auditor_progress_deposit_confirmation;
+
plugin->get_auditor_progress_coin = &postgres_get_auditor_progress_coin;
plugin->update_auditor_progress_coin = &postgres_update_auditor_progress_coin;
plugin->insert_auditor_progress_coin = &postgres_insert_auditor_progress_coin;
- plugin->get_wire_auditor_account_progress =
- &postgres_get_wire_auditor_account_progress;
- plugin->update_wire_auditor_account_progress =
- &postgres_update_wire_auditor_account_progress;
- plugin->insert_wire_auditor_account_progress =
- &postgres_insert_wire_auditor_account_progress;
+ plugin->get_wire_auditor_account_progress
+ = &postgres_get_wire_auditor_account_progress;
+ plugin->update_wire_auditor_account_progress
+ = &postgres_update_wire_auditor_account_progress;
+ plugin->insert_wire_auditor_account_progress
+ = &postgres_insert_wire_auditor_account_progress;
+
plugin->get_wire_auditor_progress = &postgres_get_wire_auditor_progress;
plugin->update_wire_auditor_progress = &postgres_update_wire_auditor_progress;
plugin->insert_wire_auditor_progress = &postgres_insert_wire_auditor_progress;
@@ -2972,15 +3126,15 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
plugin->update_balance_summary = &postgres_update_balance_summary;
plugin->insert_balance_summary = &postgres_insert_balance_summary;
- plugin->select_historic_denom_revenue =
- &postgres_select_historic_denom_revenue;
- plugin->insert_historic_denom_revenue =
- &postgres_insert_historic_denom_revenue;
+ plugin->select_historic_denom_revenue
+ = &postgres_select_historic_denom_revenue;
+ plugin->insert_historic_denom_revenue
+ = &postgres_insert_historic_denom_revenue;
- plugin->select_historic_reserve_revenue =
- &postgres_select_historic_reserve_revenue;
- plugin->insert_historic_reserve_revenue =
- &postgres_insert_historic_reserve_revenue;
+ plugin->select_historic_reserve_revenue
+ = &postgres_select_historic_reserve_revenue;
+ plugin->insert_historic_reserve_revenue
+ = &postgres_insert_historic_reserve_revenue;
plugin->get_predicted_balance = &postgres_get_predicted_balance;
plugin->update_predicted_result = &postgres_update_predicted_result;
diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c
index 1e5ca7553..d39d08b91 100644
--- a/src/auditordb/test_auditordb.c
+++ b/src/auditordb/test_auditordb.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2016 Taler Systems SA
+ Copyright (C) 2016--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
@@ -17,17 +17,17 @@
* @file auditordb/test_auditordb.c
* @brief test cases for DB interaction functions
* @author Gabor X Toth
+ * @author Christian Grothoff
*/
#include "platform.h"
#include <gnunet/gnunet_db_lib.h>
#include "taler_auditordb_lib.h"
#include "taler_auditordb_plugin.h"
-
/**
- * Global result from the testcase.
+ * Currency we use, must match CURRENCY in "test-auditor-db-postgres.conf".
*/
-static int result = -1;
+#define CURRENCY "EUR"
/**
* Report line of error if @a cond is true, and jump to label "drop".
@@ -39,7 +39,6 @@ static int result = -1;
goto drop; \
} while (0)
-
/**
* Initializes @a ptr with random data.
*/
@@ -54,15 +53,124 @@ static int result = -1;
/**
- * Currency we use, must match CURRENCY in "test-auditor-db-postgres.conf".
+ * Global result from the testcase.
*/
-#define CURRENCY "EUR"
+static int result = -1;
+
+/**
+ * Hash of denomination public key.
+ */
+static struct TALER_DenominationHashP denom_pub_hash;
+
+/**
+ * Another hash of a denomination public key.
+ */
+static struct TALER_DenominationHashP rnd_hash;
+
+/**
+ * Current time.
+ */
+static struct GNUNET_TIME_Timestamp now;
+
+/**
+ * Timestamp in the past.
+ */
+static struct GNUNET_TIME_Timestamp past;
+
+/**
+ * Timestamp in the future.
+ */
+static struct GNUNET_TIME_Timestamp future;
/**
* Database plugin under test.
*/
static struct TALER_AUDITORDB_Plugin *plugin;
+/**
+ * Historic denomination revenue value.
+ */
+static struct TALER_Amount rbalance;
+
+/**
+ * Historic denomination loss value.
+ */
+static struct TALER_Amount rloss;
+
+/**
+ * Reserve profit value we are using.
+ */
+static struct TALER_Amount reserve_profits;
+
+
+static enum GNUNET_GenericReturnValue
+select_historic_denom_revenue_result (
+ void *cls,
+ const struct TALER_DenominationHashP *denom_pub_hash2,
+ struct GNUNET_TIME_Timestamp revenue_timestamp2,
+ const struct TALER_Amount *revenue_balance2,
+ const struct TALER_Amount *loss2)
+{
+ static int n = 0;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "select_historic_denom_revenue_result: row %u\n", n);
+
+ if ( (2 <= n++)
+ || (cls != NULL)
+ || ((0 != GNUNET_memcmp (&revenue_timestamp2,
+ &past))
+ && (0 != GNUNET_memcmp (&revenue_timestamp2,
+ &now)))
+ || ((0 != GNUNET_memcmp (denom_pub_hash2,
+ &denom_pub_hash))
+ && (0 != GNUNET_memcmp (denom_pub_hash2,
+ &rnd_hash)))
+ || (0 != TALER_amount_cmp (revenue_balance2,
+ &rbalance))
+ || (0 != TALER_amount_cmp (loss2,
+ &rloss)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "select_historic_denom_revenue_result: result does not match\n");
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+static enum GNUNET_GenericReturnValue
+select_historic_reserve_revenue_result (
+ void *cls,
+ struct GNUNET_TIME_Timestamp start_time2,
+ struct GNUNET_TIME_Timestamp end_time2,
+ const struct TALER_Amount *reserve_profits2)
+{
+ static int n = 0;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "select_historic_reserve_revenue_result: row %u\n", n);
+
+ if ((2 <= n++)
+ || (cls != NULL)
+ || ((0 != GNUNET_memcmp (&start_time2,
+ &past))
+ && (0 != GNUNET_memcmp (&start_time2,
+ &now)))
+ || (0 != GNUNET_memcmp (&end_time2,
+ &future))
+ || (0 != TALER_amount_cmp (reserve_profits2,
+ &reserve_profits)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "select_historic_reserve_revenue_result: result does not match\n");
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
/**
* Main function that will be run by the scheduler.
@@ -130,13 +238,8 @@ run (void *cls)
struct TALER_MasterPublicKeyP master_pub;
struct TALER_ReservePublicKeyP reserve_pub;
- struct TALER_DenominationHashP rnd_hash;
struct TALER_DenominationPrivateKey denom_priv;
struct TALER_DenominationPublicKey denom_pub;
- struct TALER_DenominationHashP denom_pub_hash;
- struct GNUNET_TIME_Timestamp now;
- struct GNUNET_TIME_Timestamp past;
- struct GNUNET_TIME_Timestamp future;
struct GNUNET_TIME_Timestamp date;
RND_BLK (&master_pub);
@@ -217,472 +320,364 @@ run (void *cls)
(ppc.last_refund_serial_id != ppc2.last_refund_serial_id) ||
(ppc.last_withdraw_serial_id != ppc2.last_withdraw_serial_id) );
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_reserve_info\n");
-
- struct TALER_Amount reserve_balance;
- struct TALER_Amount withdraw_fee_balance;
- struct TALER_Amount purse_fee_balance;
- struct TALER_Amount history_fee_balance;
- struct TALER_Amount reserve_balance2 = {};
- struct TALER_Amount withdraw_fee_balance2 = {};
- struct TALER_Amount purse_fee_balance2 = {};
- struct TALER_Amount history_fee_balance2 = {};
-
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":12.345678",
- &reserve_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":23.456789",
- &withdraw_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":23.456789",
- &purse_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":23.456789",
- &history_fee_balance));
-
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_reserve_info (plugin->cls,
- &reserve_pub,
- &master_pub,
- &reserve_balance,
- &withdraw_fee_balance,
- past,
- "payto://bla/blub"));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: update_reserve_info\n");
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_reserve_info (plugin->cls,
- &reserve_pub,
- &master_pub,
- &reserve_balance,
- &withdraw_fee_balance,
- future));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: get_reserve_info\n");
-
- char *payto;
+ {
+ struct TALER_AUDITORDB_ReserveFeeBalance rfb;
+ struct TALER_AUDITORDB_ReserveFeeBalance rfb2;
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_reserve_info (plugin->cls,
- &reserve_pub,
- &master_pub,
- &rowid,
- &reserve_balance2,
- &withdraw_fee_balance2,
- &date,
- &payto));
- FAILIF (0 != strcmp (payto,
- "payto://bla/blub"));
- GNUNET_free (payto);
- FAILIF (0 != GNUNET_memcmp (&date,
- &future)
- || 0 != TALER_amount_cmp (&reserve_balance2,
- &reserve_balance)
- || 0 != TALER_amount_cmp (&withdraw_fee_balance2,
- &withdraw_fee_balance));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: insert_reserve_info\n");
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":12.345678",
+ &rfb.reserve_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":11.245678",
+ &rfb.reserve_loss));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":23.456789",
+ &rfb.withdraw_fee_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":23.456719",
+ &rfb.close_fee_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":33.456789",
+ &rfb.purse_fee_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":43.456789",
+ &rfb.open_fee_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":53.456789",
+ &rfb.history_fee_balance));
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->insert_reserve_info (plugin->cls,
+ &reserve_pub,
+ &master_pub,
+ &rfb,
+ past,
+ "payto://bla/blub"));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: update_reserve_info\n");
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->update_reserve_info (plugin->cls,
+ &reserve_pub,
+ &master_pub,
+ &rfb,
+ future));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: get_reserve_info\n");
+ {
+ char *payto;
+
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->get_reserve_info (plugin->cls,
+ &reserve_pub,
+ &master_pub,
+ &rowid,
+ &rfb2,
+ &date,
+ &payto));
+ FAILIF (0 != strcmp (payto,
+ "payto://bla/blub"));
+ GNUNET_free (payto);
+ }
+ FAILIF ( (0 != GNUNET_memcmp (&date,
+ &future))
+ || (0 != TALER_amount_cmp (&rfb2.reserve_balance,
+ &rfb.reserve_balance))
+ || (0 != TALER_amount_cmp (&rfb2.withdraw_fee_balance,
+ &rfb.withdraw_fee_balance))
+ || (0 != TALER_amount_cmp (&rfb2.close_fee_balance,
+ &rfb.close_fee_balance))
+ || (0 != TALER_amount_cmp (&rfb2.purse_fee_balance,
+ &rfb.purse_fee_balance))
+ || (0 != TALER_amount_cmp (&rfb2.open_fee_balance,
+ &rfb.open_fee_balance))
+ || (0 != TALER_amount_cmp (&rfb2.history_fee_balance,
+ &rfb.history_fee_balance))
+ );
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_reserve_summary\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: insert_reserve_summary\n");
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_reserve_summary (plugin->cls,
- &master_pub,
- &reserve_balance,
- &withdraw_fee_balance,
- &purse_fee_balance,
- &history_fee_balance));
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->insert_reserve_summary (plugin->cls,
+ &master_pub,
+ &rfb));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: update_reserve_summary\n");
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->update_reserve_summary (plugin->cls,
+ &master_pub,
+ &rfb));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: get_reserve_summary\n");
+ ZR_BLK (&rfb2);
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->get_reserve_summary (plugin->cls,
+ &master_pub,
+ &rfb2));
+ FAILIF ( (0 != TALER_amount_cmp (&rfb2.reserve_balance,
+ &rfb.reserve_balance) ||
+ (0 != TALER_amount_cmp (&rfb2.withdraw_fee_balance,
+ &rfb.withdraw_fee_balance)) ||
+ (0 != TALER_amount_cmp (&rfb2.close_fee_balance,
+ &rfb.close_fee_balance)) ||
+ (0 != TALER_amount_cmp (&rfb2.purse_fee_balance,
+ &rfb.purse_fee_balance)) ||
+ (0 != TALER_amount_cmp (&rfb2.open_fee_balance,
+ &rfb.open_fee_balance)) ||
+ (0 != TALER_amount_cmp (&rfb2.history_fee_balance,
+ &rfb.history_fee_balance))));
+ }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: update_reserve_summary\n");
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: insert_denomination_balance\n");
+
+ struct TALER_AUDITORDB_DenominationCirculationData dcd;
+ struct TALER_AUDITORDB_DenominationCirculationData dcd2;
+
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":12.345678",
+ &dcd.denom_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":0.1",
+ &dcd.denom_loss));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":13.57986",
+ &dcd.denom_risk));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":12.57986",
+ &dcd.recoup_loss));
+ dcd.num_issued = 62;
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->insert_denomination_balance (plugin->cls,
+ &denom_pub_hash,
+ &dcd));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: update_denomination_balance\n");
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->update_denomination_balance (plugin->cls,
+ &denom_pub_hash,
+ &dcd));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: get_denomination_balance\n");
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_reserve_summary (plugin->cls,
- &master_pub,
- &reserve_balance,
- &withdraw_fee_balance,
- &purse_fee_balance,
- &history_fee_balance));
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->get_denomination_balance (plugin->cls,
+ &denom_pub_hash,
+ &dcd2));
+ FAILIF (0 != TALER_amount_cmp (&dcd2.denom_balance,
+ &dcd.denom_balance));
+ FAILIF (0 != TALER_amount_cmp (&dcd2.denom_loss,
+ &dcd.denom_loss));
+ FAILIF (0 != TALER_amount_cmp (&dcd2.denom_risk,
+ &dcd.denom_risk));
+ FAILIF (0 != TALER_amount_cmp (&dcd2.recoup_loss,
+ &dcd.recoup_loss));
+ FAILIF (dcd2.num_issued != dcd.num_issued);
+ }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: get_reserve_summary\n");
+ {
+ struct TALER_AUDITORDB_GlobalCoinBalance gcb;
+ struct TALER_AUDITORDB_GlobalCoinBalance gcb2;
+
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":12.345678",
+ &gcb.total_escrowed));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":23.456789",
+ &gcb.deposit_fee_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":34.567890",
+ &gcb.melt_fee_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":45.678901",
+ &gcb.refund_fee_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":55.678901",
+ &gcb.purse_fee_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":65.678901",
+ &gcb.open_deposit_fee_balance));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":13.57986",
+ &gcb.risk));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":0.1",
+ &gcb.loss));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":1.1",
+ &gcb.irregular_loss));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: insert_balance_summary\n");
- ZR_BLK (&reserve_balance2);
- ZR_BLK (&withdraw_fee_balance2);
- ZR_BLK (&purse_fee_balance2);
- ZR_BLK (&history_fee_balance2);
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->insert_balance_summary (plugin->cls,
+ &master_pub,
+ &gcb));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: update_balance_summary\n");
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->update_balance_summary (plugin->cls,
+ &master_pub,
+ &gcb));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: get_balance_summary\n");
+ ZR_BLK (&gcb2);
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->get_balance_summary (plugin->cls,
+ &master_pub,
+ &gcb2));
+ FAILIF (0 != TALER_amount_cmp (&gcb2.total_escrowed,
+ &gcb.total_escrowed));
+ FAILIF (0 != TALER_amount_cmp (&gcb2.deposit_fee_balance,
+ &gcb.deposit_fee_balance) );
+ FAILIF (0 != TALER_amount_cmp (&gcb2.melt_fee_balance,
+ &gcb.melt_fee_balance) );
+ FAILIF (0 != TALER_amount_cmp (&gcb2.refund_fee_balance,
+ &gcb.refund_fee_balance));
+ FAILIF (0 != TALER_amount_cmp (&gcb2.purse_fee_balance,
+ &gcb.purse_fee_balance));
+ FAILIF (0 != TALER_amount_cmp (&gcb2.open_deposit_fee_balance,
+ &gcb.open_deposit_fee_balance));
+ FAILIF (0 != TALER_amount_cmp (&gcb2.risk,
+ &gcb.risk));
+ FAILIF (0 != TALER_amount_cmp (&gcb2.loss,
+ &gcb.loss));
+ FAILIF (0 != TALER_amount_cmp (&gcb2.irregular_loss,
+ &gcb.irregular_loss));
+ }
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_reserve_summary (plugin->cls,
- &master_pub,
- &reserve_balance2,
- &withdraw_fee_balance2,
- &purse_fee_balance2,
- &history_fee_balance2));
-
- FAILIF ( (0 != TALER_amount_cmp (&reserve_balance2,
- &reserve_balance) ||
- (0 != TALER_amount_cmp (&withdraw_fee_balance2,
- &withdraw_fee_balance)) ||
- (0 != TALER_amount_cmp (&purse_fee_balance2,
- &purse_fee_balance)) ||
- (0 != TALER_amount_cmp (&history_fee_balance2,
- &history_fee_balance))));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_denomination_balance\n");
-
- struct TALER_Amount denom_balance;
- struct TALER_Amount denom_loss;
- struct TALER_Amount denom_loss2;
- struct TALER_Amount deposit_fee_balance;
- struct TALER_Amount melt_fee_balance;
- struct TALER_Amount refund_fee_balance;
- struct TALER_Amount denom_balance2;
- struct TALER_Amount deposit_fee_balance2;
- struct TALER_Amount melt_fee_balance2;
- struct TALER_Amount refund_fee_balance2;
- struct TALER_Amount rbalance;
- struct TALER_Amount dbalance;
- struct TALER_Amount rbalance2;
- struct TALER_Amount dbalance2;
- struct TALER_Amount loss;
- struct TALER_Amount loss2;
- struct TALER_Amount iirp;
- struct TALER_Amount iirp2;
- uint64_t nissued;
-
+ "Test: insert_historic_denom_revenue\n");
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":12.345678",
- &denom_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":0.1",
- &denom_loss));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":23.456789",
- &deposit_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":34.567890",
- &melt_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":45.678901",
- &refund_fee_balance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":13.57986",
&rbalance));
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":12.57986",
- &dbalance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.6",
- &loss));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1",
- &iirp));
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_denomination_balance (plugin->cls,
- &denom_pub_hash,
- &denom_balance,
- &denom_loss,
- &rbalance,
- &loss,
- 42));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: update_denomination_balance\n");
-
- ppc.last_withdraw_serial_id++;
- ppc.last_deposit_serial_id++;
- ppc.last_melt_serial_id++;
- ppc.last_refund_serial_id++;
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_denomination_balance (plugin->cls,
- &denom_pub_hash,
- &denom_balance,
- &denom_loss,
- &rbalance,
- &loss,
- 62));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: get_denomination_balance\n");
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_denomination_balance (plugin->cls,
- &denom_pub_hash,
- &denom_balance2,
- &denom_loss2,
- &rbalance2,
- &loss2,
- &nissued));
-
- FAILIF (0 != GNUNET_memcmp (&denom_balance2, &denom_balance));
- FAILIF (0 != GNUNET_memcmp (&denom_loss2, &denom_loss));
- FAILIF (0 != GNUNET_memcmp (&rbalance2, &rbalance));
- FAILIF (62 != nissued);
-
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_balance_summary\n");
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_balance_summary (plugin->cls,
- &master_pub,
- &refund_fee_balance,
- &melt_fee_balance,
- &deposit_fee_balance,
- &denom_balance,
- &rbalance,
- &loss,
- &iirp));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: update_balance_summary\n");
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_balance_summary (plugin->cls,
- &master_pub,
- &denom_balance,
- &deposit_fee_balance,
- &melt_fee_balance,
- &refund_fee_balance,
- &rbalance,
- &loss,
- &iirp));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: get_balance_summary\n");
-
- ZR_BLK (&denom_balance2);
- ZR_BLK (&deposit_fee_balance2);
- ZR_BLK (&melt_fee_balance2);
- ZR_BLK (&refund_fee_balance2);
- ZR_BLK (&rbalance2);
- ZR_BLK (&loss2);
- ZR_BLK (&iirp2);
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_balance_summary (plugin->cls,
- &master_pub,
- &denom_balance2,
- &deposit_fee_balance2,
- &melt_fee_balance2,
- &refund_fee_balance2,
- &rbalance2,
- &loss2,
- &iirp2));
-
- FAILIF ( (0 != GNUNET_memcmp (&denom_balance2,
- &denom_balance) ) ||
- (0 != GNUNET_memcmp (&deposit_fee_balance2,
- &deposit_fee_balance) ) ||
- (0 != GNUNET_memcmp (&melt_fee_balance2,
- &melt_fee_balance) ) ||
- (0 != GNUNET_memcmp (&refund_fee_balance2,
- &refund_fee_balance)) );
- FAILIF (0 != GNUNET_memcmp (&rbalance2,
- &rbalance));
- FAILIF (0 != GNUNET_memcmp (&loss2,
- &loss));
- FAILIF (0 != GNUNET_memcmp (&iirp2,
- &iirp));
-
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_historic_denom_revenue\n");
-
+ TALER_string_to_amount (CURRENCY ":23.456789",
+ &rloss));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_historic_denom_revenue (plugin->cls,
&master_pub,
&denom_pub_hash,
past,
&rbalance,
- &loss));
-
+ &rloss));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_historic_denom_revenue (plugin->cls,
&master_pub,
&rnd_hash,
now,
&rbalance,
- &loss));
-
+ &rloss));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: select_historic_denom_revenue\n");
-
- int
- select_historic_denom_revenue_result (
- void *cls,
- const struct TALER_DenominationHashP *denom_pub_hash2,
- struct GNUNET_TIME_Timestamp revenue_timestamp2,
- const struct TALER_Amount *revenue_balance2,
- const struct TALER_Amount *loss2)
- {
- static int n = 0;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "select_historic_denom_revenue_result: row %u\n", n);
-
- if ((2 <= n++)
- || (cls != NULL)
- || ((0 != GNUNET_memcmp (&revenue_timestamp2, &past))
- && (0 != GNUNET_memcmp (&revenue_timestamp2, &now)))
- || ((0 != GNUNET_memcmp (denom_pub_hash2, &denom_pub_hash))
- && (0 != GNUNET_memcmp (denom_pub_hash2, &rnd_hash)))
- || (0 != GNUNET_memcmp (revenue_balance2, &rbalance))
- || (0 != GNUNET_memcmp (loss2, &loss)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "select_historic_denom_revenue_result: result does not match\n");
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
- }
-
-
FAILIF (0 >=
- plugin->select_historic_denom_revenue (plugin->cls,
- &master_pub,
- &
- select_historic_denom_revenue_result,
- NULL));
-
+ plugin->select_historic_denom_revenue (
+ plugin->cls,
+ &master_pub,
+ &select_historic_denom_revenue_result,
+ NULL));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: insert_historic_reserve_revenue\n");
-
- struct TALER_Amount reserve_profits;
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":56.789012",
&reserve_profits));
-
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_historic_reserve_revenue (plugin->cls,
&master_pub,
past,
future,
&reserve_profits));
-
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_historic_reserve_revenue (plugin->cls,
&master_pub,
now,
future,
&reserve_profits));
-
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: select_historic_reserve_revenue\n");
-
- int
- select_historic_reserve_revenue_result (
- void *cls,
- struct GNUNET_TIME_Timestamp start_time2,
- struct GNUNET_TIME_Timestamp end_time2,
- const struct TALER_Amount *reserve_profits2)
- {
- static int n = 0;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "select_historic_reserve_revenue_result: row %u\n", n);
-
- if ((2 <= n++)
- || (cls != NULL)
- || ((0 != GNUNET_memcmp (&start_time2, &past))
- && (0 != GNUNET_memcmp (&start_time2, &now)))
- || (0 != GNUNET_memcmp (&end_time2, &future))
- || (0 != GNUNET_memcmp (reserve_profits2, &reserve_profits)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "select_historic_reserve_revenue_result: result does not match\n");
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
- }
-
-
FAILIF (0 >=
plugin->select_historic_reserve_revenue (plugin->cls,
&master_pub,
select_historic_reserve_revenue_result,
NULL));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: insert_predicted_result\n");
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_predicted_result (plugin->cls,
- &master_pub,
- &rbalance,
- &dbalance));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: update_predicted_result\n");
-
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":78.901234",
- &rbalance));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":73.901234",
- &dbalance));
+ {
+ struct TALER_Amount dbalance;
+ struct TALER_Amount dbalance2;
+ struct TALER_Amount rbalance2;
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_predicted_result (plugin->cls,
- &master_pub,
- &rbalance,
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":2.535678",
&dbalance));
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_wire_fee_summary (plugin->cls,
- &master_pub,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: insert_predicted_result\n");
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->insert_predicted_result (plugin->cls,
+ &master_pub,
+ &rbalance,
+ &dbalance));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: update_predicted_result\n");
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":78.901234",
&rbalance));
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->update_wire_fee_summary (plugin->cls,
- &master_pub,
- &reserve_profits));
- {
- struct TALER_Amount rprof;
-
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":73.901234",
+ &dbalance));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_wire_fee_summary (plugin->cls,
- &master_pub,
- &rprof));
- FAILIF (0 !=
- TALER_amount_cmp (&rprof,
- &reserve_profits));
- }
- FAILIF (0 >
- plugin->commit (plugin->cls));
+ plugin->update_predicted_result (plugin->cls,
+ &master_pub,
+ &rbalance,
+ &dbalance));
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->insert_wire_fee_summary (plugin->cls,
+ &master_pub,
+ &rbalance));
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->update_wire_fee_summary (plugin->cls,
+ &master_pub,
+ &reserve_profits));
+ {
+ struct TALER_Amount rprof;
+
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->get_wire_fee_summary (plugin->cls,
+ &master_pub,
+ &rprof));
+ FAILIF (0 !=
+ TALER_amount_cmp (&rprof,
+ &reserve_profits));
+ }
+ FAILIF (0 >
+ plugin->commit (plugin->cls));
- FAILIF (GNUNET_OK !=
- plugin->start (plugin->cls));
+ FAILIF (GNUNET_OK !=
+ plugin->start (plugin->cls));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Test: get_predicted_balance\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Test: get_predicted_balance\n");
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_predicted_balance (plugin->cls,
- &master_pub,
- &rbalance2,
- &dbalance2));
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->get_predicted_balance (plugin->cls,
+ &master_pub,
+ &rbalance2,
+ &dbalance2));
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->del_reserve_info (plugin->cls,
- &reserve_pub,
- &master_pub));
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->del_reserve_info (plugin->cls,
+ &reserve_pub,
+ &master_pub));
- FAILIF (0 != TALER_amount_cmp (&rbalance2,
- &rbalance));
- FAILIF (0 != TALER_amount_cmp (&dbalance2,
- &dbalance));
+ FAILIF (0 != TALER_amount_cmp (&rbalance2,
+ &rbalance));
+ FAILIF (0 != TALER_amount_cmp (&dbalance2,
+ &dbalance));
- plugin->rollback (plugin->cls);
+ plugin->rollback (plugin->cls);
+ }
#if GC_IMPLEMENTED
FAILIF (GNUNET_OK !=