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: implement postges_g


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: implement postges_get_old_coin_by_h_blind for #5777
Date: Tue, 23 Jul 2019 20:27:50 +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 7d43ad56 implement postges_get_old_coin_by_h_blind for #5777
7d43ad56 is described below

commit 7d43ad56d3a43cc38b4ca0278145b237ca8e4bbb
Author: Christian Grothoff <address@hidden>
AuthorDate: Tue Jul 23 20:27:41 2019 +0200

    implement postges_get_old_coin_by_h_blind for #5777
---
 src/exchange/taler-exchange-httpd_payback.c |  3 --
 src/exchangedb/plugin_exchangedb_postgres.c | 52 +++++++++++++++++++++++++++--
 src/include/taler_exchangedb_plugin.h       | 17 ++++++++++
 3 files changed, 66 insertions(+), 6 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_payback.c 
b/src/exchange/taler-exchange-httpd_payback.c
index 60ce75f4..45f8c2fc 100644
--- a/src/exchange/taler-exchange-httpd_payback.c
+++ b/src/exchange/taler-exchange-httpd_payback.c
@@ -247,13 +247,10 @@ payback_transaction (void *cls,
      reserve / account the money should go */
   if (pc->refreshed)
   {
-    GNUNET_assert (0); // FIXME #5777: not implemented in DB!
-#if 0
     qs = TEH_plugin->get_old_coin_by_h_blind (TEH_plugin->cls,
                                               session,
                                               &pc->h_blind,
                                               &pc->target.old_coin_pub);
-#endif
     if (0 > qs)
     {
       if (GNUNET_DB_STATUS_HARD_ERROR == qs)
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index cbf4c093..b308f774 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1761,6 +1761,17 @@ postgres_prepare (PGconn *db_conn)
                             " LIMIT 1"
                             " FOR UPDATE;",
                             1),
+    /* Used in #postgres_get_old_coin_by_h_blind() */
+    GNUNET_PQ_make_prepare ("old_coin_by_h_blind",
+                            "SELECT"
+                            " rcom.old_coin_pub"
+                            " FROM refresh_revealed_coins"
+                            "   JOIN refresh_commitments rcom"
+                            "      USING (rc)"
+                            " WHERE coin_ev=$1"
+                            " LIMIT 1"
+                            " FOR UPDATE;",
+                            1),
     /* used in #postgres_commit */
     GNUNET_PQ_make_prepare ("do_commit",
                             "COMMIT",
@@ -7156,9 +7167,42 @@ postgres_get_reserve_by_h_blind (void *cls,
   };
 
   return GNUNET_PQ_eval_prepared_singleton_select (session->conn,
-                                                  "reserve_by_h_blind",
-                                                  params,
-                                                  rs);
+                                                   "reserve_by_h_blind",
+                                                   params,
+                                                   rs);
+}
+
+
+/**
+ * Obtain information about which old coin a coin was refreshed
+ * given the hash of the blinded (fresh) coin.
+ *
+ * @param cls closure
+ * @param session a session
+ * @param h_blind_ev hash of the blinded coin
+ * @param[out] reserve_pub set to information about the reserve (on success 
only)
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_get_old_coin_by_h_blind (void *cls,
+                                  struct TALER_EXCHANGEDB_Session *session,
+                                  const struct GNUNET_HashCode *h_blind_ev,
+                                  struct TALER_CoinSpendPublicKeyP 
*old_coin_pub)
+{
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (h_blind_ev),
+    GNUNET_PQ_query_param_end
+  };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_auto_from_type ("old_coin_pub",
+                                          old_coin_pub),
+    GNUNET_PQ_result_spec_end
+  };
+
+  return GNUNET_PQ_eval_prepared_singleton_select (session->conn,
+                                                   "old_coin_by_h_blind",
+                                                   params,
+                                                   rs);
 }
 
 
@@ -7764,6 +7808,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
     = &postgres_insert_payback_refresh_request;
   plugin->get_reserve_by_h_blind
     = &postgres_get_reserve_by_h_blind;
+  plugin->get_old_coin_by_h_blind
+    = &postgres_get_old_coin_by_h_blind;
   plugin->insert_denomination_revocation
     = &postgres_insert_denomination_revocation;
   plugin->get_denomination_revocation
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 8450fb04..104ae805 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -2430,6 +2430,23 @@ struct TALER_EXCHANGEDB_Plugin
 
 
   /**
+   * Obtain information about which old coin a coin was refreshed
+   * given the hash of the blinded (fresh) coin.
+   *
+   * @param cls closure
+   * @param session a session
+   * @param h_blind_ev hash of the blinded coin
+   * @param[out] old_coin_pub set to information about the old coin (on 
success only)
+   * @return transaction status code
+   */
+  enum GNUNET_DB_QueryStatus
+  (*get_old_coin_by_h_blind)(void *cls,
+                             struct TALER_EXCHANGEDB_Session *session,
+                             const struct GNUNET_HashCode *h_blind_ev,
+                             struct TALER_CoinSpendPublicKeyP *old_coin_pub);
+
+
+  /**
    * Store information that a denomination key was revoked
    * in the database.
    *

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



reply via email to

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