commit 6a419ca7dfff4a504522a3ae947395d21aba3023
parent 3bc34304d3a9bdf460d3767fdf6c907338440e4e
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Mon, 9 Nov 2015 10:36:04 +0100
Merge branch 'master' of ssh://taler.net/var/git/merchant
Diffstat:
3 files changed, 58 insertions(+), 10 deletions(-)
diff --git a/src/backend-lib/merchant_db.h b/src/backend-lib/merchant_db.h
@@ -117,6 +117,20 @@ long long
MERCHANT_DB_get_contract_product (PGconn *conn,
uint64_t contract_id);
+/**
+ * Update the pending column of a deposit permission
+ * @param conn handle to DB
+ * @param transaction_id identification number of the deposit to
+ * update
+ * @param pending true if still pending, false otherwise (i.e. the
+ * mint did respond something)
+ * @return GNUNET_OK if successful, GNUNET_SYSERR upon errors
+ */
+uint32_t
+MERCHANT_DB_update_deposit_permission (PGconn *conn,
+ uint64_t transaction_id,
+ unsigned int pending);
+
unsigned int
MERCHANT_DB_checkout_create (PGconn *conn,
struct GNUNET_CRYPTO_rsa_PublicKey *coin_pub,
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
@@ -118,10 +118,36 @@ deposit_fee_from_coin_aggregate (struct MHD_Connection *connection,
void
deposit_cb (void *cls, unsigned int http_status, json_t *proof)
{
- if (MHD_HTTP_OK == http_status)
- ; /* set pending to false in DB and notify the frontend with "OK" */
- else
- ; /* set a timeout to retry */
+ /* NOTE: what if the mint doesn't respond? Does this callback get
+ called? */
+ int i;
+ struct MERCHANT_DepositConfirmationCls *dccls;
+ dccls = (struct MERCHANT_DepositConfirmationCls *) cls;
+
+ if (GNUNET_SYSERR ==
+ MERCHANT_DB_update_deposit_permission (db_conn,
+ dccls->transaction_id,
+ 0))
+ /* TODO */;
+ dccls->dc[dccls->index].ackd = 1;
+ dccls->dc[dccls->index].exit_status = http_status;
+ dccls->dc[dccls->index].proof = proof;
+
+ /* loop through the confirmation array and return accordingly */
+ for (i = 0; i < dccls->coins_cnt; i++)
+ {
+ /* just return if there is at least one coin to be still
+ confirmed */
+ if (!dccls->dc[i].ackd)
+ return;
+ }
+
+ /* at this point, any coin has been confirmed by the mint. So
+ check for errors .. */
+
+ /* Finally */
+ GNUNET_free (dccls->dc);
+ GNUNET_free (dccls);
}
/**
@@ -149,8 +175,8 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
json_t *coin_aggregate;
json_t *wire_details;
unsigned int mint_index; /*a cell in the global array*/
- unsigned int coins_index; /*a cell in the global array*/
- unsigned int coins_cnt; /*a cell in the global array*/
+ unsigned int coins_index;
+ unsigned int coins_cnt;
uint64_t transaction_id;
int res;
@@ -353,6 +379,8 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
dccls = GNUNET_malloc (sizeof (struct MERCHANT_DepositConfirmationCls));
dccls->index = coins_index;
dccls->dc = dc;
+ dccls->coins_cnt = coins_cnt;
+ dccls->transaction_id = transaction_id;
dh = TALER_MINT_deposit (mints[mint_index].conn,
&amount,
diff --git a/src/include/merchant.h b/src/include/merchant.h
@@ -47,10 +47,6 @@
struct MERCHANT_DepositConfirmation
{
/**
- * How many coins this request is made of
- */
- unsigned int coins_cnt;
- /**
* True if this coin's outcome has been read from
* its cb
*/
@@ -82,6 +78,16 @@ struct MERCHANT_DepositConfirmationCls
*/
struct MERCHANT_DepositConfirmation *dc;
+ /**
+ * How many coins this paymen is made of.
+ */
+ unsigned int coins_cnt;
+
+ /**
+ * Transaction id
+ */
+ uint64_t transaction_id;
+
};
/**