gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant] 16/19: Huge renaming about removing transa


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] 16/19: Huge renaming about removing transaction_id use
Date: Fri, 10 Feb 2017 14:23:07 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository merchant.

commit 1dc680a189a75bfca13bfc590d29e9e1dacfc89a
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Feb 7 19:08:47 2017 +0100

    Huge renaming about removing transaction_id use
---
 src/backend/taler-merchant-httpd_history.c         |   7 +-
 src/backend/taler-merchant-httpd_pay.c             |  21 +++--
 .../taler-merchant-httpd_track-transaction.c       |  51 +++++++----
 src/backend/taler-merchant-httpd_track-transfer.c  |  18 ++--
 src/backenddb/plugin_merchantdb_postgres.c         | 101 +++++++++++----------
 src/include/taler_merchantdb_plugin.h              |  34 +++----
 src/lib/merchant_api_pay.c                         |   7 +-
 src/lib/merchant_api_track_transfer.c              |   3 +-
 8 files changed, 127 insertions(+), 115 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_history.c 
b/src/backend/taler-merchant-httpd_history.c
index 32f31cf..4a96d2a 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 9dec5e0..31eec04 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 aeb2563..94b3f6d 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 40017c4..66dd920 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)
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index feb6113..57cfe5e 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -164,14 +164,14 @@ postgres_initialize (void *cls)
   /* Setup tables */
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_proposal_data ("
-           "h_transaction_id BYTEA NOT NULL CHECK 
(LENGTH(h_transaction_id)=64)"
+           "h_proposal_data BYTEA NOT NULL CHECK (LENGTH(h_proposal_data)=64)"
            ",proposal_data BYTEA NOT NULL"
-          ",PRIMARY KEY (h_transaction_id)"
+          ",PRIMARY KEY (h_proposal_data)"
            ");");
 
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_transactions ("
-           " transaction_id VARCHAR NOT NULL"
+           " h_proposal_data BYTEA NOT NULL"
            ",exchange_uri VARCHAR NOT NULL"
           ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)"
            ",h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)"
@@ -180,11 +180,11 @@ postgres_initialize (void *cls)
            ",total_amount_val INT8 NOT NULL"
            ",total_amount_frac INT4 NOT NULL"
            ",total_amount_curr VARCHAR(" TALER_CURRENCY_LEN_STR ") NOT NULL"
-          ",PRIMARY KEY (transaction_id, merchant_pub)"
+          ",PRIMARY KEY (h_proposal_data, merchant_pub)"
            ");");
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_deposits ("
-          " transaction_id VARCHAR NOT NULL"
+          " h_proposal_data BTYEA NOT NULL"
           ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)"
           ",FOREIGN KEY (transaction_id, merchant_pub) REFERENCES 
merchant_transactions (transaction_id, merchant_pub)"
            ",coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)"
@@ -196,7 +196,7 @@ postgres_initialize (void *cls)
            ",deposit_fee_curr VARCHAR(" TALER_CURRENCY_LEN_STR ") NOT NULL"
            ",signkey_pub BYTEA NOT NULL CHECK (LENGTH(signkey_pub)=32)"
            ",exchange_proof BYTEA NOT NULL"
