gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: do not 500 on empty reserve hist


From: gnunet
Subject: [taler-exchange] branch master updated: do not 500 on empty reserve history by not ignoring undecided purses that may have caused reserve to be created in the first place
Date: Mon, 16 Jan 2023 17:45:09 +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 faf3f57c do not 500 on empty reserve history by not ignoring undecided 
purses that may have caused reserve to be created in the first place
faf3f57c is described below

commit faf3f57ce3582a5b9f1070d689827bccd0183cd4
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jan 16 17:45:05 2023 +0100

    do not 500 on empty reserve history by not ignoring undecided purses that 
may have caused reserve to be created in the first place
---
 src/exchange/taler-exchange-httpd_responses.c | 6 ++++++
 src/exchange/taler-exchange-httpd_withdraw.c  | 2 ++
 src/exchangedb/exchange_do_reserve_purse.sql  | 4 ----
 src/exchangedb/pg_get_reserve_history.c       | 9 +++++++--
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_responses.c 
b/src/exchange/taler-exchange-httpd_responses.c
index ab9b8139..33bc1398 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -704,6 +704,7 @@ TEH_RESPONSE_compile_reserve_history (
   json_t *json_history;
 
   json_history = json_array ();
+  GNUNET_assert (NULL != json_history);
   for (const struct TALER_EXCHANGEDB_ReserveHistory *pos = rh;
        NULL != pos;
        pos = pos->next)
@@ -1012,10 +1013,14 @@ reply_reserve_insufficient_funds (
 
   json_history = TEH_RESPONSE_compile_reserve_history (rh);
   if (NULL == json_history)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to compile reserve history\n");
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
                                        
TALER_EC_EXCHANGE_RESERVE_HISTORY_ERROR_INSUFFICIENT_FUNDS,
                                        NULL);
+  }
   return TALER_MHD_REPLY_JSON_PACK (
     connection,
     MHD_HTTP_CONFLICT,
@@ -1061,6 +1066,7 @@ TEH_RESPONSE_reply_reserve_insufficient_balance (
   if ( (qs < 0) ||
        (NULL == rh) )
   {
+    GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
                                        TALER_EC_GENERIC_DB_FETCH_FAILED,
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c 
b/src/exchange/taler-exchange-httpd_withdraw.c
index 25377363..05153bfc 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -215,6 +215,8 @@ withdraw_transaction (void *cls,
   if (! balance_ok)
   {
     TEH_plugin->rollback (TEH_plugin->cls);
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Balance insufficient for /withdraw\n");
     *mhd_ret = TEH_RESPONSE_reply_reserve_insufficient_balance (
       connection,
       TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS,
diff --git a/src/exchangedb/exchange_do_reserve_purse.sql 
b/src/exchangedb/exchange_do_reserve_purse.sql
index 4f65c660..0476e60d 100644
--- a/src/exchangedb/exchange_do_reserve_purse.sql
+++ b/src/exchangedb/exchange_do_reserve_purse.sql
@@ -161,7 +161,3 @@ END $$;
 
 COMMENT ON FUNCTION exchange_do_reserve_purse(BYTEA, BYTEA, INT8, INT8, INT8, 
BYTEA, BOOLEAN, INT8, INT4, BYTEA, BYTEA)
   IS 'Create a purse for a reserve.';
-
-
-
-
diff --git a/src/exchangedb/pg_get_reserve_history.c 
b/src/exchangedb/pg_get_reserve_history.c
index 89701ae7..6c12abc6 100644
--- a/src/exchangedb/pg_get_reserve_history.c
+++ b/src/exchangedb/pg_get_reserve_history.c
@@ -797,14 +797,14 @@ TEH_PG_get_reserve_history (void *cls,
            " FROM purse_merges pm"
            "   JOIN purse_requests pr"
            "     USING (purse_pub)"
-           "   JOIN purse_decision pdes"
+           "   LEFT JOIN purse_decision pdes"
            "     USING (purse_pub)"
            "   JOIN account_merges am"
            "     ON (am.purse_pub = pm.purse_pub AND"
            "         am.reserve_pub = pm.reserve_pub)"
            " WHERE pm.reserve_pub=$1"
            "  AND COALESCE(pm.partner_serial_id,0)=0" /* must be local! */
-           "  AND NOT pdes.refunded;");
+           "  AND NOT COALESCE (pdes.refunded, FALSE);");
   PREPARE (pg,
            "history_by_reserve",
            "SELECT"
@@ -855,7 +855,12 @@ TEH_PG_get_reserve_history (void *cls,
                                                &rhc);
     if ( (0 > qs) ||
          (GNUNET_OK != rhc.status) )
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Failed to compile reserve history at `%s'\n",
+                  work[i].statement);
       break;
+    }
   }
   if ( (qs < 0) ||
        (rhc.status != GNUNET_OK) )

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]