[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: move ensure_coin_known for melt
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: move ensure_coin_known for melt and recoup outside of transaction, more logging |
Date: |
Wed, 08 Dec 2021 15:18:44 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 9d3f7d3a move ensure_coin_known for melt and recoup outside of
transaction, more logging
9d3f7d3a is described below
commit 9d3f7d3a56712d6a963e8a4775a8f9757740d648
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Dec 8 15:18:40 2021 +0100
move ensure_coin_known for melt and recoup outside of transaction, more
logging
---
src/exchange/taler-exchange-httpd_deposit.c | 32 ++++++++++++++++++++++-------
src/exchange/taler-exchange-httpd_melt.c | 10 +++++++++
src/exchange/taler-exchange-httpd_recoup.c | 22 +++++++++++++-------
src/exchangedb/plugin_exchangedb_postgres.c | 6 +++++-
4 files changed, 55 insertions(+), 15 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_deposit.c
b/src/exchange/taler-exchange-httpd_deposit.c
index 5534c402..d549a1fa 100644
--- a/src/exchange/taler-exchange-httpd_deposit.c
+++ b/src/exchange/taler-exchange-httpd_deposit.c
@@ -162,13 +162,6 @@ deposit_transaction (void *cls,
enum GNUNET_DB_QueryStatus qs;
struct TALER_Amount deposit_fee;
- /* make sure coin is 'known' in database */
- qs = TEH_make_coin_known (&deposit->coin,
- connection,
- mhd_ret);
- if (qs < 0)
- return qs;
-
/* Check for idempotency: did we get this request before? */
qs = TEH_plugin->have_deposit (TEH_plugin->cls,
deposit,
@@ -490,6 +483,31 @@ TEH_handler_deposit (struct MHD_Connection *connection,
NULL);
}
+ if (GNUNET_SYSERR ==
+ TEH_plugin->preflight (TEH_plugin->cls))
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_START_FAILED,
+ "preflight failure");
+ }
+
+ {
+ MHD_RESULT mhd_ret = MHD_NO;
+ enum GNUNET_DB_QueryStatus qs;
+
+ /* make sure coin is 'known' in database */
+ qs = TEH_make_coin_known (&deposit.coin,
+ connection,
+ &mhd_ret);
+ /* no transaction => no serialization failures should be possible */
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
+ if (qs < 0)
+ return mhd_ret;
+ }
+
+
/* execute transaction */
{
MHD_RESULT mhd_ret;
diff --git a/src/exchange/taler-exchange-httpd_melt.c
b/src/exchange/taler-exchange-httpd_melt.c
index e2e34371..3347790b 100644
--- a/src/exchange/taler-exchange-httpd_melt.c
+++ b/src/exchange/taler-exchange-httpd_melt.c
@@ -380,6 +380,16 @@ static MHD_RESULT
handle_melt (struct MHD_Connection *connection,
struct MeltContext *rmc)
{
+ if (GNUNET_SYSERR ==
+ TEH_plugin->preflight (TEH_plugin->cls))
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_START_FAILED,
+ "preflight failure");
+ }
+
/* verify signature of coin for melt operation */
{
struct TALER_RefreshMeltCoinAffirmationPS body = {
diff --git a/src/exchange/taler-exchange-httpd_recoup.c
b/src/exchange/taler-exchange-httpd_recoup.c
index 7ea345b8..fd8baf65 100644
--- a/src/exchange/taler-exchange-httpd_recoup.c
+++ b/src/exchange/taler-exchange-httpd_recoup.c
@@ -130,13 +130,6 @@ recoup_transaction (void *cls,
enum GNUNET_DB_QueryStatus qs;
int existing_recoup_found;
- /* make sure coin is 'known' in database */
- qs = TEH_make_coin_known (pc->coin,
- connection,
- mhd_ret);
- if (qs < 0)
- return qs;
-
/* Check whether a recoup is allowed, and if so, to which
reserve / account the money should go */
if (pc->refreshed)
@@ -471,6 +464,21 @@ verify_and_execute_recoup (
pc.coin_bks = coin_bks;
pc.coin = coin;
pc.refreshed = refreshed;
+
+ {
+ MHD_RESULT mhd_ret = MHD_NO;
+ enum GNUNET_DB_QueryStatus qs;
+
+ /* make sure coin is 'known' in database */
+ qs = TEH_make_coin_known (coin,
+ connection,
+ &mhd_ret);
+ /* no transaction => no serialization failures should be possible */
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
+ if (qs < 0)
+ return mhd_ret;
+ }
+
{
MHD_RESULT mhd_ret;
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c
b/src/exchangedb/plugin_exchangedb_postgres.c
index 79013179..4f0bc243 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -5778,6 +5778,8 @@ postgres_ensure_coin_known (void *cls,
GNUNET_break (0);
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Serialization failure in insert_known_coin? Strange!\n");
return TALER_EXCHANGEDB_CKS_SOFT_FAIL;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
/* continued below */
@@ -5794,8 +5796,11 @@ postgres_ensure_coin_known (void *cls,
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
+ GNUNET_break (0);
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Serialization failure in get_known_coin_dh? Strange!\n");
return TALER_EXCHANGEDB_CKS_SOFT_FAIL;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
if (0 == GNUNET_memcmp (&denom_pub_hash,
@@ -5865,7 +5870,6 @@ postgres_insert_deposit (void *cls,
&kyc);
if (qs <= 0)
{
- GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
return qs;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: move ensure_coin_known for melt and recoup outside of transaction, more logging,
gnunet <=