gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 165/277: add logic for activation of reserves to mercha


From: gnunet
Subject: [taler-merchant] 165/277: add logic for activation of reserves to merchant backend DB
Date: Sun, 05 Jul 2020 20:51:18 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

commit e3c0320132f88f3d13e1f6d96a6cea9c3334df83
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jun 1 14:12:59 2020 +0200

    add logic for activation of reserves to merchant backend DB
---
 src/backenddb/plugin_merchantdb_postgres.c | 45 ++++++++++++++++++++++++++++++
 src/include/taler_merchantdb_plugin.h      | 20 +++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 5981004..ca00539 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -3819,6 +3819,39 @@ RETRY:
 }
 
 
+/**
+ * Confirms @a credit as the amount the exchange claims to have received and
+ * thus really 'activates' the reserve.  This has to happen before tips can
+ * be authorized.
+ *
+ * @param cls closure, typically a connection to the db
+ * @param instance_id which instance is the reserve tied to
+ * @param reserve_pub which reserve is topped up or created
+ * @param initial_exchange_balance how much money was be added to the reserve
+ *           according to the exchange
+ * @return transaction status, usually
+ *      #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_activate_reserve (void *cls,
+                           const char *instance_id,
+                           const struct TALER_ReservePublicKeyP *reserve_pub,
+                           const struct TALER_Amount *initial_exchange_balance)
+{
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_string (instance_id),
+    GNUNET_PQ_query_param_auto_from_type (reserve_pub),
+    TALER_PQ_query_param_amount (initial_exchange_balance),
+    GNUNET_PQ_query_param_end
+  };
+
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "activate_reserve",
+                                             params);
+}
+
+
 /**
  * Closure for #lookup_accounts_cb.
  */
@@ -6865,6 +6898,17 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
                             " FROM merchant_instances"
                             " WHERE merchant_id=$1",
                             6),
+    /* For postgres_activate_reserve() */
+    GNUNET_PQ_make_prepare ("activate_reserve",
+                            "UPDATE merchant_tip_reserves SET"
+                            " exchange_initial_balance_val=$3"
+                            " exchange_initial_balance_frac=$4"
+                            " WHERE reserve_pub=$2"
+                            " AND merchant_serial="
+                            "   (SELECT merchant_serial"
+                            "      FROM merchant_instances"
+                            "     WHERE merchant_id=$1)",
+                            4),
     /* For postgres_insert_reserve() */
     GNUNET_PQ_make_prepare ("insert_reserve_key",
                             "INSERT INTO merchant_tip_reserve_keys"
@@ -7250,6 +7294,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
   plugin->lookup_transfers = &postgres_lookup_transfers;
   plugin->store_wire_fee_by_exchange = &postgres_store_wire_fee_by_exchange;
   plugin->insert_reserve = &postgres_insert_reserve;
+  plugin->activate_reserve = &postgres_activate_reserve;
   plugin->lookup_reserves = &postgres_lookup_reserves;
   plugin->lookup_reserve = &postgres_lookup_reserve;
   plugin->delete_reserve = &postgres_delete_reserve;
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 8f17da7..0346597 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -1613,6 +1613,26 @@ struct TALER_MERCHANTDB_Plugin
                     struct GNUNET_TIME_Absolute expiration);
 
 
+  /**
+   * Confirms @a credit as the amount the exchange claims to have received and
+   * thus really 'activates' the reserve.  This has to happen before tips can
+   * be authorized.
+   *
+   * @param cls closure, typically a connection to the db
+   * @param instance_id which instance is the reserve tied to
+   * @param reserve_pub which reserve is topped up or created
+   * @param initial_exchange_balance how much money was be added to the reserve
+   *           according to the exchange
+   * @return transaction status, usually
+   *      #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
+   */
+  enum GNUNET_DB_QueryStatus
+  (*activate_reserve)(void *cls,
+                      const char *instance_id,
+                      const struct TALER_ReservePublicKeyP *reserve_pub,
+                      const struct TALER_Amount *initial_exchange_balance);
+
+
   /**
    * Lookup reserves.
    *

-- 
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]