[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.
- [taler-merchant] 141/277: Merge branch 'protocolV1' of git+ssh://git.taler.net/merchant into protocolV1, (continued)
- [taler-merchant] 141/277: Merge branch 'protocolV1' of git+ssh://git.taler.net/merchant into protocolV1, gnunet, 2020/07/05
- [taler-merchant] 143/277: more SQL for tips, gnunet, 2020/07/05
- [taler-merchant] 148/277: fixed inventory locking, test code for transfer lookups, gnunet, 2020/07/05
- [taler-merchant] 155/277: fix ftbfs, gnunet, 2020/07/05
- [taler-merchant] 154/277: return creation_time instead of leaving it uninitizlied, mark problematic missing lines, gnunet, 2020/07/05
- [taler-merchant] 158/277: work on tip APIs, gnunet, 2020/07/05
- [taler-merchant] 156/277: implement lookup tip details, gnunet, 2020/07/05
- [taler-merchant] 159/277: add POST /tips logic, gnunet, 2020/07/05
- [taler-merchant] 164/277: fixed db test building and added test for wire fee storage, gnunet, 2020/07/05
- [taler-merchant] 163/277: implement filter, gnunet, 2020/07/05
- [taler-merchant] 165/277: add logic for activation of reserves to merchant backend DB,
gnunet <=
- [taler-merchant] 147/277: added more tests for contract terms, deposits, and transfers, gnunet, 2020/07/05
- [taler-merchant] 160/277: address DB fixes for missing EC values, gnunet, 2020/07/05
- [taler-merchant] 157/277: fix DB use, gnunet, 2020/07/05
- [taler-merchant] 166/277: SQL fixing, gnunet, 2020/07/05
- [taler-merchant] 152/277: wrote db tests for tips/lookups, gnunet, 2020/07/05
- [taler-merchant] 145/277: refactored the existing product and order tests, gnunet, 2020/07/05
- [taler-merchant] 171/277: tests/fixes for tips and pickups in backenddb, gnunet, 2020/07/05
- [taler-merchant] 169/277: implement POST /private/reserves, gnunet, 2020/07/05
- [taler-merchant] 161/277: fix misc issues in client APIs, gnunet, 2020/07/05
- [taler-merchant] 162/277: implement GET /reserves/RPUB, gnunet, 2020/07/05