summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mintdb/perf_taler_mintdb.c11
-rw-r--r--src/mintdb/perf_taler_mintdb_init.c13
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.c96
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.h6
4 files changed, 36 insertions, 90 deletions
diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c
index c7e8c355..040a473f 100644
--- a/src/mintdb/perf_taler_mintdb.c
+++ b/src/mintdb/perf_taler_mintdb.c
@@ -33,27 +33,30 @@ main (int argc, char ** argv)
struct GNUNET_CONFIGURATION_Handle *config;
struct PERF_TALER_MINTDB_Cmd test[] =
{
- PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit",100000),
+ PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit",10),
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_init"),
PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("init_deposit_insert"),
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"),
- PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit","loop_db_init_deposit"),
+ PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("array_depo", "loop_db_init_deposit", "init_deposit_insert", 10, PERF_TALER_MINTDB_DEPOSIT),
+ PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit",
+ "loop_db_init_deposit"),
PERF_TALER_MINTDB_INIT_CMD_END("end")
};
-
+ // Plugin init
config = GNUNET_CONFIGURATION_create();
GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf");
GNUNET_assert (NULL !=
(plugin = TALER_MINTDB_plugin_load (config)));
plugin->create_tables (plugin->cls, GNUNET_YES);
+ // Run command
PERF_TALER_MINTDB_interpret(plugin, test);
+ // Drop tables
{
struct TALER_MINTDB_Session *session;
session = plugin->get_session (plugin->cls, GNUNET_YES);
plugin->drop_temporary (plugin->cls, session);
}
-
TALER_MINTDB_plugin_unload(plugin);
GNUNET_CONFIGURATION_destroy(config);
return GNUNET_OK;
diff --git a/src/mintdb/perf_taler_mintdb_init.c b/src/mintdb/perf_taler_mintdb_init.c
index 3478af0e..4ada307b 100644
--- a/src/mintdb/perf_taler_mintdb_init.c
+++ b/src/mintdb/perf_taler_mintdb_init.c
@@ -26,6 +26,7 @@
#define CURRENCY "EUR"
+#define PERF_TALER_MINTDB_RSA_SIZE 256
/**
@@ -193,7 +194,9 @@ PERF_TALER_MINTDB_deposit_init ()
GNUNET_assert (NULL !=
(eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ()));
GNUNET_assert (NULL !=
- (rsa_prv = GNUNET_CRYPTO_rsa_private_key_create (128)));
+ (rsa_prv = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_MINTDB_RSA_SIZE)));
+ GNUNET_CRYPTO_eddsa_key_get_public (eddsa_prvt,
+ &coin.coin_pub.eddsa_pub);
GNUNET_assert (NULL !=
(coin.denom_pub.rsa_public_key =
GNUNET_CRYPTO_rsa_private_key_get_public (rsa_prv)));
@@ -202,8 +205,7 @@ PERF_TALER_MINTDB_deposit_init ()
GNUNET_CRYPTO_rsa_sign (rsa_prv,
&coin.coin_pub.eddsa_pub,
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))));
- GNUNET_CRYPTO_eddsa_key_get_public (eddsa_prvt,
- &coin.coin_pub.eddsa_pub);
+
GNUNET_CRYPTO_rsa_private_key_free (rsa_prv);
GNUNET_free (eddsa_prvt);
}
@@ -273,6 +275,7 @@ PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit)
return GNUNET_OK;
GNUNET_CRYPTO_rsa_public_key_free (deposit->coin.denom_pub.rsa_public_key);
GNUNET_CRYPTO_rsa_signature_free (deposit->coin.denom_sig.rsa_signature);
+ json_decref (deposit->wire);
GNUNET_free (deposit);
return GNUNET_OK;
@@ -294,7 +297,7 @@ PERF_TALER_MINTDB_denomination_init ()
(dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)));
GNUNET_assert (NULL !=
(dki->denom_priv.rsa_private_key
- = GNUNET_CRYPTO_rsa_private_key_create (128)));
+ = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_MINTDB_RSA_SIZE)));
GNUNET_assert (NULL !=
(dki->denom_pub.rsa_public_key =
GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key)));
@@ -363,7 +366,7 @@ PERF_TALER_MINTDB_coin_public_info_init ()
struct TALER_CoinPublicInfo *cpi;
GNUNET_assert (NULL !=
- (denom_prv = GNUNET_CRYPTO_rsa_private_key_create (128)));
+ (denom_prv = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_MINTDB_RSA_SIZE)));
GNUNET_assert (NULL !=
(coin_spent_prv = GNUNET_CRYPTO_eddsa_key_create ()));
GNUNET_assert (NULL !=
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c
index b92d6dc3..71972de2 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.c
+++ b/src/mintdb/perf_taler_mintdb_interpreter.c
@@ -195,9 +195,18 @@ cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[])
static void
interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
{
+ int i;
int jump = cmd_find (state->cmd,
state->cmd[state->i].details.end_loop.label_loop);
-
+ // Cleaning up the memory in the loop
+ for (i = jump; i < state->i; i++)
+ {
+ // If the exposed variable has not been copied it is freed
+ if ( GNUNET_NO == state->cmd[i].exposed_saved)
+ data_free (&state->cmd[i].exposed, state->cmd[i].exposed_type);
+ state->cmd[i].exposed_saved = GNUNET_NO;
+ }
+
state->cmd[jump].details.loop.curr_iteration++;
// If the loop is not finished
if (state->cmd[jump].details.loop.max_iterations >
@@ -209,15 +218,6 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
// Reset the loop counter and continue running
state->cmd[jump].details.loop.curr_iteration = 0;
}
- // Cleaning up the memory in the loop
- int j;
- for (j = jump; j < state->i; j++)
- {
- // If the exposed variable has not been copied it is freed
- if ( GNUNET_NO == state->cmd[j].exposed_saved)
- data_free (&state->cmd[j].exposed, state->cmd[j].exposed_type);
- state->cmd[j].exposed_saved = GNUNET_NO;
- }
}
static void
@@ -366,66 +366,6 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
interpret_save_array (state);
-// {
-// int loop_index;
-// int proba;
-// int rnd;
-// // Array initialization on first loop iteration
-// // Alows for nested loops
-// if (0 == state->cmd[cmd_find (state->cmd,
-// state->cmd[state->i]
-// .details.save_array.label_loop)]
-// .details.loop.curr_iteration)
-// {
-// state->cmd[state->i].details.save_array.index = 0;
-// }
-// loop_index = cmd_find (state->cmd,
-// state->cmd[state->i].details.save_array.label_loop);
-// // The probobility distribution of the saved items will be a little biased
-// // against the few last items but it should not be a big problem.
-// proba = state->cmd[loop_index].details.loop.max_iterations /
-// state->cmd[state->i].details.save_array.nb_saved;
-// rnd = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, proba);
-// /*
-// * If the remaining sapce is equal to the remaining number of
-// * iterations, the item is automaticly saved.
-// *
-// * Else it is saved only if rdn is 0
-// */
-// if (((state->cmd[loop_index].details.loop.max_iterations -
-// state->cmd[loop_index].details.loop.curr_iteration) ==
-// (state->cmd[state->i].details.save_array.nb_saved -
-// state->cmd[state->i].details.save_array.index))
-// || (rnd == 0))
-// {
-// union PERF_TALER_MINTDB_Data *save_location;
-// union PERF_TALER_MINTDB_Data *item_saved;
-//
-// save_location = &state->cmd[state->i].details.save_array
-// .data_saved[state->cmd[state->i].details.save_array.index];
-// item_saved = &state->cmd[cmd_find (state->cmd,
-// state->cmd[state->i]
-// .details.save_array.label_save)]
-// .exposed;
-// switch (state->cmd[state->i].details.save_array.type_saved)
-// {
-// case PERF_TALER_MINTDB_DEPOSIT:
-// save_location->deposit = item_saved->deposit;
-// break;
-//
-// case PERF_TALER_MINTDB_TIME:
-// save_location->time = item_saved->time;
-// break;
-//
-// default:
-// break;
-// }
-// state->cmd[cmd_find (state->cmd,
-// state->cmd[state->i].details.save_array.label_save)]
-// .exposed_saved = GNUNET_YES;
-// state->cmd[state->i].details.save_array.index++;
-// }
-// }
break;
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
@@ -461,14 +401,14 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT:
{
- struct TALER_MINTDB_Deposit *deposit =
- PERF_TALER_MINTDB_deposit_init ();
-
- GNUNET_assert (
- state->plugin->insert_deposit (state->plugin->cls,
- state->session,
- deposit));
- state->cmd[state->i].exposed.deposit = deposit;
+ struct TALER_MINTDB_Deposit *deposit =
+ PERF_TALER_MINTDB_deposit_init ();
+
+ GNUNET_assert (
+ state->plugin->insert_deposit (state->plugin->cls,
+ state->session,
+ deposit));
+ state->cmd[state->i].exposed.deposit = deposit;
}
break;
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h
index 53dfae38..c5641473 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.h
+++ b/src/mintdb/perf_taler_mintdb_interpreter.h
@@ -125,7 +125,7 @@
{ \
.command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\
.label = _label, \
- .exposed_type = PERF_TALER_MINTDB_NONE, \
+ .exposed_type = PERF_TALER_MINTDB_DEPOSIT, \
}
/**
@@ -144,7 +144,7 @@
* Extracts @a _nb_saved items of type @a _save_type
* from the command @a _label_save during the loop @a _label_loop
*/
-#define PERF_TALER_MINTDB_INIT_CMD_SAMPLE_ARRAY(_label, _label_loop, _label_save, _nb_saved, _save_type) \
+#define PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, _label_save, _nb_saved, _save_type) \
{ \
.command = PERF_TALER_MINTDB_CMD_SAVE_ARRAY, \
.label = _label, \
@@ -153,7 +153,7 @@
.label_loop = _label_loop, \
.label_save = _label_save, \
.nb_saved = _nb_saved, \
- .save_type = _save_type \
+ .type_saved = _save_type \
} \
}