-           ",PRIMARY KEY (transaction_id, coin_pub)"
+           ",PRIMARY KEY (h_proposal_data, coin_pub)"
            ");");
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_proofs ("
@@ -212,10 +212,10 @@ postgres_initialize (void *cls)
      Hence those cannot be foreign keys into deposits/transactions! */
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_transfers ("
-           " transaction_id VARCHAR NOT NULL"
+           " h_proposal_data BYTEA NOT NULL"
            ",coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)"
            ",wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32)"
-           ",PRIMARY KEY (transaction_id, coin_pub)"
+           ",PRIMARY KEY (h_proposal_data, coin_pub)"
            ");");
   PG_EXEC_INDEX (pg,
                  "CREATE INDEX IF NOT EXISTS merchant_transfers_by_coin"
@@ -228,7 +228,7 @@ postgres_initialize (void *cls)
   PG_PREPARE (pg,
               "insert_transaction",
               "INSERT INTO merchant_transactions"
-              "(transaction_id"
+              "(h_proposal_data"
               ",exchange_uri"
              ",merchant_pub"
               ",h_wire"
@@ -259,7 +259,7 @@ postgres_initialize (void *cls)
   PG_PREPARE (pg,
               "insert_transfer",
               "INSERT INTO merchant_transfers"
-              "(transaction_id"
+              "(h_proposal_data"
               ",coin_pub"
               ",wtid) VALUES "
               "($1, $2, $3)",
@@ -334,7 +334,7 @@ postgres_initialize (void *cls)
               ",deposit_fee_curr"
               ",exchange_proof"
               " FROM merchant_deposits"
-              " WHERE transaction_id=$1"
+              " WHERE h_proposal_data=$1"
               " AND merchant_pub=$2",
               2);
   PG_PREPARE (pg,
@@ -353,7 +353,7 @@ postgres_initialize (void *cls)
               " AND coin_pub=$3",
               3);
   PG_PREPARE (pg,
-              "find_transfers_by_transaction_id",
+              "find_transfers_by_hash",
               "SELECT"
               " coin_pub"
               ",wtid"
@@ -361,12 +361,12 @@ postgres_initialize (void *cls)
               ",merchant_proofs.proof"
               " FROM merchant_transfers"
               "   JOIN merchant_proofs USING (wtid)"
-              " WHERE transaction_id=$1",
+              " WHERE h_proposal_data=$1",
               1);
   PG_PREPARE (pg,
               "find_deposits_by_wtid",
               "SELECT"
-              " merchant_transfers.transaction_id"
+              " merchant_transfers.h_proposal_data"
               ",merchant_transfers.coin_pub"
               ",merchant_deposits.amount_with_fee_val"
               ",merchant_deposits.amount_with_fee_frac"
@@ -377,7 +377,7 @@ postgres_initialize (void *cls)
               ",merchant_deposits.exchange_proof"
               " FROM merchant_transfers"
               "   JOIN merchant_deposits"
-              "     ON (merchant_deposits.transaction_id = 
merchant_transfers.transaction_id"
+              "     ON (merchant_deposits.h_proposal_data = 
merchant_transfers.h_proposal_data"
               "       AND"
               "         merchant_deposits.coin_pub = 
merchant_transfers.coin_pub)"
               " WHERE wtid=$1",
@@ -515,7 +515,7 @@ postgres_insert_proposal_data (void *cls,
  */
 static int
 postgres_store_transaction (void *cls,
-                            const char *transaction_id,
+                            const struct GNUNET_HashCode *h_proposal_data,
                            const struct TALER_MerchantPublicKeyP *merchant_pub,
                             const char *exchange_uri,
                             const struct GNUNET_HashCode *h_wire,
@@ -530,7 +530,7 @@ postgres_store_transaction (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dbtc: %s\n", total_amount->currency);
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_string (transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_string (exchange_uri),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_auto_from_type (h_wire),
@@ -626,7 +626,7 @@ postgres_store_deposit (void *cls,
  */
 static int
 postgres_store_coin_to_transfer (void *cls,
-                                 const char *transaction_id,
+                                 const struct GNUNET_HashCode *h_proposal_data,
                                  const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
                                  const struct TALER_WireTransferIdentifierRawP 
*wtid)
 {
@@ -635,7 +635,7 @@ postgres_store_coin_to_transfer (void *cls,
   int ret;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_string (transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_auto_from_type (coin_pub),
     GNUNET_PQ_query_param_auto_from_type (wtid),
     GNUNET_PQ_query_param_end
@@ -753,12 +753,13 @@ postgres_find_transactions_by_date (void *cls,
     struct GNUNET_TIME_Absolute timestamp;
     struct GNUNET_TIME_Absolute refund_deadline;
     struct TALER_Amount total_amount;
-    char *transaction_id;
+    struct GNUNET_HashCode h_proposal_data;
+
     struct GNUNET_PQ_ResultSpec rs[] = {
       GNUNET_PQ_result_spec_string ("exchange_uri",
                                     &exchange_uri),
-      GNUNET_PQ_result_spec_string ("transaction_id",
-                                    &transaction_id),
+      GNUNET_PQ_result_spec_auto_from_type ("h_proposal_data",
+                                    &h_proposal_data),
       GNUNET_PQ_result_spec_auto_from_type ("merchant_pub",
                                             &merchant_pub),
       GNUNET_PQ_result_spec_auto_from_type ("h_wire",
@@ -784,7 +785,7 @@ postgres_find_transactions_by_date (void *cls,
     cb (cb_cls,
        &merchant_pub,
         exchange_uri,
-        transaction_id,
+        &h_proposal_data,
         &h_wire,
         timestamp,
         refund_deadline,
@@ -809,7 +810,7 @@ postgres_find_transactions_by_date (void *cls,
  */
 static int
 postgres_find_transaction (void *cls,
-                           const char *transaction_id,
+                           const struct GNUNET_HashCode *h_proposal_data,
                           const struct TALER_MerchantPublicKeyP *merchant_pub,
                            TALER_MERCHANTDB_TransactionCallback cb,
                            void *cb_cls)
@@ -817,7 +818,7 @@ postgres_find_transaction (void *cls,
   struct PostgresClosure *pg = cls;
   PGresult *result;
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_string(transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_end
   };
@@ -875,7 +876,7 @@ postgres_find_transaction (void *cls,
     cb (cb_cls,
        merchant_pub,
         exchange_uri,
-        transaction_id,
+        h_proposal_data,
         &h_wire,
         timestamp,
         refund_deadline,
@@ -900,7 +901,7 @@ postgres_find_transaction (void *cls,
  */
 static int
 postgres_find_payments (void *cls,
-                        const char *transaction_id,
+                        const struct GNUNET_HashCode *h_proposal_data,
                        const struct TALER_MerchantPublicKeyP *merchant_pub,
                         TALER_MERCHANTDB_CoinDepositCallback cb,
                         void *cb_cls)
@@ -910,7 +911,7 @@ postgres_find_payments (void *cls,
   unsigned int i;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_string (transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_end
   };
@@ -958,7 +959,7 @@ postgres_find_payments (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
+        h_proposal_data,
         &coin_pub,
         &amount_with_fee,
         &deposit_fee,
@@ -987,19 +988,19 @@ postgres_find_payments (void *cls,
  *         #GNUNET_SYSERR on hard errors
  */
 static int
-postgres_find_payments_by_id_and_coin (void *cls,
-                                       const char *transaction_id,
-                                       const struct TALER_MerchantPublicKeyP 
*merchant_pub,
-                                       const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
-                                       TALER_MERCHANTDB_CoinDepositCallback cb,
-                                       void *cb_cls)
+postgres_find_payments_by_hash_and_coin (void *cls,
+                                         const struct GNUNET_HashCode 
*h_proposal_data,
+                                         const struct TALER_MerchantPublicKeyP 
*merchant_pub,
+                                         const struct 
TALER_CoinSpendPublicKeyP *coin_pub,
+                                         TALER_MERCHANTDB_CoinDepositCallback 
cb,
+                                         void *cb_cls)
 {
   struct PostgresClosure *pg = cls;
   PGresult *result;
   unsigned int i;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_string (transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_auto_from_type (coin_pub),
     GNUNET_PQ_query_param_end
@@ -1046,7 +1047,7 @@ postgres_find_payments_by_id_and_coin (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
+        h_proposal_data,
         coin_pub,
         &amount_with_fee,
         &deposit_fee,
@@ -1076,21 +1077,21 @@ postgres_find_payments_by_id_and_coin (void *cls,
  *         #GNUNET_SYSERR on hard errors
  */
 static int
-postgres_find_transfers_by_id (void *cls,
-                               const char *transaction_id,
-                               TALER_MERCHANTDB_TransferCallback cb,
-                               void *cb_cls)
+postgres_find_transfers_by_hash (void *cls,
+                                 const struct GNUNET_HashCode *h_proposal_data,
+                                 TALER_MERCHANTDB_TransferCallback cb,
+                                 void *cb_cls)
 {
   struct PostgresClosure *pg = cls;
   PGresult *result;
   unsigned int i;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_string (transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_end
   };
   result = GNUNET_PQ_exec_prepared (pg->conn,
-                                    "find_transfers_by_transaction_id",
+                                    "find_transfers_by_hash",
                                     params);
   if (PGRES_TUPLES_OK != PQresultStatus (result))
   {
@@ -1133,7 +1134,7 @@ postgres_find_transfers_by_id (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
+        h_proposal_data,
         &coin_pub,
         &wtid,
         execution_time,
@@ -1186,15 +1187,15 @@ postgres_find_deposits_by_wtid (void *cls,
 
   for (i=0;i<PQntuples (result);i++)
   {
-    char *transaction_id;
+    struct GNUNET_HashCode h_proposal_data;
     struct TALER_CoinSpendPublicKeyP coin_pub;
     struct TALER_Amount amount_with_fee;
     struct TALER_Amount deposit_fee;
     json_t *exchange_proof;
 
     struct GNUNET_PQ_ResultSpec rs[] = {
-      GNUNET_PQ_result_spec_string ("transaction_id",
-                                    &transaction_id),
+      GNUNET_PQ_result_spec_auto_from_type ("h_proposal_data",
+                                            &h_proposal_data),
       GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
                                             &coin_pub),
       TALER_PQ_result_spec_amount ("amount_with_fee",
@@ -1216,7 +1217,7 @@ postgres_find_deposits_by_wtid (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
+        &h_proposal_data,
         &coin_pub,
         &amount_with_fee,
         &deposit_fee,
@@ -1350,9 +1351,9 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
   plugin->store_transfer_to_proof = &postgres_store_transfer_to_proof;
   plugin->find_transaction = &postgres_find_transaction;
   plugin->find_transactions_by_date = &postgres_find_transactions_by_date;
-  plugin->find_payments_by_id_and_coin = 
&postgres_find_payments_by_id_and_coin;
+  plugin->find_payments_by_hash_and_coin = 
&postgres_find_payments_by_hash_and_coin;
   plugin->find_payments = &postgres_find_payments;
-  plugin->find_transfers_by_id = &postgres_find_transfers_by_id;
+  plugin->find_transfers_by_hash = &postgres_find_transfers_by_hash;
   plugin->find_deposits_by_wtid = &postgres_find_deposits_by_wtid;
   plugin->find_proof_by_wtid = &postgres_find_proof_by_wtid;
   plugin->insert_proposal_data = &postgres_insert_proposal_data;
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 1abddc3..8f56986 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -47,7 +47,7 @@ typedef void
 (*TALER_MERCHANTDB_TransactionCallback)(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,
@@ -67,7 +67,7 @@ typedef void
  */
 typedef void
 (*TALER_MERCHANTDB_CoinDepositCallback)(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,
@@ -93,7 +93,7 @@ typedef void
  */
 typedef void
 (*TALER_MERCHANTDB_TransferCallback)(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,
@@ -195,7 +195,7 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*store_transaction) (void *cls,
-                        const char *transaction_id,
+                        const struct GNUNET_HashCode *h_proposal_data,
                        const struct TALER_MerchantPublicKeyP *merchant_pub,
                         const char *exchange_uri,
                         const struct GNUNET_HashCode *h_wire,
@@ -241,7 +241,7 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*store_coin_to_transfer) (void *cls,
-                             const char *transaction_id,
+                             const struct GNUNET_HashCode *h_proposal_data,
                              const struct TALER_CoinSpendPublicKeyP *coin_pub,
                              const struct TALER_WireTransferIdentifierRawP 
*wtid);
 
@@ -295,7 +295,7 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*find_transaction) (void *cls,
-                       const char *transaction_id,
+                       const struct GNUNET_HashCode *h_proposal_data,
                       const struct TALER_MerchantPublicKeyP *merchant_pub,
                        TALER_MERCHANTDB_TransactionCallback cb,
                        void *cb_cls);
@@ -315,7 +315,7 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*find_payments) (void *cls,
-                    const char *transaction_id,
+                    const struct GNUNET_HashCode *h_proposal_data,
                     const struct TALER_MerchantPublicKeyP *merchant_pub,
                     TALER_MERCHANTDB_CoinDepositCallback cb,
                     void *cb_cls);
@@ -334,12 +334,12 @@ struct TALER_MERCHANTDB_Plugin
    *         #GNUNET_SYSERR on hard errors
    */
   int
-  (*find_payments_by_id_and_coin) (void *cls,
-                                   const char *transaction_id,
-                                   const struct TALER_MerchantPublicKeyP 
*merchant_pub,
-                                   const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
-                                   TALER_MERCHANTDB_CoinDepositCallback cb,
-                                   void *cb_cls);
+  (*find_payments_by_hash_and_coin) (void *cls,
+                                     const struct GNUNET_HashCode 
*h_proposal_data,
+                                     const struct TALER_MerchantPublicKeyP 
*merchant_pub,
+                                     const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
+                                     TALER_MERCHANTDB_CoinDepositCallback cb,
+                                     void *cb_cls);
 
 
   /**
@@ -357,10 +357,10 @@ struct TALER_MERCHANTDB_Plugin
    *         #GNUNET_SYSERR on hard errors
    */
   int
-  (*find_transfers_by_id) (void *cls,
-                           const char *transaction_id,
-                           TALER_MERCHANTDB_TransferCallback cb,
-                           void *cb_cls);
+  (*find_transfers_by_hash) (void *cls,
+                             const struct GNUNET_HashCode *h_proposal_data,
+                             TALER_MERCHANTDB_TransferCallback cb,
+                             void *cb_cls);
 
 
   /**
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index 5475ec7..dd0c51b 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -278,7 +278,7 @@ struct TALER_MERCHANT_Pay *
 TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
                           const char *merchant_uri,
                           const char *instance,
-                           const struct GNUNET_HashCode *h_contract,
+                           const struct GNUNET_HashCode *h_proposal_data,
                            uint64_t transaction_id,
                           const struct TALER_Amount *amount,
                           const struct TALER_Amount *max_fee,
@@ -304,11 +304,10 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context 
*ctx,
 
   dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
   dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
-  dr.h_contract = *h_contract;
+  dr.h_proposal_data = *h_proposal_data;
   dr.h_wire = *h_wire;
   dr.timestamp = GNUNET_TIME_absolute_hton (timestamp);
   dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline);
-  dr.transaction_id = GNUNET_htonll (transaction_id);
   dr.merchant = *merchant_pub;
   for (i=0;i<num_coins;i++)
   {
@@ -346,7 +345,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
   return TALER_MERCHANT_pay_frontend (ctx,
                                      merchant_uri,
                                       instance,
-                                     h_contract,
+                                     h_proposal_data,
                                       amount,
                                      max_fee,
                                      transaction_id,
diff --git a/src/lib/merchant_api_track_transfer.c 
b/src/lib/merchant_api_track_transfer.c
index ee6c979..10e6981 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -118,8 +118,7 @@ check_track_transfer_response_ok (struct 
TALER_MERCHANT_TrackTransferHandle *wdh
       struct TALER_TrackTransferDetails *detail = &details[i];
       struct json_t *detail_j = json_array_get (details_j, i);
       struct GNUNET_JSON_Specification spec_detail[] = {
-        GNUNET_JSON_spec_fixed_auto ("H_contract", &detail->h_contract),
-        GNUNET_JSON_spec_uint64 ("transaction_id", &detail->transaction_id),
+        GNUNET_JSON_spec_fixed_auto ("h_proposal_data", 
&detail->h_proposal_data),
         GNUNET_JSON_spec_fixed_auto ("coin_pub", &detail->coin_pub),
         TALER_JSON_spec_amount ("deposit_value", &detail->coin_value),
         TALER_JSON_spec_amount ("deposit_fee", &detail->coin_fee),

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]