summaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-04-20 01:50:26 +0200
committerChristian Grothoff <christian@grothoff.org>2016-04-20 01:50:26 +0200
commitf693e25793f9e8f75b80b11b066ed209e8aa4c1c (patch)
tree07bd275d003080389d67ed142b7673bab469c40f /src/exchangedb
parent1d8da4bf8442e4864e877a665c876d0cd5e03de8 (diff)
downloadexchange-f693e25793f9e8f75b80b11b066ed209e8aa4c1c.tar.gz
exchange-f693e25793f9e8f75b80b11b066ed209e8aa4c1c.tar.bz2
exchange-f693e25793f9e8f75b80b11b066ed209e8aa4c1c.zip
introduce refund fee
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/perf_taler_exchangedb.c3
-rw-r--r--src/exchangedb/perf_taler_exchangedb_init.c4
-rw-r--r--src/exchangedb/perf_taler_exchangedb_init.h25
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c20
-rw-r--r--src/exchangedb/test_exchangedb.c25
5 files changed, 49 insertions, 28 deletions
diff --git a/src/exchangedb/perf_taler_exchangedb.c b/src/exchangedb/perf_taler_exchangedb.c
index 6ff7f5331..bac8f4cb8 100644
--- a/src/exchangedb/perf_taler_exchangedb.c
+++ b/src/exchangedb/perf_taler_exchangedb.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014, 2015 GNUnet e.V.
+ Copyright (C) 2014, 2015, 2016 Inria and GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -17,6 +17,7 @@
* @file exchangedb/perf_taler_exchangedb.c
* @brief Exchange database performance analysis
* @author Nicolas Fournier
+ * @author Christian Grothoff
*/
#include "platform.h"
#include "perf_taler_exchangedb_interpreter.h"
diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c
index 516f3ea58..67ac56c77 100644
--- a/src/exchangedb/perf_taler_exchangedb_init.c
+++ b/src/exchangedb/perf_taler_exchangedb_init.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014, 2015 GNUnet e.V.
+ Copyright (C) 2014, 2015, 2016 Inria & GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -17,6 +17,7 @@
* @file exchangedb/perf_taler_exchangedb_init.c
* @brief Interpreter library for exchange database performance analysis
* @author Nicolas Fournier
+ * @author Christian Grothoff
*/
#include "platform.h"
#include "perf_taler_exchangedb_init.h"
@@ -75,6 +76,7 @@ PERF_TALER_EXCHANGEDB_denomination_init ()
TALER_amount_hton (&properties.fee_withdraw, &amount);
TALER_amount_hton (&properties.fee_deposit, &amount);
TALER_amount_hton (&properties.fee_refresh, &amount);
+ TALER_amount_hton (&properties.fee_refund, &amount);
GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key,
&properties.denom_hash);
issue.properties = properties;
diff --git a/src/exchangedb/perf_taler_exchangedb_init.h b/src/exchangedb/perf_taler_exchangedb_init.h
index 0ff074108..2021023a1 100644
--- a/src/exchangedb/perf_taler_exchangedb_init.h
+++ b/src/exchangedb/perf_taler_exchangedb_init.h
@@ -79,8 +79,7 @@ PERF_TALER_EXCHANGEDB_denomination_init (void);
* @return a copy of @a deposit; NULL if error
*/
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
-PERF_TALER_EXCHANGEDB_denomination_copy (
- const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki);
+PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki);
/**
@@ -88,8 +87,7 @@ PERF_TALER_EXCHANGEDB_denomination_copy (
* @param dki pointer to the struct to free
*/
int
-PERF_TALER_EXCHANGEDB_denomination_free (
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki);
+PERF_TALER_EXCHANGEDB_denomination_free (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki);
/**
@@ -122,8 +120,7 @@ PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserv
* @param dki the denomination key used to sign the key
*/
struct TALER_EXCHANGEDB_Deposit *
-PERF_TALER_EXCHANGEDB_deposit_init (
- const struct PERF_TALER_EXCHANGEDB_Coin *coin);
+PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coin);
/**
@@ -150,9 +147,8 @@ PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit);
* @return a randomly generated CollectableBlindcoin
*/
struct PERF_TALER_EXCHANGEDB_Coin *
-PERF_TALER_EXCHANGEDB_coin_init (
- const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki,
- const struct PERF_TALER_EXCHANGEDB_Reserve *reserve);
+PERF_TALER_EXCHANGEDB_coin_init (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki,
+ const struct PERF_TALER_EXCHANGEDB_Reserve *reserve);
/**
@@ -161,8 +157,7 @@ PERF_TALER_EXCHANGEDB_coin_init (
* @return a copy of coin; NULL if error
*/
struct PERF_TALER_EXCHANGEDB_Coin *
-PERF_TALER_EXCHANGEDB_coin_copy (
- const struct PERF_TALER_EXCHANGEDB_Coin *coin);
+PERF_TALER_EXCHANGEDB_coin_copy (const struct PERF_TALER_EXCHANGEDB_Coin *coin);
/**
@@ -170,8 +165,7 @@ PERF_TALER_EXCHANGEDB_coin_copy (
* @param coin pointer to the structure to free
*/
int
-PERF_TALER_EXCHANGEDB_coin_free (
- struct PERF_TALER_EXCHANGEDB_Coin *coin);
+PERF_TALER_EXCHANGEDB_coin_free (struct PERF_TALER_EXCHANGEDB_Coin *coin);
/**
@@ -186,15 +180,14 @@ PERF_TALER_EXCHANGEDB_refresh_session_init (void);
*/
int
PERF_TALER_EXCHANGEDB_refresh_session_copy (struct TALER_EXCHANGEDB_RefreshSession *session,
- struct TALER_EXCHANGEDB_RefreshSession *copy);
+ struct TALER_EXCHANGEDB_RefreshSession *copy);
/**
* Frees memory of a refresh_session
*/
int
-PERF_TALER_EXCHANGEDB_refresh_session_free (
- struct TALER_EXCHANGEDB_RefreshSession *refresh_session);
+PERF_TALER_EXCHANGEDB_refresh_session_free (struct TALER_EXCHANGEDB_RefreshSession *refresh_session);
/**
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 092aebc48..d69fa7d61 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -272,6 +272,9 @@ postgres_create_tables (void *cls,
",fee_refresh_val INT8 NOT NULL"
",fee_refresh_frac INT4 NOT NULL"
",fee_refresh_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
+ ",fee_refund_val INT8 NOT NULL"
+ ",fee_refund_frac INT4 NOT NULL"
+ ",fee_refund_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
")");
/* reserves table is for summarization of a reserve. It is updated when new
funds are added and existing funds are withdrawn. The 'expiration_date'
@@ -544,10 +547,14 @@ postgres_prepare (PGconn *db_conn)
",fee_refresh_val"
",fee_refresh_frac"
",fee_refresh_curr" /* must match coin_curr */
+ ",fee_refund_val"
+ ",fee_refund_frac"
+ ",fee_refund_curr" /* must match coin_curr */
") VALUES "
"($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
- " $11, $12, $13, $14, $15, $16, $17, $18, $19);",
- 19, NULL);
+ " $11, $12, $13, $14, $15, $16, $17, $18,"
+ " $19, $20, $21, $22);",
+ 22, NULL);
/* Used in #postgres_get_denomination_info() */
PREPARE ("denomination_get",
@@ -570,6 +577,9 @@ postgres_prepare (PGconn *db_conn)
",fee_refresh_val"
",fee_refresh_frac"
",fee_refresh_curr" /* must match coin_curr */
+ ",fee_refund_val"
+ ",fee_refund_frac"
+ ",fee_refund_curr" /* must match coin_curr */
" FROM denominations"
" WHERE pub=$1;",
1, NULL);
@@ -1378,6 +1388,7 @@ postgres_insert_denomination_info (void *cls,
TALER_PQ_query_param_amount_nbo (&issue->properties.fee_withdraw),
TALER_PQ_query_param_amount_nbo (&issue->properties.fee_deposit),
TALER_PQ_query_param_amount_nbo (&issue->properties.fee_refresh),
+ TALER_PQ_query_param_amount_nbo (&issue->properties.fee_refund),
GNUNET_PQ_query_param_end
};
/* check fees match coin currency */
@@ -1390,6 +1401,9 @@ postgres_insert_denomination_info (void *cls,
GNUNET_assert (GNUNET_YES ==
TALER_amount_cmp_currency_nbo (&issue->properties.value,
&issue->properties.fee_refresh));
+ GNUNET_assert (GNUNET_YES ==
+ TALER_amount_cmp_currency_nbo (&issue->properties.value,
+ &issue->properties.fee_refund));
result = GNUNET_PQ_exec_prepared (session->conn,
"denomination_insert",
@@ -1476,6 +1490,8 @@ postgres_get_denomination_info (void *cls,
&issue->properties.fee_deposit),
TALER_PQ_result_spec_amount_nbo ("fee_refresh",
&issue->properties.fee_refresh),
+ TALER_PQ_result_spec_amount_nbo ("fee_refund",
+ &issue->properties.fee_refund),
GNUNET_PQ_result_spec_end
};
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index f2c473fd9..3bb9b9f2c 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -16,7 +16,8 @@
/**
* @file exchangedb/test_exchangedb.c
* @brief test cases for DB interaction functions
- * @author Sree Harsha Totakura <sreeharsha@totakura.in>
+ * @author Sree Harsha Totakura
+ * @author Christian Grothoff
*/
#include "platform.h"
#include "taler_exchangedb_lib.h"
@@ -114,7 +115,8 @@ create_denom_key_pair (unsigned int size,
const struct TALER_Amount *value,
const struct TALER_Amount *fee_withdraw,
const struct TALER_Amount *fee_deposit,
- const struct TALER_Amount *fee_refresh)
+ const struct TALER_Amount *fee_refresh,
+ const struct TALER_Amount *fee_refund)
{
struct DenomKeyPair *dkp;
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation dki;
@@ -147,6 +149,7 @@ create_denom_key_pair (unsigned int size,
TALER_amount_hton (&dki.issue.properties.fee_withdraw, fee_withdraw);
TALER_amount_hton (&dki.issue.properties.fee_deposit, fee_deposit);
TALER_amount_hton (&dki.issue.properties.fee_refresh, fee_refresh);
+ TALER_amount_hton (&dki.issue.properties.fee_refund, fee_refund);
GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key,
&dki.issue.properties.denom_hash);
if (GNUNET_OK !=
@@ -166,11 +169,11 @@ static struct TALER_Amount value;
static struct TALER_Amount fee_withdraw;
static struct TALER_Amount fee_deposit;
static struct TALER_Amount fee_refresh;
+static struct TALER_Amount fee_refund;
static struct TALER_Amount amount_with_fee;
static void
-free_refresh_commit_coins_array(struct TALER_EXCHANGEDB_RefreshCommitCoin
- *commit_coins,
+free_refresh_commit_coins_array(struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins,
unsigned int size)
{
unsigned int cnt;
@@ -205,7 +208,7 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session,
uint16_t cnc_index;
int ret;
- #define COIN_ENC_MAX_SIZE 512
+#define COIN_ENC_MAX_SIZE 512
ret = GNUNET_SYSERR;
ret_commit_coins = NULL;
commit_coins = GNUNET_new_array (MELT_NEW_COINS,
@@ -331,7 +334,8 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
&value,
&fee_withdraw,
&fee_deposit,
- &fee_refresh);
+ &fee_refresh,
+ &fee_refund);
/* create MELT_OLD_COINS number of refresh melts */
melts = GNUNET_new_array (MELT_OLD_COINS, struct TALER_EXCHANGEDB_RefreshMelt);
for (cnt=0; cnt < MELT_OLD_COINS; cnt++)
@@ -394,7 +398,8 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
&value,
&fee_withdraw,
&fee_deposit,
- &fee_refresh);
+ &fee_refresh,
+ &fee_refund);
new_denom_pubs[cnt]=new_dkp[cnt]->pub;
}
FAILIF (GNUNET_OK != plugin->insert_refresh_order (plugin->cls,
@@ -684,6 +689,9 @@ run (void *cls)
TALER_string_to_amount (CURRENCY ":0.000010",
&fee_refresh));
GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":0.000010",
+ &fee_refund));
+ GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.000010",
&amount_with_fee));
@@ -723,7 +731,8 @@ run (void *cls)
&value,
&fee_withdraw,
&fee_deposit,
- &fee_refresh);
+ &fee_refresh,
+ &fee_refund);
RND_BLK(&cbc.h_coin_envelope);
RND_BLK(&cbc.reserve_sig);
cbc.denom_pub = dkp->pub;