gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] 17/19: More fixes on renaming, mostly in d


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] 17/19: More fixes on renaming, mostly in db.
Date: Fri, 10 Feb 2017 14:23:08 +0100

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

marcello pushed a commit to branch master
in repository merchant.

commit 5bc8e40c420f8f914ae1562c4c2e50840fa690a3
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Feb 7 21:31:36 2017 +0100

    More fixes on renaming, mostly in db.
---
 src/backenddb/plugin_merchantdb_postgres.c | 12 ++++-----
 src/backenddb/test_merchantdb.c            | 43 +++++++++++++++++++-----------
 src/include/taler_merchantdb_plugin.h      |  2 +-
 3 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 57cfe5e..9a528d2 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -184,9 +184,9 @@ postgres_initialize (void *cls)
            ");");
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_deposits ("
-          " h_proposal_data BTYEA NOT NULL"
+          " h_proposal_data BYTEA 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)"
+          ",FOREIGN KEY (h_proposal_data, merchant_pub) REFERENCES 
merchant_transactions (h_proposal_data, merchant_pub)"
            ",coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)"
            ",amount_with_fee_val INT8 NOT NULL"
            ",amount_with_fee_frac INT4 NOT NULL"
@@ -243,7 +243,7 @@ postgres_initialize (void *cls)
   PG_PREPARE (pg,
               "insert_deposit",
               "INSERT INTO merchant_deposits"
-              "(transaction_id"
+              "(h_proposal_data"
              ",merchant_pub"
               ",coin_pub"
               ",amount_with_fee_val"
@@ -527,8 +527,6 @@ postgres_store_transaction (void *cls,
   PGresult *result;
   int ret;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dbtc: %s\n", total_amount->currency);
-
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_string (exchange_uri),
@@ -573,7 +571,7 @@ postgres_store_transaction (void *cls,
  */
 static int
 postgres_store_deposit (void *cls,
-                        const char *transaction_id,
+                        const struct GNUNET_HashCode *h_proposal_data,
                         const struct TALER_MerchantPublicKeyP *merchant_pub,
                         const struct TALER_CoinSpendPublicKeyP *coin_pub,
                         const struct TALER_Amount *amount_with_fee,
@@ -586,7 +584,7 @@ postgres_store_deposit (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 (merchant_pub),
     GNUNET_PQ_query_param_auto_from_type (coin_pub),
     TALER_PQ_query_param_amount (amount_with_fee),
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index add1e81..e2e43bd 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -75,6 +75,11 @@ static struct GNUNET_HashCode h_wire;
 char *transaction_id;
 
 /**
+ * Proposal's hash
+ */
+struct GNUNET_HashCode h_proposal_data;
+
+/**
  * Time of the transaction.
  */
 static struct GNUNET_TIME_Absolute timestamp;
@@ -158,7 +163,7 @@ static void
 transaction_cb (void *cls,
                const struct TALER_MerchantPublicKeyP *amerchant_pub,
                 const char *aexchange_uri,
-                const char *atransaction_id,
+                const struct GNUNET_HashCode *ah_proposal_data,
                 const struct GNUNET_HashCode *ah_wire,
                 struct GNUNET_TIME_Absolute atimestamp,
                 struct GNUNET_TIME_Absolute arefund_deadline,
@@ -168,8 +173,9 @@ transaction_cb (void *cls,
   CHECK (0 == memcmp (amerchant_pub,
                       &merchant_pub,
                      sizeof (struct TALER_MerchantPublicKeyP)));
-  CHECK (0 == strcmp (atransaction_id,
-                      transaction_id));
+  CHECK (0 == memcmp (ah_proposal_data,
+                      &h_proposal_data,
+                      sizeof (struct GNUNET_HashCode)));
   CHECK (0 == strcmp (aexchange_uri,
                       EXCHANGE_URI));
   CHECK (0 == memcmp (ah_wire,
@@ -200,7 +206,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,
@@ -222,14 +228,15 @@ history_cb (void *cls,
  */
 static void
 deposit_cb (void *cls,
-            const char *atransaction_id,
+            const struct GNUNET_HashCode *ah_proposal_data,
             const struct TALER_CoinSpendPublicKeyP *acoin_pub,
             const struct TALER_Amount *aamount_with_fee,
             const struct TALER_Amount *adeposit_fee,
             const json_t *aexchange_proof)
 {
-  CHECK ((0 == strcmp (atransaction_id,
-                       transaction_id)));
+  CHECK ((0 == memcmp (ah_proposal_data,
+                       &h_proposal_data,
+                       sizeof (struct GNUNET_HashCode))));
   CHECK (0 == memcmp (acoin_pub,
                       &coin_pub,
                       sizeof (struct TALER_CoinSpendPublicKeyP)));
@@ -261,13 +268,16 @@ deposit_cb (void *cls,
  */
 static void
 transfer_cb (void *cls,
-             const char *atransaction_id,
+             const struct GNUNET_HashCode *ah_proposal_data,
              const struct TALER_CoinSpendPublicKeyP *acoin_pub,
              const struct TALER_WireTransferIdentifierRawP *awtid,
              struct GNUNET_TIME_Absolute execution_time,
              const json_t *exchange_proof)
 {
-  CHECK (atransaction_id == transaction_id);
+  CHECK (0 == memcmp (ah_proposal_data,
+                      &h_proposal_data,
+                      sizeof (struct GNUNET_HashCode)));
+
   CHECK (0 == memcmp (acoin_pub,
                       &coin_pub,
                       sizeof (struct TALER_CoinSpendPublicKeyP)));
@@ -325,6 +335,7 @@ run (void *cls)
 
   /* Prepare data for 'store_payment()' */
   RND_BLK (&h_wire);
+  RND_BLK (&h_proposal_data);
   transaction_id = "test_ID";
   GNUNET_CRYPTO_hash (transaction_id,
                       strlen (transaction_id),
@@ -372,7 +383,7 @@ run (void *cls)
 
   FAILIF (GNUNET_OK !=
           plugin->store_transaction (plugin->cls,
-                                     transaction_id,
+                                     &h_proposal_data,
                                     &merchant_pub,
                                      EXCHANGE_URI,
                                      &h_wire,
@@ -381,7 +392,7 @@ run (void *cls)
                                      &amount_with_fee));
   FAILIF (GNUNET_OK !=
           plugin->store_deposit (plugin->cls,
-                                 transaction_id,
+                                 &h_proposal_data,
                                 &merchant_pub,
                                  &coin_pub,
                                  &amount_with_fee,
@@ -390,7 +401,7 @@ run (void *cls)
                                  deposit_proof));
   FAILIF (GNUNET_OK !=
           plugin->store_coin_to_transfer (plugin->cls,
-                                          transaction_id,
+                                          &h_proposal_data,
                                           &coin_pub,
                                           &wtid));
   FAILIF (GNUNET_OK !=
@@ -402,7 +413,7 @@ run (void *cls)
                                            transfer_proof));
   FAILIF (GNUNET_OK !=
           plugin->find_transaction (plugin->cls,
-                                    transaction_id,
+                                    &h_proposal_data,
                                    &merchant_pub,
                                     &transaction_cb,
                                     NULL));
@@ -416,13 +427,13 @@ run (void *cls)
 
   FAILIF (GNUNET_OK !=
           plugin->find_payments (plugin->cls,
-                                 transaction_id,
+                                 &h_proposal_data,
                                  &merchant_pub,
                                  &deposit_cb,
                                  NULL));
   FAILIF (GNUNET_OK !=
-          plugin->find_transfers_by_id (plugin->cls,
-                                        transaction_id,
+          plugin->find_transfers_by_hash (plugin->cls,
+                                        &h_proposal_data,
                                         &transfer_cb,
                                         NULL));
   FAILIF (GNUNET_OK !=
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 8f56986..06f1c56 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -219,7 +219,7 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*store_deposit) (void *cls,
-                    const char *transaction_id,
+                    const struct GNUNET_HashCode *h_proposal_data,
                     const struct TALER_MerchantPublicKeyP *merchant_pub,
                     const struct TALER_CoinSpendPublicKeyP *coin_pub,
                     const struct TALER_Amount *amount_with_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]