summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_track-transaction.c
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-12-08 16:39:37 +0100
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-12-08 16:39:37 +0100
commit1a273fd9543a39900ffc57ea43b99ff618c1e485 (patch)
tree2faf83eb4b3bbc85b44925037c1de8ddae2e9432 /src/backend/taler-merchant-httpd_track-transaction.c
parent14aba6e9089ebb1eb52e258523eac23ce046cea9 (diff)
downloadmerchant-1a273fd9543a39900ffc57ea43b99ff618c1e485.tar.gz
merchant-1a273fd9543a39900ffc57ea43b99ff618c1e485.tar.bz2
merchant-1a273fd9543a39900ffc57ea43b99ff618c1e485.zip
Fix track-transaction conflict
Diffstat (limited to 'src/backend/taler-merchant-httpd_track-transaction.c')
-rw-r--r--src/backend/taler-merchant-httpd_track-transaction.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c
index 8bc41a84..8e963ba0 100644
--- 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,