From c93f64710674bb4f635288c5e326f2cf47b8e8c7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 8 Jul 2020 18:20:44 +0200 Subject: merge known_coin transaction into main transaction (for #6416) --- src/exchange/taler-exchange-httpd_deposit.c | 34 ++++++++++++----------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'src/exchange/taler-exchange-httpd_deposit.c') diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index c2610b4b9..30f754b6d 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -217,6 +217,20 @@ deposit_transaction (void *cls, struct TALER_Amount spent; enum GNUNET_DB_QueryStatus qs; + /* make sure coin is 'known' in database */ + qs = TEH_plugin->ensure_coin_known (TEH_plugin->cls, + session, + &deposit->coin); + if (GNUNET_DB_STATUS_HARD_ERROR == qs) + { + *mhd_ret + = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_COIN_HISTORY_STORE_ERROR, + "could not persist coin data"); + return GNUNET_DB_STATUS_HARD_ERROR; + } + /* Theoretically, someone other threat may have received and committed the deposit in the meantime. Check now that we are in the transaction scope. */ @@ -493,26 +507,6 @@ TEH_handler_deposit (struct MHD_Connection *connection, "deposited amount smaller than depositing fee"); } - /* make sure coin is 'known' in database */ - { - MHD_RESULT mhd_ret; - struct TEH_DB_KnowCoinContext kcc = { - .coin = &deposit.coin, - .connection = connection - }; - - if (GNUNET_OK != - TEH_DB_run_transaction (connection, - "know coin for deposit", - &mhd_ret, - &TEH_DB_know_coin_transaction, - &kcc)) - { - GNUNET_JSON_parse_free (spec); - return mhd_ret; - } - } - /* check deposit signature */ { struct TALER_DepositRequestPS dr = { -- cgit v1.2.3