aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/taler_amount_lib.h15
-rw-r--r--src/include/taler_util_wallet.h16
-rw-r--r--src/mintdb/Makefile.am4
-rw-r--r--src/mintdb/perf/perf_taler_mintdb_init.c87
-rw-r--r--src/mintdb/perf/perf_taler_mintdb_init.h12
-rw-r--r--src/mintdb/perf/perf_taler_mintdb_interpreter.c58
-rw-r--r--src/mintdb/perf/perf_taler_mintdb_interpreter.h37
7 files changed, 131 insertions, 98 deletions
diff --git a/src/include/taler_amount_lib.h b/src/include/taler_amount_lib.h
index 06549bac1..0a7111003 100644
--- a/src/include/taler_amount_lib.h
+++ b/src/include/taler_amount_lib.h
@@ -21,6 +21,14 @@
#ifndef TALER_AMOUNT_LIB_H
#define TALER_AMOUNT_LIB_H
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
/**
* @brief Number of characters (plus 1 for 0-termination) we use to
@@ -249,5 +257,12 @@ TALER_amount_normalize (struct TALER_Amount *amount);
char *
TALER_amount_to_string (const struct TALER_Amount *amount);
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/include/taler_util_wallet.h b/src/include/taler_util_wallet.h
index 275c9daf6..4699a469d 100644
--- a/src/include/taler_util_wallet.h
+++ b/src/include/taler_util_wallet.h
@@ -25,6 +25,14 @@
#include "taler_crypto_lib.h"
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
/* Define logging functions */
#define TALER_LOG_DEBUG(...) \
@@ -86,4 +94,12 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg,
struct TALER_Amount *denom);
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+
#endif
diff --git a/src/mintdb/Makefile.am b/src/mintdb/Makefile.am
index 783b87b26..57aa03b93 100644
--- a/src/mintdb/Makefile.am
+++ b/src/mintdb/Makefile.am
@@ -59,7 +59,7 @@ test_mintdb_deposits_LDADD = \
$(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil \
-ljansson \
- -lpq
+ -lpq
test_mintdb_keyio_SOURCES = \
test_mintdb_keyio.c
@@ -67,7 +67,7 @@ test_mintdb_keyio_LDADD = \
libtalermintdb.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
- -lgnunetutil
+ -lgnunetutil
test_mintdb_postgres_SOURCES = \
test_mintdb.c
diff --git a/src/mintdb/perf/perf_taler_mintdb_init.c b/src/mintdb/perf/perf_taler_mintdb_init.c
index 31be2b1bd..724717ffb 100644
--- a/src/mintdb/perf/perf_taler_mintdb_init.c
+++ b/src/mintdb/perf/perf_taler_mintdb_init.c
@@ -10,28 +10,35 @@
#define CURRENCY "EUR\0\0\0\0\0\0\0\0"
struct TALER_MINTDB_CollectableBlindcoin *
-init_CollectableBlindcoin(){
- struct TALER_MINTDB_CollectableBlindcoin *coin = GNUNET_malloc(sizeof(*coin));
-
- struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create();
- struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key = GNUNET_CRYPTO_rsa_private_key_create(512);
-
-
- coin->denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public(denomination_key);
- GNUNET_CRYPTO_eddsa_key_get_public(reserve_sig_key, &(coin->reserve_pub.eddsa_pub));
-
-
+init_CollectableBlindcoin ()
+{
+ // indent by 2 spaces
+ struct TALER_MINTDB_CollectableBlindcoin *coin = GNUNET_new (*coin);
+
+ struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ();
+ struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key = GNUNET_CRYPTO_rsa_private_key_create (512);
+
+
+ coin->denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key);
+ GNUNET_CRYPTO_eddsa_key_get_public (reserve_sig_key,
+ &coin->reserve_pub.eddsa_pub);
+
+
//TODO Randomise the amount that is deposited and apply a fee subsequently
-
+
+ // GNUNET_assert (GNUNET_OK ==
+ // TALER_string_to_amount (CURRENCY ":1.1",
+ // &coin->amount_with_fee));
+
coin->amount_with_fee = (struct TALER_Amount) {1, 1, CURRENCY};
coin->withdraw_fee = (struct TALER_Amount) {0, 1, CURRENCY};
- int random_int = rand();
+ int random_int = rand(); // GNUNET_CRYPTO_random_u32
coin->sig.rsa_signature = GNUNET_CRYPTO_rsa_sign(denomination_key, &random_int, sizeof(random_int));
- GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK , &(coin->h_coin_envelope));
+ GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &coin->h_coin_envelope);
- void *purpose = GNUNET_malloc(sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof(int));
+ void *purpose = GNUNET_malloc (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof(int));
((struct GNUNET_CRYPTO_EccSignaturePurpose *)purpose)->size = sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof(int);
((struct GNUNET_CRYPTO_EccSignaturePurpose *)purpose)->purpose = GNUNET_SIGNATURE_PURPOSE_TEST;
*((int *)(purpose + sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose))) = random_int;
@@ -39,7 +46,7 @@ init_CollectableBlindcoin(){
GNUNET_CRYPTO_eddsa_sign(reserve_sig_key, purpose, &coin->reserve_sig.eddsa_signature);
-
+
GNUNET_free(reserve_sig_key);
GNUNET_CRYPTO_rsa_private_key_free(denomination_key);
return coin;
@@ -52,11 +59,11 @@ init_Reserve(){
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_priv = GNUNET_CRYPTO_eddsa_key_create();
GNUNET_CRYPTO_eddsa_key_get_public(reserve_priv , &(reserve->pub.eddsa_pub));
-
+
reserve->balance = (struct TALER_Amount){1, 1, CURRENCY};
reserve->expiry = GNUNET_TIME_absolute_get_forever_();
-
+
GNUNET_free(reserve_priv);
return reserve;
}
@@ -82,7 +89,7 @@ init_Deposit(){
deposit-> transaction_id = transaction_id;
transaction_id++;
-
+
//TODO Randomize the amount that is deposited
@@ -94,11 +101,11 @@ init_Deposit(){
GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &deposit->h_contract);
GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &deposit->h_wire);
-
+
// Coin Spend Signature
{
struct GNUNET_CRYPTO_EddsaSignature sig;
-
+
struct GNUNET_CRYPTO_EddsaPrivateKey *p_eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create();
void *prp = GNUNET_malloc(sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)+sizeof(int));
*((struct GNUNET_CRYPTO_EccSignaturePurpose *)prp) =(struct GNUNET_CRYPTO_EccSignaturePurpose) {sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)+sizeof(int), GNUNET_SIGNATURE_PURPOSE_TEST};
@@ -117,45 +124,45 @@ init_Deposit(){
struct GNUNET_CRYPTO_EddsaPrivateKey *p_eddsa_prv = GNUNET_CRYPTO_eddsa_key_create();
GNUNET_CRYPTO_eddsa_key_get_public(p_eddsa_prv, &eddsa_pub);
-
+
deposit->merchant_pub.eddsa_pub = eddsa_pub;
-
+
GNUNET_free(p_eddsa_prv);
}
- // Coin
+ // Coin
{
-
+
{
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
struct GNUNET_CRYPTO_EddsaPrivateKey *p_eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create();
-
+
GNUNET_CRYPTO_eddsa_key_get_public(p_eddsa_prvt, &eddsa_pub);
-
+
deposit->coin.coin_pub.eddsa_pub = eddsa_pub;
-
+
GNUNET_free(p_eddsa_prvt);
}
{
struct GNUNET_CRYPTO_rsa_PrivateKey *p_rsa_prv = GNUNET_CRYPTO_rsa_private_key_create(128);
struct GNUNET_CRYPTO_rsa_PublicKey *p_rsa_pub = GNUNET_CRYPTO_rsa_private_key_get_public(p_rsa_prv);
-
+
deposit->coin.denom_pub.rsa_public_key = p_rsa_pub;
-
-
- deposit->coin.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_sign(p_rsa_prv,
- (void *) &(deposit->coin.coin_pub.eddsa_pub),
+
+
+ deposit->coin.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_sign(p_rsa_prv,
+ (void *) &(deposit->coin.coin_pub.eddsa_pub),
sizeof(&(deposit->coin.coin_pub.eddsa_pub)));
GNUNET_CRYPTO_rsa_private_key_free(p_rsa_prv);
- }
+ }
}
-
+
return deposit;
}
@@ -173,7 +180,7 @@ init_denomination(){
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
&dki->issue.denom_hash);
- struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt =
+ struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt =
GNUNET_CRYPTO_eddsa_key_create();
struct GNUNET_CRYPTO_EddsaPublicKey master_pub;
@@ -225,7 +232,7 @@ int
free_deposit(struct TALER_MINTDB_Deposit *deposit){
GNUNET_free(deposit->coin.denom_pub.rsa_public_key);
GNUNET_free(deposit->coin.denom_sig.rsa_signature);
-
+
GNUNET_free(deposit);
return GNUNET_OK;
@@ -249,10 +256,6 @@ free_denomination(struct TALER_MINTDB_DenominationKeyIssueInformation *dki){
GNUNET_free(dki->denom_pub.rsa_public_key);
GNUNET_free(dki);
-
+
return GNUNET_OK;
}
-
-
-
-
diff --git a/src/mintdb/perf/perf_taler_mintdb_init.h b/src/mintdb/perf/perf_taler_mintdb_init.h
index 37a9ccbb8..d17929a94 100644
--- a/src/mintdb/perf/perf_taler_mintdb_init.h
+++ b/src/mintdb/perf/perf_taler_mintdb_init.h
@@ -8,20 +8,20 @@
#include <taler/taler_mintdb_plugin.h>
-#define CURRENCY "EUR\0\0\0\0\0\0\0\0"
+#define CURRENCY "EUR"
struct TALER_MINTDB_CollectableBlindcoin *
-init_collectableBlindcoin();
+init_collectable_blindcoin(void);
struct TALER_MINTDB_RefreshSession *
-init_refresh_session();
+init_refresh_session(void);
struct TALER_MINTDB_Deposit *
init_deposit(int transaction_id);
struct TALER_MINTDB_DenominationKeyIssueInformation *
-init_denomination();
+init_denomination(void);
@@ -29,9 +29,9 @@ int
free_deposit(struct TALER_MINTDB_Deposit *deposit);
int
-free_collectableBlindcoin(struct TALER_MINTDB_CollectableBlindcoin);
+free_collectable_blindcoin(struct TALER_MINTDB_CollectableBlindcoin *NAME);
-int
+int
free_denomination(struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
diff --git a/src/mintdb/perf/perf_taler_mintdb_interpreter.c b/src/mintdb/perf/perf_taler_mintdb_interpreter.c
index 9c26c70f4..93c49b9c0 100644
--- a/src/mintdb/perf/perf_taler_mintdb_interpreter.c
+++ b/src/mintdb/perf/perf_taler_mintdb_interpreter.c
@@ -8,26 +8,18 @@
/**
* Finds the first command in cmd with the name search
*
- * \return the index of the first command with name search
+ * \return the index of the first command with name search
* GNUNET_SYSERR if none found
*/
static int
cmd_find(const struct PERF_TALER_MINTDB_CMD *cmd, const char *search)
{
- int i = 0;
- while (0)
- {
- if (cmd[i].command == CMD_END)
- {
- return GNUNET_SYSERR;
- }
+ int i;
- if (0 != strcmp(cmd[i].name, search))
- {
+ for (i=0; CMD_END != cmd[i].command; i++)
+ if (0 == strcmp (cmd[i].name, search))
return i;
- }
- i++;
- }
+ return GNUNET_SYSERR;
}
@@ -36,22 +28,21 @@ cmd_find(const struct PERF_TALER_MINTDB_CMD *cmd, const char *search)
cmd_init(struct PERF_TALER_MINTDB_CMD cmd[])
{
int i = 0;
- while (cmd[i].command != CMD_END)
+ while (CMD_END != cmd[i].command)
{
switch (cmd[i].command)
{
case CMD_SAVE_ARRAY:
-
// Initialization is done differently depending of the type saved
- switch (cmd[i].details.save_array.saved_type)
+ switch (cmd[i].details.save_array.saved_type)
{
- case DEPOSIT:
- cmd[i].details.save_array.saved_data.deposit =
+ case DEPOSIT:
+ cmd[i].details.save_array.saved_data.deposit =
GNUNET_malloc(cmd[i].details.save_array.nb*
sizeof(*cmd[i].details.save_array.saved_data.deposit));
break;
case TIME:
- cmd[i].details.save_array.saved_data.time =
+ cmd[i].details.save_array.saved_data.time =
GNUNET_malloc(cmd[i].details.save_array.nb*
sizeof(*cmd[i].details.save_array.saved_data.time));
@@ -61,9 +52,9 @@ cmd_init(struct PERF_TALER_MINTDB_CMD cmd[])
break;
case CMD_LOAD_ARRAY:
- cmd[i].details.load_array.permutation =
+ cmd[i].details.load_array.permutation =
GNUNET_CRYPTO_random_permute(
- GNUNET_CRYPTO_QUALITY_WEAK,
+ GNUNET_CRYPTO_QUALITY_WEAK,
cmd[i].details.load_array.nb);
break;
default:
@@ -129,7 +120,7 @@ cmd_clean(struct PERF_TALER_MINTDB_CMD cmd[])
/**
- *
+ *
*/
static int
interprete(struct TALER_MINTDB_Plugin *db_plugin,
@@ -142,7 +133,6 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
{
case CMD_END:
return GNUNET_YES;
- break;
case CMD_LOOP:
cmd[i].details.loop.curr_iteration++;
@@ -171,7 +161,7 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
default:
break;
- }
+ }
}
}
}
@@ -210,7 +200,7 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
case CMD_INSERT_DEPOSIT:
{
struct TALER_MINTDB_Deposit *deposit = init_deposit(0);
- db_plugin->insert_deposit(db_plugin->cls, session, deposit);
+ db_plugin->insert_deposit(db_plugin->cls, session, deposit);
cmd[i].exposed.deposit = deposit;
}
@@ -238,8 +228,8 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
int proba = cmd[loop_index].details.loop.max_iterations / cmd[i].details.save_array.nb;
int rnd = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, proba);
- // If there is a lesser or equal number of iteration next than room remain in the array
- if ((cmd[loop_index].details.loop.max_iterations - cmd[loop_index].details.loop.curr_iteration <=
+ // If there is a lesser or equal number of iteration next than room remain in the array
+ if ((cmd[loop_index].details.loop.max_iterations - cmd[loop_index].details.loop.curr_iteration <=
cmd[i].details.save_array.nb - cmd[i].details.save_array.index) ||
(rnd == 0 && cmd[i].details.save_array.index < cmd[i].details.save_array.nb))
{
@@ -247,11 +237,11 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
// We automaticly save the whatever we need to
switch (cmd[i].details.save_array.saved_type){
case DEPOSIT:
- cmd[i].details.save_array.saved_data.deposit[cmd[i].details.save_array.index] =
+ cmd[i].details.save_array.saved_data.deposit[cmd[i].details.save_array.index] =
cmd[cmd_find(cmd, cmd[i].details.save_array.saved)].exposed.deposit;
break;
case TIME:
- cmd[i].details.save_array.saved_data.deposit[cmd[i].details.save_array.index] =
+ cmd[i].details.save_array.saved_data.deposit[cmd[i].details.save_array.index] =
cmd[cmd_find(cmd, cmd[i].details.save_array.saved)].exposed.deposit;
break;
}
@@ -264,8 +254,8 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
case CMD_LOAD_ARRAY:
{
- int loop_index = cmd_find(cmd, cmd[i].details.load_array.loop);
- int save_index = cmd_find(cmd, cmd[i].details.load_array.saved);
+ int loop_index = cmd_find(cmd, cmd[i].details.load_array.loop);
+ int save_index = cmd_find(cmd, cmd[i].details.load_array.saved);
switch (cmd[i].details.load_array.loaded_type){
case DEPOSIT:
cmd[i].exposed.deposit = cmd[save_index].details.save_array.saved_data.deposit[
@@ -294,11 +284,11 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
}
/**
- * Runs the commands given in cmd, working with
- * the database referenced by db_plugin
+ * Runs the commands given in @a cmd, working with
+ * the database referenced by @a db_plugin
*/
int
-PERF_TALER_MINTDB_interprete(struct TALER_MINTDB_Plugin *db_plugin,
+PERF_TALER_MINTDB_interprete(struct TALER_MINTDB_Plugin *db_plugin,
struct TALER_MINTDB_Session *session,
struct PERF_TALER_MINTDB_CMD cmd[])
{
diff --git a/src/mintdb/perf/perf_taler_mintdb_interpreter.h b/src/mintdb/perf/perf_taler_mintdb_interpreter.h
index c39cfd584..a201fd4a8 100644
--- a/src/mintdb/perf/perf_taler_mintdb_interpreter.h
+++ b/src/mintdb/perf/perf_taler_mintdb_interpreter.h
@@ -8,12 +8,18 @@
#include <taler/taler_mintdb_plugin.h>
+#define INIT_CMD_END(label) {.command = CMD_END, .name = label}
-#define INIT_CMD_LOOP(label, _iter) {.command = CMD_LOOP, .name = label, .details.loop = {.max_iterations = _iter, .curr_iteration = -1} }
+#define INIT_CMD_LOOP(label, _iter) { \
+ .command = CMD_LOOP, \
+ .name = label, \
+ .details.loop = { \
+ .max_iterations = _iter, \
+ .curr_iteration = -1} \
+ }
#define INIT_CMD_END_LOOP(label, _loopname) {.command = CMD_END_LOOP, .name = label, .details.end_loop.loop_start = _loopname}
-#define INIT_CMD_END(label) {.command = CMD_END, .name = label}
#define INIT_CMD_GET_TIME(label) {.command = CMD_GET_TIME, .name = label}
@@ -82,7 +88,7 @@ struct PERF_TALER_MINTDB_CMD{
} command;
- char name[40];
+ const char *name; // label!
// Contains command specific data.
union {
@@ -100,25 +106,28 @@ struct PERF_TALER_MINTDB_CMD{
char stop_time[40];
char description[40];
- } gauger;
+ } gauger;
struct {
- int nb; // Number of deposits to save
- int index; // The number of deposits already saved
+ /**
+ * Comment!
+ */
+ unsigned int nb; // Number of deposits to save
+ unsigned int index; // The number of deposits already saved
char loop[40]; // The loop from which the data will be extracted
char saved[40]; // The deposit saved
enum PERF_TALER_MINTDB_TYPE saved_type;
- union {
- struct TALER_MINTDB_Deposit **deposit;
- struct timespec *time;
- } saved_data;
+ union NAME_IT_TOP_LEVEL {
+ struct TALER_MINTDB_Deposit *deposit;
+ struct timespec time;
+ } *samples;
} save_array;
struct {
int nb; //the number of deposits to save
char loop[40];
char saved[40]; // The command where the deposit were saved
- enum PERF_TALER_MINTDB_TYPE loaded_type;
+ enum PERF_TALER_MINTDB_TYPE loaded_type;
unsigned int *permutation; // A permutation array to randomize the order the deposits are loaded in
} load_array;
@@ -128,10 +137,10 @@ struct PERF_TALER_MINTDB_CMD{
} details;
- union {
+ union NAME_IT_TOP_LEVEL {
struct TALER_MINTDB_Deposit *deposit;
struct timespec time;
- } exposed;
+ } exposed;
int exposed_used;
};
@@ -140,7 +149,7 @@ struct PERF_TALER_MINTDB_CMD{
int
PERF_TALER_MINTDB_interprete(
struct TALER_MINTDB_Plugin *db_plugin,
- struct TALER_MINTDB_Session *session,
+ struct TALER_MINTDB_Session *session, // add START_SESSION CMD
struct PERF_TALER_MINTDB_CMD cmd[]);