From b74612fc3362e64dcfb7eacad3602025ccfcf5ea Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 17 Dec 2020 13:04:37 +0100 Subject: update auditordb and test logic to work with new key separation logic (#6175) --- src/auditordb/plugin_auditordb_postgres.c | 231 ------------------------------ 1 file changed, 231 deletions(-) (limited to 'src/auditordb/plugin_auditordb_postgres.c') diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index a475c46e1..151c93ad3 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -221,48 +221,6 @@ postgres_get_session (void *cls) ",master_sig" ") VALUES ($1,$2,$3,$4,$5,$6);", 6), - /* Used in #postgres_insert_denomination_info() */ - GNUNET_PQ_make_prepare ("auditor_denominations_insert", - "INSERT INTO auditor_denominations " - "(denom_pub_hash" - ",master_pub" - ",valid_from" - ",expire_withdraw" - ",expire_deposit" - ",expire_legal" - ",coin_val" - ",coin_frac" - ",fee_withdraw_val" - ",fee_withdraw_frac" - ",fee_deposit_val" - ",fee_deposit_frac" - ",fee_refresh_val" - ",fee_refresh_frac" - ",fee_refund_val" - ",fee_refund_frac" - ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16);", - 16), - /* Used in #postgres_insert_denomination_info() */ - GNUNET_PQ_make_prepare ("auditor_denominations_select", - "SELECT" - " denom_pub_hash" - ",valid_from" - ",expire_withdraw" - ",expire_deposit" - ",expire_legal" - ",coin_val" - ",coin_frac" - ",fee_withdraw_val" - ",fee_withdraw_frac" - ",fee_deposit_val" - ",fee_deposit_frac" - ",fee_refresh_val" - ",fee_refresh_frac" - ",fee_refund_val" - ",fee_refund_frac" - " FROM auditor_denominations" - " WHERE master_pub=$1;", - 1), /* Used in #postgres_insert_deposit_confirmation() */ GNUNET_PQ_make_prepare ("auditor_deposit_confirmation_insert", "INSERT INTO deposit_confirmations " @@ -1291,192 +1249,6 @@ postgres_get_deposit_confirmations ( } -/** - * Insert information about a denomination key and in particular - * the properties (value, fees, expiration times) the coins signed - * with this key have. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use - * @param issue issuing information with value, fees and other info about the denomination - * @return operation status result - */ -static enum GNUNET_DB_QueryStatus -postgres_insert_denomination_info ( - void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_DenominationKeyValidityPS *issue) -{ - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (&issue->denom_hash), - GNUNET_PQ_query_param_auto_from_type (&issue->master), - TALER_PQ_query_param_absolute_time_nbo (&issue->start), - TALER_PQ_query_param_absolute_time_nbo (&issue->expire_withdraw), - TALER_PQ_query_param_absolute_time_nbo (&issue->expire_deposit), - TALER_PQ_query_param_absolute_time_nbo (&issue->expire_legal), - TALER_PQ_query_param_amount_nbo (&issue->value), - TALER_PQ_query_param_amount_nbo (&issue->fee_withdraw), - TALER_PQ_query_param_amount_nbo (&issue->fee_deposit), - TALER_PQ_query_param_amount_nbo (&issue->fee_refresh), - TALER_PQ_query_param_amount_nbo (&issue->fee_refund), - GNUNET_PQ_query_param_end - }; - - (void) cls; - /* check fees match coin currency */ - GNUNET_assert (GNUNET_YES == - TALER_amount_cmp_currency_nbo (&issue->value, - &issue->fee_withdraw)); - GNUNET_assert (GNUNET_YES == - TALER_amount_cmp_currency_nbo (&issue->value, - &issue->fee_deposit)); - GNUNET_assert (GNUNET_YES == - TALER_amount_cmp_currency_nbo (&issue->value, - &issue->fee_refresh)); - GNUNET_assert (GNUNET_YES == - TALER_amount_cmp_currency_nbo (&issue->value, - &issue->fee_refund)); - return GNUNET_PQ_eval_prepared_non_select (session->conn, - "auditor_denominations_insert", - params); -} - - -/** - * Closure for #denomination_info_cb(). - */ -struct DenominationInfoContext -{ - - /** - * Master public key that is being used. - */ - const struct TALER_MasterPublicKeyP *master_pub; - - /** - * Function to call for each denomination. - */ - TALER_AUDITORDB_DenominationInfoDataCallback cb; - - /** - * Closure for @e cb - */ - void *cb_cls; - - /** - * Plugin context. - */ - struct PostgresClosure *pg; - - /** - * Query status to return. - */ - enum GNUNET_DB_QueryStatus qs; -}; - - -/** - * Helper function for #postgres_select_denomination_info(). - * To be called with the results of a SELECT statement - * that has returned @a num_results results. - * - * @param cls closure of type `struct DenominationInfoContext *` - * @param result the postgres result - * @param num_results the number of results in @a result - */ -static void -denomination_info_cb (void *cls, - PGresult *result, - unsigned int num_results) -{ - struct DenominationInfoContext *dic = cls; - struct PostgresClosure *pg = dic->pg; - - for (unsigned int i = 0; i < num_results; i++) - { - struct TALER_DenominationKeyValidityPS issue = { - .master = *dic->master_pub - }; - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", - &issue.denom_hash), - TALER_PQ_result_spec_absolute_time_nbo ("valid_from", &issue.start), - TALER_PQ_result_spec_absolute_time_nbo ("expire_withdraw", - &issue.expire_withdraw), - TALER_PQ_result_spec_absolute_time_nbo ("expire_deposit", - &issue.expire_deposit), - TALER_PQ_result_spec_absolute_time_nbo ("expire_legal", - &issue.expire_legal), - TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("coin", &issue.value), - TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_withdraw", &issue.fee_withdraw), - TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_deposit", &issue.fee_deposit), - TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_refresh", &issue.fee_refresh), - TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_refund", &issue.fee_refund), - GNUNET_PQ_result_spec_end - }; - - if (GNUNET_OK != - GNUNET_PQ_extract_result (result, - rs, - i)) - { - GNUNET_break (0); - dic->qs = GNUNET_DB_STATUS_HARD_ERROR; - return; - } - dic->qs = i + 1; - if (GNUNET_OK != - dic->cb (dic->cb_cls, - &issue)) - return; - } -} - - -/** - * Get information about denomination keys of a particular exchange. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use - * @param master_pub master public key of the exchange - * @param cb function to call with the results - * @param cb_cls closure for @a cb - * @return transaction status code - */ -static enum GNUNET_DB_QueryStatus -postgres_select_denomination_info ( - void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_DenominationInfoDataCallback cb, - void *cb_cls) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (master_pub), - GNUNET_PQ_query_param_end - }; - struct DenominationInfoContext dic = { - .master_pub = master_pub, - .cb = cb, - .cb_cls = cb_cls, - .pg = pg - }; - enum GNUNET_DB_QueryStatus qs; - - (void) cls; - qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, - "auditor_denominations_select", - params, - &denomination_info_cb, - &dic); - if (qs > 0) - return dic.qs; - GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); - return qs; -} - - /** * Insert information about the auditor's progress with an exchange's * data. @@ -3221,9 +2993,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->insert_deposit_confirmation = &postgres_insert_deposit_confirmation; plugin->get_deposit_confirmations = &postgres_get_deposit_confirmations; - plugin->select_denomination_info = &postgres_select_denomination_info; - plugin->insert_denomination_info = &postgres_insert_denomination_info; - plugin->get_auditor_progress_reserve = &postgres_get_auditor_progress_reserve; plugin->update_auditor_progress_reserve = &postgres_update_auditor_progress_reserve; -- cgit v1.2.3