From 7b62deabac967c2ba94502211ffd553eda572622 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 27 Oct 2018 21:27:23 +0200 Subject: split up progress points of auditor by coin/reserve/aggregation to minimize DB conflicts --- src/auditor/taler-auditor.c | 292 +++++++++++++--------- src/auditordb/plugin_auditordb_postgres.c | 403 +++++++++++++++++++++++------- src/auditordb/test_auditordb.c | 64 +++-- src/include/taler_auditordb_plugin.h | 162 ++++++++++-- 4 files changed, 657 insertions(+), 264 deletions(-) diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index 83f87ae0a..12ababc55 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -109,9 +109,19 @@ static struct GNUNET_TIME_Relative idle_reserve_expiration_time; static struct TALER_MasterPublicKeyP master_pub; /** - * Last reserve_in serial ID seen. + * Checkpointing our progress for reserves. */ -static struct TALER_AUDITORDB_ProgressPoint pp; +static struct TALER_AUDITORDB_ProgressPointReserve ppr; + +/** + * Checkpointing our progress for aggregations. + */ +static struct TALER_AUDITORDB_ProgressPointAggregation ppa; + +/** + * Checkpointing our progress for coins. + */ +static struct TALER_AUDITORDB_ProgressPointCoin ppc; /** * Array of reports about denomination keys with an @@ -773,8 +783,8 @@ handle_reserve_in (void *cls, enum GNUNET_DB_QueryStatus qs; /* should be monotonically increasing */ - GNUNET_assert (rowid >= pp.last_reserve_in_serial_id); - pp.last_reserve_in_serial_id = rowid + 1; + GNUNET_assert (rowid >= ppr.last_reserve_in_serial_id); + ppr.last_reserve_in_serial_id = rowid + 1; GNUNET_CRYPTO_hash (reserve_pub, sizeof (*reserve_pub), @@ -861,8 +871,8 @@ handle_reserve_out (void *cls, enum GNUNET_DB_QueryStatus qs; /* should be monotonically increasing */ - GNUNET_assert (rowid >= pp.last_reserve_out_serial_id); - pp.last_reserve_out_serial_id = rowid + 1; + GNUNET_assert (rowid >= ppr.last_reserve_out_serial_id); + ppr.last_reserve_out_serial_id = rowid + 1; /* lookup denomination pub data (make sure denom_pub is valid, establish fees) */ qs = get_denomination_info (denom_pub, @@ -1011,8 +1021,8 @@ handle_payback_by_reserve (void *cls, const char *rev; /* should be monotonically increasing */ - GNUNET_assert (rowid >= pp.last_reserve_payback_serial_id); - pp.last_reserve_payback_serial_id = rowid + 1; + GNUNET_assert (rowid >= ppr.last_reserve_payback_serial_id); + ppr.last_reserve_payback_serial_id = rowid + 1; GNUNET_CRYPTO_rsa_public_key_hash (coin->denom_pub.rsa_public_key, &pr.h_denom_pub); @@ -1202,8 +1212,8 @@ handle_reserve_closed (void *cls, enum GNUNET_DB_QueryStatus qs; /* should be monotonically increasing */ - GNUNET_assert (rowid >= pp.last_reserve_close_serial_id); - pp.last_reserve_close_serial_id = rowid + 1; + GNUNET_assert (rowid >= ppr.last_reserve_close_serial_id); + ppr.last_reserve_close_serial_id = rowid + 1; GNUNET_CRYPTO_hash (reserve_pub, sizeof (*reserve_pub), @@ -1507,9 +1517,33 @@ analyze_reserves (void *cls) struct ReserveContext rc; enum GNUNET_DB_QueryStatus qsx; enum GNUNET_DB_QueryStatus qs; + enum GNUNET_DB_QueryStatus qsp; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Analyzing reserves\n"); + qsp = adb->get_auditor_progress_reserve (adb->cls, + asession, + &master_pub, + &ppr); + if (0 > qsp) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp); + return qsp; + } + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) + { + GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + _("First analysis using this auditor, starting audit from scratch\n")); + } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("Resuming reserve audit at %llu/%llu/%llu/%llu\n"), + (unsigned long long) ppr.last_reserve_in_serial_id, + (unsigned long long) ppr.last_reserve_out_serial_id, + (unsigned long long) ppr.last_reserve_payback_serial_id, + (unsigned long long) ppr.last_reserve_close_serial_id); + } rc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; qsx = adb->get_reserve_summary (adb->cls, asession, @@ -1528,7 +1562,7 @@ analyze_reserves (void *cls) qs = edb->select_reserves_in_above_serial_id (edb->cls, esession, - pp.last_reserve_in_serial_id, + ppr.last_reserve_in_serial_id, &handle_reserve_in, &rc); if (qs < 0) @@ -1538,7 +1572,7 @@ analyze_reserves (void *cls) } qs = edb->select_reserves_out_above_serial_id (edb->cls, esession, - pp.last_reserve_out_serial_id, + ppr.last_reserve_out_serial_id, &handle_reserve_out, &rc); if (qs < 0) @@ -1548,7 +1582,7 @@ analyze_reserves (void *cls) } qs = edb->select_payback_above_serial_id (edb->cls, esession, - pp.last_reserve_payback_serial_id, + ppr.last_reserve_payback_serial_id, &handle_payback_by_reserve, &rc); if (qs < 0) @@ -1558,7 +1592,7 @@ analyze_reserves (void *cls) } qs = edb->select_reserve_closed_above_serial_id (edb->cls, esession, - pp.last_reserve_close_serial_id, + ppr.last_reserve_close_serial_id, &handle_reserve_closed, &rc); if (qs < 0) @@ -1599,6 +1633,29 @@ analyze_reserves (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp) + qs = adb->update_auditor_progress_reserve (adb->cls, + asession, + &master_pub, + &ppr); + else + qs = adb->insert_auditor_progress_reserve (adb->cls, + asession, + &master_pub, + &ppr); + if (0 >= qs) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Failed to update auditor DB, not recording progress\n"); + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + return qs; + } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("Concluded reserve audit step at %llu/%llu/%llu/%llu\n"), + (unsigned long long) ppr.last_reserve_in_serial_id, + (unsigned long long) ppr.last_reserve_out_serial_id, + (unsigned long long) ppr.last_reserve_payback_serial_id, + (unsigned long long) ppr.last_reserve_close_serial_id); return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } @@ -2388,8 +2445,8 @@ check_wire_out_cb (void *cls, char *method; /* should be monotonically increasing */ - GNUNET_assert (rowid >= pp.last_wire_out_serial_id); - pp.last_wire_out_serial_id = rowid + 1; + GNUNET_assert (rowid >= ppa.last_wire_out_serial_id); + ppa.last_wire_out_serial_id = rowid + 1; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking wire transfer %s over %s performed on %s\n", @@ -2565,9 +2622,31 @@ analyze_aggregations (void *cls) struct WireFeeInfo *wfi; enum GNUNET_DB_QueryStatus qsx; enum GNUNET_DB_QueryStatus qs; + enum GNUNET_DB_QueryStatus qsp; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Analyzing aggregations\n"); + qsp = adb->get_auditor_progress_aggregation (adb->cls, + asession, + &master_pub, + &ppa); + if (0 > qsp) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp); + return qsp; + } + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) + { + GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + _("First analysis using this auditor, starting audit from scratch\n")); + } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("Resuming aggregation audit at %llu\n"), + (unsigned long long) ppa.last_wire_out_serial_id); + } + memset (&ac, 0, sizeof (ac)); @@ -2583,7 +2662,7 @@ analyze_aggregations (void *cls) ac.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; qs = edb->select_wire_out_above_serial_id (edb->cls, esession, - pp.last_wire_out_serial_id, + ppa.last_wire_out_serial_id, &check_wire_out_cb, &ac); if (0 > qs) @@ -2627,6 +2706,27 @@ analyze_aggregations (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == ac.qs); return ac.qs; } + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp) + qs = adb->update_auditor_progress_aggregation (adb->cls, + asession, + &master_pub, + &ppa); + else + qs = adb->insert_auditor_progress_aggregation (adb->cls, + asession, + &master_pub, + &ppa); + if (0 >= qs) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Failed to update auditor DB, not recording progress\n"); + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + return qs; + } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("Concluded aggregation audit step at %llu\n"), + (unsigned long long) ppa.last_wire_out_serial_id); + return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } @@ -2925,8 +3025,8 @@ withdraw_cb (void *cls, struct TALER_Amount value; enum GNUNET_DB_QueryStatus qs; - GNUNET_assert (rowid >= pp.last_withdraw_serial_id); /* should be monotonically increasing */ - pp.last_withdraw_serial_id = rowid + 1; + GNUNET_assert (rowid >= ppc.last_withdraw_serial_id); /* should be monotonically increasing */ + ppc.last_withdraw_serial_id = rowid + 1; qs = get_denomination_info (denom_pub, &dki, @@ -3078,8 +3178,8 @@ refresh_session_cb (void *cls, struct TALER_Amount tmp; enum GNUNET_DB_QueryStatus qs; - GNUNET_assert (rowid >= pp.last_melt_serial_id); /* should be monotonically increasing */ - pp.last_melt_serial_id = rowid + 1; + GNUNET_assert (rowid >= ppc.last_melt_serial_id); /* should be monotonically increasing */ + ppc.last_melt_serial_id = rowid + 1; qs = get_denomination_info (denom_pub, &dki, @@ -3412,8 +3512,8 @@ deposit_cb (void *cls, struct TALER_Amount tmp; enum GNUNET_DB_QueryStatus qs; - GNUNET_assert (rowid >= pp.last_deposit_serial_id); /* should be monotonically increasing */ - pp.last_deposit_serial_id = rowid + 1; + GNUNET_assert (rowid >= ppc.last_deposit_serial_id); /* should be monotonically increasing */ + ppc.last_deposit_serial_id = rowid + 1; qs = get_denomination_info (denom_pub, &dki, @@ -3562,8 +3662,8 @@ refund_cb (void *cls, struct TALER_Amount refund_fee; enum GNUNET_DB_QueryStatus qs; - GNUNET_assert (rowid >= pp.last_refund_serial_id); /* should be monotonically increasing */ - pp.last_refund_serial_id = rowid + 1; + GNUNET_assert (rowid >= ppc.last_refund_serial_id); /* should be monotonically increasing */ + ppc.last_refund_serial_id = rowid + 1; qs = get_denomination_info (denom_pub, &dki, @@ -3702,9 +3802,34 @@ analyze_coins (void *cls) struct CoinContext cc; enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qsx; + enum GNUNET_DB_QueryStatus qsp; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Analyzing coins\n"); + qsp = adb->get_auditor_progress_coin (adb->cls, + asession, + &master_pub, + &ppc); + if (0 > qsp) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp); + return qsp; + } + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) + { + GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + _("First analysis using this auditor, starting audit from scratch\n")); + } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("Resuming coin audit at %llu/%llu/%llu/%llu\n"), + (unsigned long long) ppc.last_deposit_serial_id, + (unsigned long long) ppc.last_melt_serial_id, + (unsigned long long) ppc.last_refund_serial_id, + (unsigned long long) ppc.last_withdraw_serial_id); + } + /* setup 'cc' */ cc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; cc.denom_summaries = GNUNET_CONTAINER_multihashmap_create (256, @@ -3727,7 +3852,7 @@ analyze_coins (void *cls) if (0 > (qs = edb->select_reserves_out_above_serial_id (edb->cls, esession, - pp.last_withdraw_serial_id, + ppc.last_withdraw_serial_id, &withdraw_cb, &cc)) ) { @@ -3739,7 +3864,7 @@ analyze_coins (void *cls) if (0 > (qs = edb->select_refunds_above_serial_id (edb->cls, esession, - pp.last_refund_serial_id, + ppc.last_refund_serial_id, &refund_cb, &cc))) { @@ -3751,7 +3876,7 @@ analyze_coins (void *cls) if (0 > (qs = edb->select_refreshs_above_serial_id (edb->cls, esession, - pp.last_melt_serial_id, + ppc.last_melt_serial_id, &refresh_session_cb, &cc))) { @@ -3763,7 +3888,7 @@ analyze_coins (void *cls) if (0 > (qs = edb->select_deposits_above_serial_id (edb->cls, esession, - pp.last_deposit_serial_id, + ppc.last_deposit_serial_id, &deposit_cb, &cc))) { @@ -3805,6 +3930,30 @@ analyze_coins (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } + + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp) + qs = adb->update_auditor_progress_coin (adb->cls, + asession, + &master_pub, + &ppc); + else + qs = adb->insert_auditor_progress_coin (adb->cls, + asession, + &master_pub, + &ppc); + if (0 >= qs) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Failed to update auditor DB, not recording progress\n"); + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + return qs; + } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("Concluded coin audit step at %llu/%llu/%llu/%llu\n"), + (unsigned long long) ppc.last_deposit_serial_id, + (unsigned long long) ppc.last_melt_serial_id, + (unsigned long long) ppc.last_refund_serial_id, + (unsigned long long) ppc.last_withdraw_serial_id); return qs; } @@ -3822,88 +3971,6 @@ typedef enum GNUNET_DB_QueryStatus (*Analysis)(void *cls); -/** - * Perform the given @a analysis incrementally, checkpointing our - * progress in the auditor DB. - * - * @param analysis analysis to run - * @param analysis_cls closure for @a analysis - * @return transaction status code - */ -static enum GNUNET_DB_QueryStatus -incremental_processing (Analysis analysis, - void *analysis_cls) -{ - enum GNUNET_DB_QueryStatus qs; - enum GNUNET_DB_QueryStatus qsx; - - qsx = adb->get_auditor_progress (adb->cls, - asession, - &master_pub, - &pp); - if (0 > qsx) - { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); - return qsx; - } - if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) - { - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Resuming audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n"), - (unsigned long long) pp.last_reserve_in_serial_id, - (unsigned long long) pp.last_reserve_out_serial_id, - (unsigned long long) pp.last_withdraw_serial_id, - (unsigned long long) pp.last_deposit_serial_id, - (unsigned long long) pp.last_melt_serial_id, - (unsigned long long) pp.last_refund_serial_id, - (unsigned long long) pp.last_wire_out_serial_id); - } - qs = analysis (analysis_cls); - if (0 > qs) - { - if (GNUNET_DB_STATUS_SOFT_ERROR == qs) - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Serialization issue, not recording progress\n"); - else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Hard database error, not recording progress\n"); - return qs; - } - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) - qs = adb->update_auditor_progress (adb->cls, - asession, - &master_pub, - &pp); - else - qs = adb->insert_auditor_progress (adb->cls, - asession, - &master_pub, - &pp); - if (0 >= qs) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Failed to update auditor DB, not recording progress\n"); - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - return qs; - } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Concluded audit step at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n\n"), - (unsigned long long) pp.last_reserve_in_serial_id, - (unsigned long long) pp.last_reserve_out_serial_id, - (unsigned long long) pp.last_withdraw_serial_id, - (unsigned long long) pp.last_deposit_serial_id, - (unsigned long long) pp.last_melt_serial_id, - (unsigned long long) pp.last_refund_serial_id, - (unsigned long long) pp.last_wire_out_serial_id); - return qs; -} - - /** * Perform the given @a analysis within a transaction scope. * Commit on success. @@ -3938,8 +4005,7 @@ transact (Analysis analysis, GNUNET_break (0); return GNUNET_SYSERR; } - qs = incremental_processing (analysis, - analysis_cls); + qs = analysis (analysis_cls); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { qs = edb->commit (edb->cls, diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 22f58fb7a..42d458998 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -147,7 +147,9 @@ postgres_drop_tables (void *cls) GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_reserve_balance;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_wire_fee_balance;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_reserves;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress;"), + GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_reserve;"), + GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_aggregation;"), + GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_coin;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS wire_auditor_progress;"), GNUNET_PQ_EXECUTE_STATEMENT_END }; @@ -206,28 +208,37 @@ postgres_create_tables (void *cls) ",fee_refund_frac INT4 NOT NULL" ",fee_refund_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" ")"), + /* List of exchanges audited by this auditor */ + // TODO: not yet used! + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS exchanges" + "(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)" + ",exchange_url VARCHAR NOT NULL" + ")"), + /* Table indicating up to which transactions the auditor has processed the exchange database. Used for SELECTing the - statements to process. We basically trace the exchange's - operations by the 6 primary tables: reserves_in, - reserves_out, deposits, refresh_sessions, refunds and prewire. The - other tables of the exchange DB just provide supporting - evidence which is checked alongside the audit of these - five tables. The 6 indices below 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). */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress" + statements to process. The indices below 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). */ + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_reserve" "(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)" ",last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0" ",last_reserve_out_serial_id INT8 NOT NULL DEFAULT 0" ",last_reserve_payback_serial_id INT8 NOT NULL DEFAULT 0" ",last_reserve_close_serial_id INT8 NOT NULL DEFAULT 0" + ")"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_aggregation" + "(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)" + ",last_wire_out_serial_id INT8 NOT NULL DEFAULT 0" + ")"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_coin" + "(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)" ",last_withdraw_serial_id INT8 NOT NULL DEFAULT 0" ",last_deposit_serial_id INT8 NOT NULL DEFAULT 0" ",last_melt_serial_id INT8 NOT NULL DEFAULT 0" ",last_refund_serial_id INT8 NOT NULL DEFAULT 0" - ",last_wire_out_serial_id INT8 NOT NULL DEFAULT 0" ")"), GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_auditor_progress" "(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)" @@ -494,7 +505,7 @@ postgres_prepare (PGconn *db_conn) " FROM auditor_denominations" " WHERE master_pub=$1;", 1), - /* Used in #postgres_insert_auditor_progress() */ + /* Used in #postgres_insert_deposit_confirmation() */ GNUNET_PQ_make_prepare ("auditor_deposit_confirmation_insert", "INSERT INTO deposit_confirmations " "(master_pub" @@ -512,50 +523,84 @@ postgres_prepare (PGconn *db_conn) ",master_sig" /* master_sig could be normalized... */ ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13);", 11), - /* Used in #postgres_insert_auditor_progress() */ - GNUNET_PQ_make_prepare ("auditor_progress_insert", - "INSERT INTO auditor_progress " - "(master_pub" - ",last_reserve_in_serial_id" - ",last_reserve_out_serial_id" - ",last_reserve_payback_serial_id" - ",last_reserve_close_serial_id" - ",last_withdraw_serial_id" - ",last_deposit_serial_id" - ",last_melt_serial_id" - ",last_refund_serial_id" - ",last_wire_out_serial_id" - ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);", - 10), - /* Used in #postgres_update_auditor_progress() */ - GNUNET_PQ_make_prepare ("auditor_progress_update", - "UPDATE auditor_progress SET " + /* Used in #postgres_update_auditor_progress_reserve() */ + GNUNET_PQ_make_prepare ("auditor_progress_update_reserve", + "UPDATE auditor_progress_reserve SET " " last_reserve_in_serial_id=$1" ",last_reserve_out_serial_id=$2" ",last_reserve_payback_serial_id=$3" ",last_reserve_close_serial_id=$4" - ",last_withdraw_serial_id=$5" - ",last_deposit_serial_id=$6" - ",last_melt_serial_id=$7" - ",last_refund_serial_id=$8" - ",last_wire_out_serial_id=$9" - " WHERE master_pub=$10", - 10), - /* Used in #postgres_get_auditor_progress() */ - GNUNET_PQ_make_prepare ("auditor_progress_select", + " WHERE master_pub=$5", + 5), + /* Used in #postgres_get_auditor_progress_reserve() */ + GNUNET_PQ_make_prepare ("auditor_progress_select_reserve", "SELECT" " last_reserve_in_serial_id" ",last_reserve_out_serial_id" ",last_reserve_payback_serial_id" ",last_reserve_close_serial_id" - ",last_withdraw_serial_id" + " FROM auditor_progress_reserve" + " WHERE master_pub=$1;", + 1), + /* Used in #postgres_insert_auditor_progress_reserve() */ + GNUNET_PQ_make_prepare ("auditor_progress_insert_reserve", + "INSERT INTO auditor_progress_reserve " + "(master_pub" + ",last_reserve_in_serial_id" + ",last_reserve_out_serial_id" + ",last_reserve_payback_serial_id" + ",last_reserve_close_serial_id" + ") VALUES ($1,$2,$3,$4,$5);", + 5), + /* Used in #postgres_update_auditor_progress_aggregation() */ + GNUNET_PQ_make_prepare ("auditor_progress_update_aggregation", + "UPDATE auditor_progress_aggregation SET " + " last_wire_out_serial_id=$1" + " WHERE master_pub=$2", + 2), + /* Used in #postgres_get_auditor_progress_aggregation() */ + GNUNET_PQ_make_prepare ("auditor_progress_select_aggregation", + "SELECT" + " last_wire_out_serial_id" + " FROM auditor_progress_aggregation" + " WHERE master_pub=$1;", + 1), + /* Used in #postgres_insert_auditor_progress_aggregation() */ + GNUNET_PQ_make_prepare ("auditor_progress_insert_aggregation", + "INSERT INTO auditor_progress_aggregation " + "(master_pub" + ",last_wire_out_serial_id" + ") VALUES ($1,$2);", + 2), + /* Used in #postgres_update_auditor_progress_coin() */ + GNUNET_PQ_make_prepare ("auditor_progress_update_coin", + "UPDATE auditor_progress_coin SET " + " last_withdraw_serial_id=$1" + ",last_deposit_serial_id=$2" + ",last_melt_serial_id=$3" + ",last_refund_serial_id=$4" + " WHERE master_pub=$5", + 4), + /* Used in #postgres_get_auditor_progress_coin() */ + GNUNET_PQ_make_prepare ("auditor_progress_select_coin", + "SELECT" + " last_withdraw_serial_id" ",last_deposit_serial_id" ",last_melt_serial_id" ",last_refund_serial_id" - ",last_wire_out_serial_id" - " FROM auditor_progress" + " FROM auditor_progress_coin" " WHERE master_pub=$1;", 1), + /* Used in #postgres_insert_auditor_progress() */ + GNUNET_PQ_make_prepare ("auditor_progress_insert_coin", + "INSERT INTO auditor_progress_coin " + "(master_pub" + ",last_withdraw_serial_id" + ",last_deposit_serial_id" + ",last_melt_serial_id" + ",last_refund_serial_id" + ") VALUES ($1,$2,$3,$4,$5);", + 5), /* Used in #postgres_insert_wire_auditor_progress() */ GNUNET_PQ_make_prepare ("wire_auditor_progress_insert", "INSERT INTO wire_auditor_progress " @@ -1296,31 +1341,26 @@ postgres_select_denomination_info (void *cls, * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param master_pub master key of the exchange - * @param pp where is the auditor in processing + * @param ppr where is the auditor in processing * @return transaction status code */ static enum GNUNET_DB_QueryStatus -postgres_insert_auditor_progress (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPoint *pp) +postgres_insert_auditor_progress_reserve (void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointReserve *ppr) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), - GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_reserve_out_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_reserve_payback_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_reserve_close_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_withdraw_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_deposit_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_melt_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_refund_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id), + 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_payback_serial_id), + GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_close_serial_id), GNUNET_PQ_query_param_end }; return GNUNET_PQ_eval_prepared_non_select (session->conn, - "auditor_progress_insert", + "auditor_progress_insert_reserve", params); } @@ -1332,31 +1372,26 @@ postgres_insert_auditor_progress (void *cls, * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param master_pub master key of the exchange - * @param pp where is the auditor in processing + * @param ppr where is the auditor in processing * @return transaction status code */ static enum GNUNET_DB_QueryStatus -postgres_update_auditor_progress (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPoint *pp) +postgres_update_auditor_progress_reserve (void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointReserve *ppr) { struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_reserve_out_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_reserve_payback_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_reserve_close_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_withdraw_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_deposit_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_melt_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_refund_serial_id), - GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id), + 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_payback_serial_id), + GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_close_serial_id), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; return GNUNET_PQ_eval_prepared_non_select (session->conn, - "auditor_progress_update", + "auditor_progress_update_reserve", params); } @@ -1367,14 +1402,14 @@ postgres_update_auditor_progress (void *cls, * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param master_pub master key of the exchange - * @param[out] pp set to where the auditor is in processing + * @param[out] ppr set to where the auditor is in processing * @return transaction status code */ static enum GNUNET_DB_QueryStatus -postgres_get_auditor_progress (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPoint *pp) +postgres_get_auditor_progress_reserve (void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointReserve *ppr) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1382,28 +1417,206 @@ postgres_get_auditor_progress (void *cls, }; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("last_reserve_in_serial_id", - &pp->last_reserve_in_serial_id), + &ppr->last_reserve_in_serial_id), GNUNET_PQ_result_spec_uint64 ("last_reserve_out_serial_id", - &pp->last_reserve_out_serial_id), + &ppr->last_reserve_out_serial_id), GNUNET_PQ_result_spec_uint64 ("last_reserve_payback_serial_id", - &pp->last_reserve_payback_serial_id), + &ppr->last_reserve_payback_serial_id), GNUNET_PQ_result_spec_uint64 ("last_reserve_close_serial_id", - &pp->last_reserve_close_serial_id), + &ppr->last_reserve_close_serial_id), + GNUNET_PQ_result_spec_end + }; + + return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + "auditor_progress_select_reserve", + 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 session connection to use + * @param master_pub master key of the exchange + * @param ppa where is the auditor in processing + * @return transaction status code + */ +static enum GNUNET_DB_QueryStatus +postgres_insert_auditor_progress_aggregation (void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointAggregation *ppa) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (master_pub), + GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (session->conn, + "auditor_progress_insert_aggregation", + 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 session connection to use + * @param master_pub master key of the exchange + * @param ppa where is the auditor in processing + * @return transaction status code + */ +static enum GNUNET_DB_QueryStatus +postgres_update_auditor_progress_aggregation (void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointAggregation *ppa) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id), + GNUNET_PQ_query_param_auto_from_type (master_pub), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (session->conn, + "auditor_progress_update_aggregation", + params); +} + + +/** + * Get information about the progress of the auditor. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param session connection to use + * @param master_pub master key of the exchange + * @param[out] ppa set to where the auditor is in processing + * @return transaction status code + */ +static enum GNUNET_DB_QueryStatus +postgres_get_auditor_progress_aggregation (void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointAggregation *ppa) +{ + 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_wire_out_serial_id", + &ppa->last_wire_out_serial_id), + GNUNET_PQ_result_spec_end + }; + + return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + "auditor_progress_select_aggregation", + 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 session connection to use + * @param master_pub master key of the exchange + * @param ppc where is the auditor in processing + * @return transaction status code + */ +static enum GNUNET_DB_QueryStatus +postgres_insert_auditor_progress_coin (void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointCoin *ppc) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (master_pub), + GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id), + GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id), + GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id), + GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (session->conn, + "auditor_progress_insert_coin", + 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 session connection to use + * @param master_pub master key of the exchange + * @param ppc where is the auditor in processing + * @return transaction status code + */ +static enum GNUNET_DB_QueryStatus +postgres_update_auditor_progress_coin (void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointCoin *ppc) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id), + GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id), + GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id), + GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id), + GNUNET_PQ_query_param_auto_from_type (master_pub), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (session->conn, + "auditor_progress_update_coin", + params); +} + + +/** + * Get information about the progress of the auditor. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param session connection to use + * @param master_pub master key of the exchange + * @param[out] ppc set to where the auditor is in processing + * @return transaction status code + */ +static enum GNUNET_DB_QueryStatus +postgres_get_auditor_progress_coin (void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointCoin *ppc) +{ + 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_withdraw_serial_id", - &pp->last_withdraw_serial_id), + &ppc->last_withdraw_serial_id), GNUNET_PQ_result_spec_uint64 ("last_deposit_serial_id", - &pp->last_deposit_serial_id), + &ppc->last_deposit_serial_id), GNUNET_PQ_result_spec_uint64 ("last_melt_serial_id", - &pp->last_melt_serial_id), + &ppc->last_melt_serial_id), GNUNET_PQ_result_spec_uint64 ("last_refund_serial_id", - &pp->last_refund_serial_id), - GNUNET_PQ_result_spec_uint64 ("last_wire_out_serial_id", - &pp->last_wire_out_serial_id), + &ppc->last_refund_serial_id), GNUNET_PQ_result_spec_end }; return GNUNET_PQ_eval_prepared_singleton_select (session->conn, - "auditor_progress_select", + "auditor_progress_select_coin", params, rs); } @@ -2702,9 +2915,15 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->select_denomination_info = &postgres_select_denomination_info; plugin->insert_denomination_info = &postgres_insert_denomination_info; - plugin->get_auditor_progress = &postgres_get_auditor_progress; - plugin->update_auditor_progress = &postgres_update_auditor_progress; - plugin->insert_auditor_progress = &postgres_insert_auditor_progress; + 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_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_progress = &postgres_get_wire_auditor_progress; plugin->update_wire_auditor_progress = &postgres_update_wire_auditor_progress; diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c index a5e8ba71d..1b8a4223d 100644 --- a/src/auditordb/test_auditordb.c +++ b/src/auditordb/test_auditordb.c @@ -215,58 +215,50 @@ run (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: insert_auditor_progress\n"); - struct TALER_AUDITORDB_ProgressPoint pp = { - .last_reserve_in_serial_id = 1234, - .last_reserve_out_serial_id = 5678, + struct TALER_AUDITORDB_ProgressPointCoin ppc = { .last_deposit_serial_id = 123, .last_melt_serial_id = 456, .last_refund_serial_id = 789, - .last_wire_out_serial_id = 555 + .last_withdraw_serial_id = 555 }; - struct TALER_AUDITORDB_ProgressPoint pp2 = { - .last_reserve_in_serial_id = 0, - .last_reserve_out_serial_id = 0, + struct TALER_AUDITORDB_ProgressPointCoin ppc2 = { .last_deposit_serial_id = 0, .last_melt_serial_id = 0, .last_refund_serial_id = 0, - .last_wire_out_serial_id = 0 + .last_withdraw_serial_id = 0 }; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_auditor_progress (plugin->cls, - session, - &master_pub, - &pp)); + plugin->insert_auditor_progress_coin (plugin->cls, + session, + &master_pub, + &ppc)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: update_auditor_progress\n"); - pp.last_reserve_in_serial_id++; - pp.last_reserve_out_serial_id++; - pp.last_deposit_serial_id++; - pp.last_melt_serial_id++; - pp.last_refund_serial_id++; - pp.last_wire_out_serial_id++; + ppc.last_deposit_serial_id++; + ppc.last_melt_serial_id++; + ppc.last_refund_serial_id++; + ppc.last_withdraw_serial_id++; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->update_auditor_progress (plugin->cls, - session, - &master_pub, - &pp)); + plugin->update_auditor_progress_coin (plugin->cls, + session, + &master_pub, + &ppc)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: get_auditor_progress\n"); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_auditor_progress (plugin->cls, - session, - &master_pub, - &pp2)); - FAILIF ( (pp.last_reserve_in_serial_id != pp2.last_reserve_in_serial_id) || - (pp.last_reserve_out_serial_id != pp2.last_reserve_out_serial_id) || - (pp.last_deposit_serial_id != pp2.last_deposit_serial_id) || - (pp.last_melt_serial_id != pp2.last_melt_serial_id) || - (pp.last_refund_serial_id != pp2.last_refund_serial_id) || - (pp.last_wire_out_serial_id != pp2.last_wire_out_serial_id) ); + plugin->get_auditor_progress_coin (plugin->cls, + session, + &master_pub, + &ppc2)); + FAILIF ( (ppc.last_deposit_serial_id != ppc2.last_deposit_serial_id) || + (ppc.last_melt_serial_id != ppc2.last_melt_serial_id) || + (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"); @@ -399,10 +391,10 @@ run (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: update_denomination_balance\n"); - pp.last_reserve_out_serial_id++; - pp.last_deposit_serial_id++; - pp.last_melt_serial_id++; - pp.last_refund_serial_id++; + 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, diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index fb3930521..ae8cafc03 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -131,10 +131,10 @@ struct TALER_AUDITORDB_WireProgressPoint /** - * Structure for remembering the auditor's progress over the - * various tables and (auditor) transactions. + * Structure for remembering the auditor's progress over the various + * tables and (auditor) transactions when analyzing reserves. */ -struct TALER_AUDITORDB_ProgressPoint +struct TALER_AUDITORDB_ProgressPointReserve { /** * last_reserve_in_serial_id serial ID of the last reserve_in transfer the auditor processed @@ -158,6 +158,29 @@ struct TALER_AUDITORDB_ProgressPoint */ uint64_t last_reserve_close_serial_id; +}; + + +/** + * Structure for remembering the auditor's progress over the various + * tables and (auditor) transactions when analyzing aggregations. + */ +struct TALER_AUDITORDB_ProgressPointAggregation +{ + + /** + * last_prewire_serial_id serial ID of the last prewire transfer the auditor processed + */ + uint64_t last_wire_out_serial_id; +}; + + +/** + * Structure for remembering the auditor's progress over the various + * tables and (auditor) transactions when analyzing coins. + */ +struct TALER_AUDITORDB_ProgressPointCoin +{ /** * last_reserve_out_serial_id serial ID of the last withdraw the auditor processed */ @@ -178,11 +201,6 @@ struct TALER_AUDITORDB_ProgressPoint */ uint64_t last_refund_serial_id; - /** - * last_prewire_serial_id serial ID of the last prewire transfer the auditor processed - */ - uint64_t last_wire_out_serial_id; - }; @@ -473,14 +491,14 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param master_pub master key of the exchange - * @param pp where is the auditor in processing + * @param ppc where is the auditor in processing * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_auditor_progress)(void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPoint *pp); + (*insert_auditor_progress_coin)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointCoin *ppc); /** @@ -490,14 +508,14 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param master_pub master key of the exchange - * @param pp where is the auditor in processing + * @param ppc where is the auditor in processing * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*update_auditor_progress)(void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPoint *pp); + (*update_auditor_progress_coin)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointCoin *ppc); /** @@ -506,14 +524,112 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param master_pub master key of the exchange - * @param[out] pp set to where the auditor is in processing + * @param[out] ppc set to where the auditor is in processing * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_auditor_progress)(void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPoint *pp); + (*get_auditor_progress_coin)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointCoin *ppc); + + /** + * 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 session connection to use + * @param master_pub master key of the exchange + * @param ppr where is the auditor in processing + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*insert_auditor_progress_reserve)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointReserve *ppr); + + + /** + * 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 session connection to use + * @param master_pub master key of the exchange + * @param ppr where is the auditor in processing + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*update_auditor_progress_reserve)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointReserve *ppr); + + + /** + * Get information about the progress of the auditor. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param session connection to use + * @param master_pub master key of the exchange + * @param[out] ppr set to where the auditor is in processing + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*get_auditor_progress_reserve)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointReserve *ppr); + + /** + * 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 session connection to use + * @param master_pub master key of the exchange + * @param ppa where is the auditor in processing + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*insert_auditor_progress_aggregation)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointAggregation *ppa); + + + /** + * 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 session connection to use + * @param master_pub master key of the exchange + * @param ppa where is the auditor in processing + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*update_auditor_progress_aggregation)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointAggregation *ppa); + + + /** + * Get information about the progress of the auditor. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param session connection to use + * @param master_pub master key of the exchange + * @param[out] ppa set to where the auditor is in processing + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*get_auditor_progress_aggregation)(void *cls, + struct TALER_AUDITORDB_Session *session, + const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointAggregation *pp); /** -- cgit v1.2.3