gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated: inserting refunds i


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: inserting refunds into their table, not tested
Date: Mon, 12 Jun 2017 17:31:12 +0200

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

marcello pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 19a4be3  inserting refunds into their table, not tested
19a4be3 is described below

commit 19a4be39533abf14a670d1076b9028e61ee402b1
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Jun 12 17:31:10 2017 +0200

    inserting refunds into their table, not tested
---
 src/backenddb/plugin_merchantdb_postgres.c | 56 +++++++++++++++++++++++-------
 1 file changed, 44 insertions(+), 12 deletions(-)

diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index d814f6f..4480b5b 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -236,7 +236,7 @@ postgres_initialize (void *cls)
                             ",PRIMARY KEY (order_id, merchant_pub)"
                             ");"),
     GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS merchant_refunds ("
-                            " rtransaction_id INT8 NOT NULL"
+                            " rtransaction_id BIGSERIAL"
                             ",h_contract_terms BYTEA NOT NULL"
                             ",coin_pub BYTEA NOT NULL CHECK 
(LENGTH(coin_pub)=32)"
                             ",reason VARCHAR NOT NULL"
@@ -337,6 +337,16 @@ postgres_initialize (void *cls)
                             ",wtid) VALUES "
                             "($1, $2, $3)",
                             3),
+    GNUNET_PQ_make_prepare ("insert_refund",
+                            "INSERT INTO merchant_refunds"
+                            "(h_contract_terms"
+                            ",coin_pub"
+                            ",reason"
+                            "refund_amount_val"
+                            "refund_amount_frac"
+                            "refund_amount_curr) VALUES"
+                            "($1, $2, $3, $4, $5, $6)",
+                            6),
     GNUNET_PQ_make_prepare ("insert_proof",
                             "INSERT INTO merchant_proofs"
                             "(exchange_uri"
@@ -1787,6 +1797,38 @@ struct InsertRefundContext
 
 
 /**
+ * Insert a refund row into merchant_refunds.  Not meant to be exported
+ * in the db API.
+ *
+ * @param cls closure, tipically a connection to the db
+ * @param h_contract_terms hashcode of the contract related to this refund
+ * @param coin_pub public key of the coin giving the (part of) refund
+ * @param reason human readable explaination behind the refund
+ * @param refund how much this coin is refunding
+ */
+enum GNUNET_DB_QueryStatus
+insert_refund (void *cls,
+               const struct GNUNET_HashCode *h_contract_terms,
+               const struct TALER_CoinSpendPublicKeyP *coin_pub,
+               const char *reason,
+               const struct TALER_Amount *refund)
+{
+  struct PostgresClosure *pg = cls;
+  
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
+    GNUNET_PQ_query_param_auto_from_type (coin_pub),
+    GNUNET_PQ_query_param_string (reason),
+    TALER_PQ_query_param_amount (refund),
+    GNUNET_PQ_query_param_end
+  };
+  
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "insert_refund",
+                                             params);
+}
+
+/**
  * Function to be called with the results of a SELECT statement
  * that has returned @a num_results results.
  *
@@ -1850,16 +1892,6 @@ process_deposits_cb (void *cls,
     if (GNUNET_DB_STATUS_SOFT_ERROR == ires)
       goto rollback; // FIXME: #5010: actually rollback + retry!
 
-    /**
-     * FIXME:
-     * Here we know how much the coin is worth, and how much it has
-     * been refunded out of it, so the actual logic can take place.
-     *
-     * Need:
-     * 1 a "insert refund" function
-     * 2 logic to abort the operation
-     */
-
     /*How much coin i will give for refund: needed by merchant_refunds table*/
     if (GNUNET_SYSERR == TALER_amount_subtract (&diff, // to commit as refund
                                                 &amount_with_fee,
@@ -1927,7 +1959,7 @@ process_deposits_cb (void *cls,
     if (-1 == TALER_amount_cmp (big, small))
     {
       big = &diff;
-      small - &ctx->refund;
+      small = &ctx->refund;
     }
     if (GNUNET_SYSERR == TALER_amount_subtract (big,
                                                 big,

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



reply via email to

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