merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 1a273fd9543a39900ffc57ea43b99ff618c1e485
parent 14aba6e9089ebb1eb52e258523eac23ce046cea9
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date:   Thu,  8 Dec 2016 16:39:37 +0100

Fix track-transaction conflict

Diffstat:
Mconfigure.ac | 1+
Msrc/Makefile.am | 2+-
Msrc/backend/taler-merchant-httpd_track-transaction.c | 30+++++++++++++++++++++++++-----
Msrc/lib/test_merchant_api.c | 1-
4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -279,5 +279,6 @@ src/Makefile src/include/Makefile src/backenddb/Makefile src/backend/Makefile +src/merchant-tools/Makefile src/lib/Makefile]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am @@ -1,3 +1,3 @@ # This Makefile is in the public domain AM_CPPFLAGS = -I$(top_srcdir)/src/include -SUBDIRS = include backenddb backend lib +SUBDIRS = include backenddb backend lib merchant-tools diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c @@ -390,13 +390,20 @@ wire_deposits_cb (void *cls, continue; for (i=0;i<details_length;i++) { - tcc->wtid = tctx->current_wtid; - tcc->execution_time = tctx->current_execution_time; - tcc->have_wtid = GNUNET_YES; + + if (0 == memcmp (&details[i].coin_pub, + &tcc->coin_pub, + sizeof (struct TALER_CoinSpendPublicKeyP))) + { + tcc->wtid = tctx->current_wtid; + tcc->execution_time = tctx->current_execution_time; + tcc->have_wtid = GNUNET_YES; + } + if (GNUNET_OK != db->store_coin_to_transfer (db->cls, - tctx->transaction_id, - &tcc->coin_pub, + details[i].transaction_id, + &details[i].coin_pub, &tctx->current_wtid)) { /* Not good, but not fatal either, log error and continue */ @@ -499,6 +506,9 @@ wtid_cb (void *cls, tctx->current_wtid = *wtid; tctx->current_execution_time = execution_time; pcc.p_ret = NULL; + /* WARNING: if two transactions got aggregated under the same + WTID, then this branch is always taken (when attempting to + track the second transaction). */ if (GNUNET_OK == db->find_proof_by_wtid (db->cls, tctx->exchange_uri, @@ -506,6 +516,16 @@ wtid_cb (void *cls, &proof_cb, &pcc)) { + /** + * Conflict semantics: when the *first* call to /track/transaction + * at the exchange returns, the merchant issues a call to /track/transfer + * (at the exchange) and when that second call returns, it updates + * the information for all other coins using that returned information. + * Thus since this function is only called as callback to /track/transaction + * at the exchange, then if we already know this WTID, then some coin was not + * accounted in what /track/transfer returned (otherwise we wouldn't have + * tried to track it). + */ GNUNET_break_op (0); resume_track_transaction_with_response (tcc->tctx, diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c @@ -2393,7 +2393,6 @@ run (void *cls) /* end of testcase */ { .oc = OC_END } }; - /*get_new_contracts (commands);*/ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Interpreter initializing\n");