[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] 02/02: refund table takes merchant public
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] 02/02: refund table takes merchant public key too |
Date: |
Wed, 14 Jun 2017 09:57:26 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository merchant.
commit b98a6a4501c8333a5bf025ea60a38e45512048ff
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Jun 14 09:57:26 2017 +0200
refund table takes merchant public key too
---
src/backenddb/plugin_merchantdb_postgres.c | 28 +++++++++++++++++++++++-----
src/backenddb/test_merchantdb.c | 1 +
src/include/taler_merchantdb_plugin.h | 8 +++++---
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/src/backenddb/plugin_merchantdb_postgres.c
b/src/backenddb/plugin_merchantdb_postgres.c
index d51f401..3335051 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -238,6 +238,7 @@ postgres_initialize (void *cls)
");"),
GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS merchant_refunds ("
" rtransaction_id BIGSERIAL"
+ ",merchant_pub BYTEA NOT NULL CHECK
(LENGTH(merchant_pub)=32)"
",h_contract_terms BYTEA NOT NULL"
",coin_pub BYTEA NOT NULL CHECK
(LENGTH(coin_pub)=32)"
",reason VARCHAR NOT NULL"
@@ -340,14 +341,15 @@ postgres_initialize (void *cls)
3),
GNUNET_PQ_make_prepare ("insert_refund",
"INSERT INTO merchant_refunds"
- "(h_contract_terms"
+ "(merchant_pub"
+ ",h_contract_terms"
",coin_pub"
",reason"
",refund_amount_val"
",refund_amount_frac"
",refund_amount_curr) VALUES"
- "($1, $2, $3, $4, $5, $6)",
- 6),
+ "($1, $2, $3, $4, $5, $6, $7)",
+ 7),
GNUNET_PQ_make_prepare ("insert_proof",
"INSERT INTO merchant_proofs"
"(exchange_uri"
@@ -410,8 +412,9 @@ postgres_initialize (void *cls)
3),
GNUNET_PQ_make_prepare ("find_refunds_from_contract_terms_hash",
"SELECT * FROM merchant_refunds"
- " WHERE h_contract_terms=$1",
- 1),
+ " WHERE merchant_pub=$1"
+ " AND h_contract_terms=$2",
+ 2),
GNUNET_PQ_make_prepare ("find_contract_terms_by_date_and_range",
"SELECT"
" contract_terms"
@@ -1647,6 +1650,9 @@ postgres_find_deposits_by_wtid (void *cls,
/**
* Obtain refunds associated with a contract.
*
+ * @param cls closure, typically a connection to the db
+ * @param merchant_pub public key of the merchant instance
+ * @param h_contract_terms hash code of the contract
* @param rc function to call for each coin on which there is a refund
* @param rc_cls closure for @a rc
* @return #GNUNET_OK if we called @a rc on all coins
@@ -1655,6 +1661,7 @@ postgres_find_deposits_by_wtid (void *cls,
*/
int
postgres_get_refunds_from_contract_terms_hash (void *cls,
+ const struct
TALER_MerchantPublicKeyP *merchant_pub,
const struct GNUNET_HashCode
*h_contract_terms,
TALER_MERCHANTDB_RefundCallback
rc,
void *rc_cls)
@@ -1665,6 +1672,7 @@ postgres_get_refunds_from_contract_terms_hash (void *cls,
unsigned int i;
struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (merchant_pub),
GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
GNUNET_PQ_query_param_end
};
@@ -1805,6 +1813,11 @@ struct InsertRefundContext
struct TALER_Amount *refund;
/**
+ * Merchant instance public key
+ */
+ const struct TALER_MerchantPublicKeyP *merchant_pub;
+
+ /**
* Hash code representing the contract
*/
const struct GNUNET_HashCode *h_contract_terms;
@@ -1821,6 +1834,7 @@ struct InsertRefundContext
* in the db API.
*
* @param cls closure, tipically a connection to the db
+ * @param merchant_pub merchant instance public key
* @param h_contract_terms hashcode of the contract related to this refund
* @param coin_pub public key of the coin giving the (part of) refund
* @param reason human readable explaination behind the refund
@@ -1828,6 +1842,7 @@ struct InsertRefundContext
*/
enum GNUNET_DB_QueryStatus
insert_refund (void *cls,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct GNUNET_HashCode *h_contract_terms,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const char *reason,
@@ -1836,6 +1851,7 @@ insert_refund (void *cls,
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (merchant_pub),
GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
GNUNET_PQ_query_param_auto_from_type (coin_pub),
GNUNET_PQ_query_param_string (reason),
@@ -2005,6 +2021,7 @@ process_deposits_cb (void *cls,
if ( (0 != small->value) || (0 != small->fraction) )
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
insert_refund (ctx->pg,
+ ctx->merchant_pub,
ctx->h_contract_terms,
&coin_pub,
ctx->reason,
@@ -2132,6 +2149,7 @@ postgres_increase_refund_for_contract (void *cls,
ctx.refund = &_refund;
ctx.reason = reason;
ctx.h_contract_terms = h_contract_terms;
+ ctx.merchant_pub = merchant_pub;
ret = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"find_deposits",
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 0c9b455..975b3b4 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -565,6 +565,7 @@ run (void *cls)
NULL));
FAILIF (GNUNET_NO !=
plugin->get_refunds_from_contract_terms_hash (plugin->cls,
+ &merchant_pub,
&h_contract_terms,
&refund_cb,
NULL));
diff --git a/src/include/taler_merchantdb_plugin.h
b/src/include/taler_merchantdb_plugin.h
index e4ff082..2cef794 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -529,6 +529,7 @@ struct TALER_MERCHANTDB_Plugin
* increase the refund on an existing contract.
*
* @param cls closure
+ * @param merchant_pub merchant's instance public key
* @param h_contract_terms
* @param merchant_pub merchant's instance public key
* @param refund maximum refund to return to the customer for this contract
@@ -550,6 +551,9 @@ struct TALER_MERCHANTDB_Plugin
/**
* Obtain refunds associated with a contract.
*
+ * @param cls closure, typically a connection to the db
+ * @param merchant_pub public key of the merchant instance
+ * @param h_contract_terms hash code of the contract
* @param rc function to call for each coin on which there is a refund
* @param rc_cls closure for @a rc
* @return #GNUNET_OK if we called @a rc on all coins
@@ -558,12 +562,10 @@ struct TALER_MERCHANTDB_Plugin
*/
int
(*get_refunds_from_contract_terms_hash)(void *cls,
+ const struct
TALER_MerchantPublicKeyP *merchant_pub,
const struct GNUNET_HashCode
*h_contract_terms,
TALER_MERCHANTDB_RefundCallback rc,
void *rc_cls);
-
-
};
-
#endif
--
To stop receiving notification emails like this one, please contact
address@hidden