diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-02-07 19:08:47 +0100 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-02-07 19:08:47 +0100 |
commit | 1dc680a189a75bfca13bfc590d29e9e1dacfc89a (patch) | |
tree | 3063754c4e749506837aab149d5e63bcc1355530 /src/backend | |
parent | 17e344a8aea027132631d8a423391fb9f77da2dc (diff) | |
download | merchant-1dc680a189a75bfca13bfc590d29e9e1dacfc89a.tar.gz merchant-1dc680a189a75bfca13bfc590d29e9e1dacfc89a.tar.bz2 merchant-1dc680a189a75bfca13bfc590d29e9e1dacfc89a.zip |
Huge renaming about removing transaction_id use
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd_history.c | 7 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 21 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transaction.c | 51 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transfer.c | 18 |
4 files changed, 55 insertions, 42 deletions
diff --git a/src/backend/taler-merchant-httpd_history.c b/src/backend/taler-merchant-httpd_history.c index 32f31cff..4a96d2a2 100644 --- a/src/backend/taler-merchant-httpd_history.c +++ b/src/backend/taler-merchant-httpd_history.c @@ -42,7 +42,7 @@ static void history_cb (void *cls, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_uri, - const char *transaction_id, + const struct GNUNET_HashCode *h_proposal_data, const struct GNUNET_HashCode *h_wire, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund, @@ -52,10 +52,9 @@ history_cb (void *cls, json_t *entry; GNUNET_break (NULL != - (entry = json_pack ("{s:s, s:s, s:s, s:o}", - "transaction_id", transaction_id, + (entry = json_pack ("{s:o, s:s, s:s, s:o}", + "h_proposal_data", GNUNET_JSON_from_data_auto (h_proposal_data), "exchange", exchange_uri, - "transaction_id", transaction_id, "timestamp", GNUNET_JSON_from_time_abs (timestamp), "total_amount", TALER_JSON_from_amount (total_amount)))); diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c index 9dec5e05..31eec043 100644 --- a/src/backend/taler-merchant-httpd_pay.c +++ b/src/backend/taler-merchant-httpd_pay.c @@ -709,7 +709,6 @@ process_pay_with_exchange (void *cls, &dc->ub_sig, &dc->denom, pc->timestamp, - 0, /*FIXME: tid*/ &pc->mi->pubkey, pc->refund_deadline, &dc->coin_sig, @@ -773,7 +772,7 @@ handle_pay_timeout (void *cls) */ static void check_coin_paid (void *cls, - const char *transaction_id, + const struct GNUNET_HashCode *h_proposal_data, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *deposit_fee, @@ -782,8 +781,9 @@ check_coin_paid (void *cls, struct PayContext *pc = cls; unsigned int i; - if (0 != strcmp (pc->transaction_id, - transaction_id)) + if (0 != memcmp (&pc->h_proposal_data, + h_proposal_data, + sizeof (struct GNUNET_HashCode))) { GNUNET_break (0); return; @@ -821,7 +821,7 @@ static void check_transaction_exists (void *cls, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_uri, - const char *transaction_id, + const struct GNUNET_HashCode *h_proposal_data, const struct GNUNET_HashCode *h_xwire, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund, @@ -829,8 +829,9 @@ check_transaction_exists (void *cls, { struct PayContext *pc = cls; - if ( (0 == strcmp (transaction_id, - pc->transaction_id)) && + if ( (0 == memcmp (h_proposal_data, + &pc->h_proposal_data, + sizeof (struct GNUNET_HashCode))) && (0 == memcmp (h_xwire, &pc->mi->h_wire, sizeof (struct GNUNET_HashCode))) && @@ -1106,7 +1107,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, /* Check if this payment attempt has already succeeded */ if (GNUNET_SYSERR == db->find_payments (db->cls, - pc->transaction_id, + &pc->h_proposal_data, &pc->mi->pubkey, &check_coin_paid, pc)) @@ -1137,7 +1138,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, /* Check if transaction is already known, if not store it. */ if (GNUNET_SYSERR == db->find_transaction (db->cls, - pc->transaction_id, + &pc->h_proposal_data, &pc->mi->pubkey, &check_transaction_exists, pc)) @@ -1177,7 +1178,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, if (GNUNET_OK != db->store_transaction (db->cls, - pc->transaction_id, + &pc->h_proposal_data, &pc->mi->pubkey, pc->chosen_exchange, &pc->mi->h_wire, diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c index aeb25637..94b3f6d1 100644 --- a/src/backend/taler-merchant-httpd_track-transaction.c +++ b/src/backend/taler-merchant-httpd_track-transaction.c @@ -205,6 +205,11 @@ struct TrackTransactionContext const char *transaction_id; /** + * Proposal's hashcode. + */ + struct GNUNET_HashCode h_proposal_data; + + /** * Response code to return upon resume. */ unsigned int response_code; @@ -397,7 +402,7 @@ wire_deposits_cb (void *cls, if (GNUNET_OK != db->store_coin_to_transfer (db->cls, - details[i].transaction_id, + &details[i].h_proposal_data, &details[i].coin_pub, &tctx->current_wtid)) { @@ -563,8 +568,8 @@ trace_coins (struct TrackTransactionContext *tctx) tcc->dwh = TALER_EXCHANGE_track_transaction (tctx->eh, &tctx->mi->privkey, &tctx->h_wire, + &tctx->h_proposal_data, &tcc->coin_pub, - 0, /*FIXME: tid*/ &wtid_cb, tcc); return; @@ -715,6 +720,7 @@ handle_track_transaction_timeout (void *cls) /** * Function called with information about a transaction. + * Its duty is to fill up the "context" for the whole operation. * * @param cls closure * @param transaction_id of the contract @@ -730,7 +736,7 @@ static void transaction_cb (void *cls, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_uri, - const char *transaction_id, + const struct GNUNET_HashCode *h_proposal_data, const struct GNUNET_HashCode *h_wire, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund, @@ -738,7 +744,7 @@ transaction_cb (void *cls, { struct TrackTransactionContext *tctx = cls; - tctx->transaction_id = GNUNET_strdup (transaction_id); + tctx->h_proposal_data = *h_proposal_data; tctx->exchange_uri = GNUNET_strdup (exchange_uri); tctx->h_wire = *h_wire; tctx->timestamp = timestamp; @@ -766,7 +772,7 @@ transaction_cb (void *cls, */ static void transfer_cb (void *cls, - const char *transaction_id, + const struct GNUNET_HashCode *h_proposal_data, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_WireTransferIdentifierRawP *wtid, struct GNUNET_TIME_Absolute execution_time, @@ -796,7 +802,7 @@ transfer_cb (void *cls, */ static void coin_cb (void *cls, - const char *transaction_id, + const struct GNUNET_HashCode *h_proposal_data, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *deposit_fee, @@ -814,10 +820,10 @@ coin_cb (void *cls, tctx->tcc_tail, tcc); GNUNET_break (GNUNET_SYSERR != - db->find_transfers_by_id (db->cls, - transaction_id, - &transfer_cb, - tcc)); + db->find_transfers_by_hash (db->cls, + h_proposal_data, + &transfer_cb, + tcc)); } /** @@ -838,10 +844,11 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, size_t *upload_data_size) { struct TrackTransactionContext *tctx; - const char *transaction_id; + const char *h_proposal_data_str; const char *instance; int ret; struct GNUNET_HashCode h_instance; + struct GNUNET_HashCode h_proposal_data; if (NULL == *connection_cls) { @@ -886,13 +893,13 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, "Not sure why we are here, should be suspended\n"); return MHD_YES; /* still work in progress */ } - transaction_id = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "id"); - if (NULL == transaction_id) + h_proposal_data_str = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "hash"); + if (NULL == h_proposal_data_str) return TMH_RESPONSE_reply_arg_missing (connection, TALER_EC_PARAMETER_MISSING, - "id"); + "hash"); instance = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "instance"); @@ -901,6 +908,10 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, GNUNET_CRYPTO_hash (instance, strlen (instance), &h_instance); + GNUNET_CRYPTO_hash (h_proposal_data_str, + strlen (h_proposal_data_str), + &h_proposal_data); + tctx->mi = GNUNET_CONTAINER_multihashmap_get (by_id_map, &h_instance); if (NULL == tctx->mi) @@ -908,7 +919,7 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, TALER_EC_TRACK_TRANSACTION_INSTANCE_UNKNOWN, "unknown instance"); ret = db->find_transaction (db->cls, - transaction_id, + &h_proposal_data, &tctx->mi->pubkey, &transaction_cb, tctx); @@ -919,7 +930,9 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, "id"); } if ( (GNUNET_SYSERR == ret) || - (0 != strcmp (tctx->transaction_id, transaction_id)) || + (0 != memcmp (&tctx->h_proposal_data, + &h_proposal_data, + sizeof (struct GNUNET_HashCode))) || (NULL == tctx->exchange_uri) ) { GNUNET_break (0); @@ -928,7 +941,7 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, "Database error"); } ret = db->find_payments (db->cls, - transaction_id, + &h_proposal_data, &tctx->mi->pubkey, &coin_cb, tctx); diff --git a/src/backend/taler-merchant-httpd_track-transfer.c b/src/backend/taler-merchant-httpd_track-transfer.c index 40017c41..66dd9205 100644 --- a/src/backend/taler-merchant-httpd_track-transfer.c +++ b/src/backend/taler-merchant-httpd_track-transfer.c @@ -215,7 +215,7 @@ track_transfer_cleanup (struct TM_HandlerContext *hc) */ static void check_transfer (void *cls, - const char *transaction_id, + const struct GNUNET_HashCode *h_proposal_data, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *deposit_fee, @@ -244,7 +244,7 @@ check_transfer (void *cls, "conflict_offset", (json_int_t) rctx->current_offset, "exchange_transfer_proof", rctx->original_response, "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), - "transaction_id", transaction_id, + "h_proposal_data", GNUNET_JSON_from_data_auto (&ttd->h_proposal_data), "amount_with_fee", TALER_JSON_from_amount (amount_with_fee), "deposit_fee", TALER_JSON_from_amount (deposit_fee)); return; @@ -327,12 +327,12 @@ wire_transfer_cb (void *cls, rctx->current_offset = i; rctx->current_detail = &details[i]; rctx->check_transfer_result = GNUNET_NO; - ret = db->find_payments_by_id_and_coin (db->cls, - details[i].transaction_id, - &rctx->mi->pubkey, - &details[i].coin_pub, - &check_transfer, - rctx); + ret = db->find_payments_by_hash_and_coin (db->cls, + &details[i].h_proposal_data, + &rctx->mi->pubkey, + &details[i].coin_pub, + &check_transfer, + rctx); if (GNUNET_SYSERR == ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -384,7 +384,7 @@ wire_transfer_cb (void *cls, /* Response is consistent with the /deposit we made, remember it for future reference */ ret = db->store_coin_to_transfer (db->cls, - details[i].transaction_id, + &details[i].h_proposal_data, &details[i].coin_pub, &rctx->wtid); if (GNUNET_OK != ret) |