gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated: reduce redundant da


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: reduce redundant data fetch (#5444)
Date: Fri, 19 Oct 2018 11:07:12 +0200

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 fb952bab reduce redundant data fetch (#5444)
fb952bab is described below

commit fb952babf67c41dedf3fac6b9d89eccf7fc10b2e
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Oct 19 11:01:40 2018 +0200

    reduce redundant data fetch (#5444)
---
 src/exchange/taler-exchange-httpd_db.c           |  3 +-
 src/exchange/taler-exchange-httpd_keystate.c     |  2 +-
 src/exchange/taler-exchange-httpd_refresh_melt.c | 16 +++++----
 src/exchangedb/plugin_exchangedb_postgres.c      | 42 ++++++++++++++++++++++++
 src/include/taler_exchangedb_plugin.h            | 17 ++++++++++
 5 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_db.c 
b/src/exchange/taler-exchange-httpd_db.c
index 34993150..579f0620 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -172,13 +172,12 @@ TEH_DB_calculate_transaction_list_totals (struct 
TALER_EXCHANGEDB_TransactionLis
                                          struct TALER_Amount *ret)
 {
   struct TALER_Amount spent = *off;
-  struct TALER_EXCHANGEDB_TransactionList *pos;
   struct TALER_Amount refunded;
 
   GNUNET_assert (GNUNET_OK ==
                  TALER_amount_get_zero (spent.currency,
                                         &refunded));
-  for (pos = tl; NULL != pos; pos = pos->next)
+  for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; NULL != pos; pos = 
pos->next)
   {
     switch (pos->type)
     {
diff --git a/src/exchange/taler-exchange-httpd_keystate.c 
b/src/exchange/taler-exchange-httpd_keystate.c
index 2e1a85f8..413b9d1b 100644
--- a/src/exchange/taler-exchange-httpd_keystate.c
+++ b/src/exchange/taler-exchange-httpd_keystate.c
@@ -2107,7 +2107,7 @@ TEH_KS_handler_keys (struct TEH_RequestHandler *rh,
                  sizeof (struct KeysResponseData),
                  &krd_search_comparator);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Filtering /keys by cherry pick date %s found entry %u/%u\n",
               GNUNET_STRINGS_absolute_time_to_string (last_issue_date),
               (unsigned int) (krd - key_state->krd_array),
diff --git a/src/exchange/taler-exchange-httpd_refresh_melt.c 
b/src/exchange/taler-exchange-httpd_refresh_melt.c
index a844d3a4..476188de 100644
--- a/src/exchange/taler-exchange-httpd_refresh_melt.c
+++ b/src/exchange/taler-exchange-httpd_refresh_melt.c
@@ -252,20 +252,22 @@ refresh_melt_transaction (void *cls,
   struct RefreshMeltContext *rmc = cls;
   struct TALER_EXCHANGEDB_RefreshMelt rm;
   enum GNUNET_DB_QueryStatus qs;
+  uint32_t noreveal_index;
 
   /* Check if we already created such a session */
-  qs = TEH_plugin->get_melt (TEH_plugin->cls,
-                             session,
-                             &rmc->refresh_session.rc,
-                             &rm);
+  qs = TEH_plugin->get_melt_index (TEH_plugin->cls,
+                                   session,
+                                   &rmc->refresh_session.rc,
+                                   &noreveal_index);
   if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
   {
     TALER_LOG_DEBUG ("Found already-melted coin\n");
     *mhd_ret = reply_refresh_melt_success (connection,
                                           &rmc->refresh_session.rc,
-                                          rm.session.noreveal_index);
-    /* FIXME: is it normal to return "hard error" upon
-     * _finding_ some data into the database?  */
+                                          noreveal_index);
+    /* Note: we return "hard error" to ensure the wrapper
+       does not retry the transaction, and to also not generate
+       a "fresh" response (as we would on "success") */
     return GNUNET_DB_STATUS_HARD_ERROR;
   }
   if (0 > qs)
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 7da15ced..b2731366 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -858,6 +858,14 @@ postgres_prepare (PGconn *db_conn)
                             "     ON (kc.denom_pub_hash = 
denom.denom_pub_hash)"
                             " WHERE rc=$1;",
                             1),
+    /* Used in #postgres_get_melt_index() to fetch
+       the noreveal index from a previous melt operation */
+    GNUNET_PQ_make_prepare ("get_melt_index",
+                            "SELECT"
+                            " noreveal_index"
+                            " FROM refresh_commitments"
+                            " WHERE rc=$1;",
+                            1),
     /* Used in #postgres_select_refreshs_above_serial_id() to fetch
        refresh session with id '\geq' the given parameter */
     GNUNET_PQ_make_prepare ("audit_get_refresh_commitments_incr",
@@ -3485,6 +3493,39 @@ postgres_get_melt (void *cls,
 
 
 /**
+ * Lookup noreveal index of a previous melt operation under the given
+ * @a rc.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @param session database handle to use
+ * @param rc commitment hash to use to locate the operation
+ * @param[out] refresh_melt where to store the result
+ * @return transaction status
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_get_melt_index (void *cls,
+                         struct TALER_EXCHANGEDB_Session *session,
+                         const struct TALER_RefreshCommitmentP *rc,
+                         uint32_t *noreveal_index)
+{
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (rc),
+    GNUNET_PQ_query_param_end
+  };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_uint32 ("noreveal_index",
+                                 noreveal_index),
+    GNUNET_PQ_result_spec_end
+  };
+
+  return GNUNET_PQ_eval_prepared_singleton_select (session->conn,
+                                                   "get_melt_index",
+                                                   params,
+                                                   rs);
+}
+
+
+/**
  * Store new refresh melt commitment data.
  *
  * @param cls the `struct PostgresClosure` with the plugin-specific state
@@ -7035,6 +7076,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
   plugin->select_refunds_by_coin = &postgres_select_refunds_by_coin;
   plugin->insert_melt = &postgres_insert_melt;
   plugin->get_melt = &postgres_get_melt;
+  plugin->get_melt_index = &postgres_get_melt_index;
   plugin->insert_refresh_reveal = &postgres_insert_refresh_reveal;
   plugin->get_refresh_reveal = &postgres_get_refresh_reveal;
   plugin->get_link_data = &postgres_get_link_data;
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 580a628c..ee58dd43 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1607,6 +1607,23 @@ struct TALER_EXCHANGEDB_Plugin
 
 
   /**
+   * Lookup noreveal index of a previous melt operation under the given
+   * @a rc.
+   *
+   * @param cls the `struct PostgresClosure` with the plugin-specific state
+   * @param session database handle to use
+   * @param rc commitment hash to use to locate the operation
+   * @param[out] refresh_melt where to store the result
+   * @return transaction status
+   */
+  enum GNUNET_DB_QueryStatus
+  (*get_melt_index) (void *cls,
+                     struct TALER_EXCHANGEDB_Session *session,
+                     const struct TALER_RefreshCommitmentP *rc,
+                     uint32_t *noreveal_index);
+
+
+  /**
    * Store in the database which coin(s) the wallet wanted to create
    * in a given refresh operation and all of the other information
    * we learned or created in the /refresh/reveal step.

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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