From e2ab079dd8a2e72c4c2b41ac9bf4b0da10c2ac1f Mon Sep 17 00:00:00 2001 From: Fournier Nicolas Date: Wed, 24 Jun 2015 10:55:57 +0200 Subject: fixed gauger command in the interpreter --- src/mintdb/perf_taler_mintdb.c | 53 ++++++++++++++++++------------ src/mintdb/perf_taler_mintdb_interpreter.c | 2 +- src/mintdb/perf_taler_mintdb_interpreter.h | 42 ++++++++++++++++------- src/mintdb/perf_taler_mintdb_values.h | 32 ++++++++---------- 4 files changed, 77 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c index 0b1e4807..a39fdd81 100644 --- a/src/mintdb/perf_taler_mintdb.c +++ b/src/mintdb/perf_taler_mintdb.c @@ -33,30 +33,41 @@ 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",10000), - 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_SAVE_ARRAY ("array_depo", - "loop_db_init_deposit", - "init_deposit_insert", - 100, - PERF_TALER_MINTDB_DEPOSIT), + PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit", + PERF_TALER_MINTDB_NB_DEPOSIT_INIT), + 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_DEBUG("INIT_LOOP"), + PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("array_depo", + "loop_db_init_deposit", + "init_deposit_insert", + PERF_TALER_MINTDB_NB_DEPOSIT_GET, + PERF_TALER_MINTDB_DEPOSIT), PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit", "loop_db_init_deposit"), - PERF_TALER_MINTDB_INIT_CMD_DEBUG("Fin loop 1"), - PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_deposit_get",100), - PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_get"), - PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY("load deposit", - "loop_deposit_get", - "array_depo"), - PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT("get_deposit", - "load_deposit"), - PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"), - PERF_TALER_MINTDB_INIT_CMD_END_LOOP("stop2", "loop_deposit_get"), - PERF_TALER_MINTDB_INIT_CMD_END("end") + PERF_TALER_MINTDB_INIT_CMD_DEBUG("INIT_END"), + // End of database initialization + PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_start"), + PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_deposit_get", + PERF_TALER_MINTDB_NB_DEPOSIT_GET), + PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_get"), + PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("load deposit", + "loop_deposit_get", + "array_depo"), + PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT ("get_deposit", + "load_deposit"), + PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"), + PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("stop2", "loop_deposit_get"), + PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_end"), + PERF_TALER_MINTDB_INIT_CMD_GAUGER ("deposit_get_commit", + "deposit_get_start", + "deposit_get_end", + "time per deposit check", + PERF_TALER_MINTDB_NB_DEPOSIT_GET), + PERF_TALER_MINTDB_INIT_CMD_END("end"), }; - // Plugin init + // Plugin init config = GNUNET_CONFIGURATION_create(); GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf"); GNUNET_assert (NULL != diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c index d7d3a6d0..4d7a17cb 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.c +++ b/src/mintdb/perf_taler_mintdb_interpreter.c @@ -407,7 +407,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) GAUGER ("MINTDB", state->cmd[state->i].details.gauger.description, - elapsed_ms, + elapsed_ms / state->cmd[state->i].details.gauger.divide, "milliseconds"); } break; diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h index 79866031..16437907 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.h +++ b/src/mintdb/perf_taler_mintdb_interpreter.h @@ -58,7 +58,7 @@ .exposed_type = PERF_TALER_MINTDB_NONE , \ .details.loop = { \ .max_iterations = _iter , \ - .curr_iteration = 0} \ + .curr_iteration = 0 } \ } /** @@ -86,15 +86,16 @@ * Commits the duration between @a _label_start and @a _label_stop * to Gauger with @a _description explaining */ -#define PERF_TALER_MINTDB_INIT_CMD_GAUGER(_label, _start_time, _stop_time, _description) \ +#define PERF_TALER_MINTDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, _description, _divide) \ { \ .command = PERF_TALER_MINTDB_CMD_GAUGER, \ .label = _label, \ .exposed_type = PERF_TALER_MINTDB_NONE, \ .details.gauger = { \ .label_start = _label_start, \ - .label_end = _label_end, \ - .description = _description \ + .label_stop = _label_stop, \ + .description = _description, \ + .divide = _divide, \ } \ } @@ -249,9 +250,7 @@ enum PERF_TALER_MINTDB_Type PERF_TALER_MINTDB_TIME, PERF_TALER_MINTDB_DEPOSIT, PERF_TALER_MINTDB_BLINDCOIN, - PERF_TALER_MINTDB_RESERVE_KEY, PERF_TALER_MINTDB_RESERVE, - PERF_TALER_MINTDB_DENOMINATION_KEY, PERF_TALER_MINTDB_DENOMINATION_INFO, PERF_TALER_MINTDB_COIN_INFO, }; @@ -266,7 +265,6 @@ union PERF_TALER_MINTDB_Data struct TALER_MINTDB_Deposit *deposit; struct TALER_MINTDB_CollectableBlindcoin *blindcoin; struct TALER_MINTDB_Reserve *reserve; - struct TALER_DenominationPublicKey *dpk; struct TALER_MINTDB_DenominationKeyIssueInformation *dki; struct TALER_CoinPublicInfo *cpi; }; @@ -334,8 +332,11 @@ enum PERF_TALER_MINTDB_CMD_Name // Insert informations about a denomination key in the database PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION, - // polls the database for informations about a specific denomination key - PERF_TALER_MINTDB_CMD_GET_DENOMINATION + // Polls the database for informations about a specific denomination key + PERF_TALER_MINTDB_CMD_GET_DENOMINATION, + + // Refresh a coin + PERF_TALER_MINTDB_CMD_REFRESH_COIN, }; @@ -381,6 +382,12 @@ struct PERF_TALER_MINTDB_CMD_gauger_details * Description of the metric, used in GAUGER */ const char *description; + + /** + * Constant the result needs to be divided by + * to get the result per unit + */ + float divide; }; @@ -470,6 +477,19 @@ struct PERF_TALER_MINTDB_CMD_get_denomination_details const char *label_source; }; + +/** + * Extra data requiered for refreshing coins + */ +struct PERF_TALER_MINTDB_CMD_refresh_coin_details +{ + /** + * The label of the coin to refresh + */ + const char *label_source; +}; + + /** * Contains extra data required for any command */ @@ -483,6 +503,7 @@ union PERF_TALER_MINTDB_CMD_Details struct PERF_TALER_MINTDB_CMD_get_deposit_details get_deposit; struct PERF_TALER_MINTDB_CMD_get_reserve_details get_reserve; struct PERF_TALER_MINTDB_CMD_get_denomination_details get_denomination; + struct PERF_TALER_MINTDB_CMD_refresh_coin_details refresh; }; @@ -520,7 +541,7 @@ struct PERF_TALER_MINTDB_Cmd * GNUNET_YES if the exposed value hav been saved during last loop iteration * GNUNET_NO if it hasn't */ - int exposed_saved; + unsigned int exposed_saved; }; @@ -533,5 +554,4 @@ PERF_TALER_MINTDB_interpret( struct TALER_MINTDB_Plugin *db_plugin, struct PERF_TALER_MINTDB_Cmd cmd[]); - #endif diff --git a/src/mintdb/perf_taler_mintdb_values.h b/src/mintdb/perf_taler_mintdb_values.h index f180c8d7..4b982b8b 100644 --- a/src/mintdb/perf_taler_mintdb_values.h +++ b/src/mintdb/perf_taler_mintdb_values.h @@ -1,18 +1,18 @@ /* - This file is part of TALER - Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors) + This file is part of TALER + Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors) - 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 - Foundation; either version 3, or (at your option) any later version. + 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 + Foundation; either version 3, or (at your option) any later version. - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, If not, see -*/ + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, If not, see + */ /** * @file mintdb/perf_taler_mintdb_values.h * @brief Values for tweaking the performance analysis @@ -23,15 +23,9 @@ -#define NB_DEPOSIT_INIT 100000 -#define NB_DEPOSIT_GET 1000 -#define NB_DEPOSIT_MARGIN 10000 +#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100 +#define PERF_TALER_MINTDB_NB_DEPOSIT_GET 10 -#define NB_BLINDCOIN_INIT 100000 - - -// Temporary macro to compile -#define GAUGER(a,b,c,d) #endif -- cgit v1.2.3 From c3b29bf7e70b3e7f36a4e1c6eb18f5a665baf8fc Mon Sep 17 00:00:00 2001 From: Fournier Nicolas Date: Wed, 24 Jun 2015 14:42:03 +0200 Subject: Fixed unconsistent signed/unsigned declaration --- src/mintdb/perf_taler_mintdb.c | 1 - src/mintdb/perf_taler_mintdb_interpreter.c | 22 +++++++++++----------- src/mintdb/perf_taler_mintdb_interpreter.h | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c index a39fdd81..48a7dd74 100644 --- a/src/mintdb/perf_taler_mintdb.c +++ b/src/mintdb/perf_taler_mintdb.c @@ -38,7 +38,6 @@ main (int argc, char ** argv) 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_DEBUG("INIT_LOOP"), PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("array_depo", "loop_db_init_deposit", "init_deposit_insert", diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c index 4d7a17cb..b54fda1c 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.c +++ b/src/mintdb/perf_taler_mintdb_interpreter.c @@ -47,7 +47,7 @@ struct PERF_TALER_MINTDB_interpreter_state /** * The current index of the interpreter */ - int i; + unsigned int i; }; /** @@ -99,7 +99,7 @@ data_free (union PERF_TALER_MINTDB_Data *data, enum PERF_TALER_MINTDB_Type type) static int cmd_find (const struct PERF_TALER_MINTDB_Cmd *cmd, const char *search) { - int i; + unsigned int i; for (i=0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++) if (0 == strcmp (cmd[i].label, search)) @@ -114,7 +114,7 @@ cmd_find (const struct PERF_TALER_MINTDB_Cmd *cmd, const char *search) static int cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[]) { - int i = 0; + unsigned int i = 0; for (i=0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++) { @@ -158,7 +158,7 @@ cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[]) static int cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[]) { - int i = 0; + unsigned int i = 0; for (i = 0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++) { @@ -166,7 +166,7 @@ cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[]) { case PERF_TALER_MINTDB_CMD_SAVE_ARRAY: { - int j; + unsigned int j; for (j = 0; j < cmd[i].details.save_array.nb_saved; j++) { data_free (&cmd[i].details.save_array.data_saved[j], @@ -198,9 +198,9 @@ cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[]) static void interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state) { - int i; + unsigned int i; union PERF_TALER_MINTDB_Data zero = {0}; - int jump = cmd_find (state->cmd, + unsigned 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++) @@ -234,8 +234,8 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state) static void interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) { - int loop_index; - int selection_chance; + unsigned int loop_index; + unsigned int selection_chance; // Array initialization on first loop iteration // Alows for nested loops @@ -316,7 +316,7 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) static void interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state) { - int loop_index, save_index; + unsigned int loop_index, save_index; union PERF_TALER_MINTDB_Data zero = {0}; union PERF_TALER_MINTDB_Data *loaded_data; @@ -392,7 +392,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GAUGER: { - int start_index, stop_index; + unsigned int start_index, stop_index; struct timespec start, stop; unsigned long elapsed_ms; diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h index 16437907..49f06b6e 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.h +++ b/src/mintdb/perf_taler_mintdb_interpreter.h @@ -347,7 +347,7 @@ struct PERF_TALER_MINTDB_CMD_loop_details { // Maximum number of iteration in the loop const unsigned int max_iterations; - int curr_iteration; + unsigned int curr_iteration; }; -- cgit v1.2.3 From 47262f4316874f321ffdcbcdcb1d98c182375730 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 25 Jun 2015 15:31:15 +0200 Subject: NPE detection --- src/mintdb/perf_taler_mintdb.c | 26 +++++---- src/mintdb/perf_taler_mintdb_interpreter.c | 88 +++++++++++++++--------------- 2 files changed, 59 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c index 48a7dd74..ed7e80b3 100644 --- a/src/mintdb/perf_taler_mintdb.c +++ b/src/mintdb/perf_taler_mintdb.c @@ -31,17 +31,17 @@ main (int argc, char ** argv) { struct TALER_MINTDB_Plugin *plugin; struct GNUNET_CONFIGURATION_Handle *config; - struct PERF_TALER_MINTDB_Cmd test[] = + struct PERF_TALER_MINTDB_Cmd test[] = { - PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit", + PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit", PERF_TALER_MINTDB_NB_DEPOSIT_INIT), 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_SAVE_ARRAY ("array_depo", - "loop_db_init_deposit", - "init_deposit_insert", - PERF_TALER_MINTDB_NB_DEPOSIT_GET, + PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("array_depo", + "loop_db_init_deposit", + "init_deposit_insert", + PERF_TALER_MINTDB_NB_DEPOSIT_GET, PERF_TALER_MINTDB_DEPOSIT), PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit", "loop_db_init_deposit"), @@ -51,22 +51,26 @@ main (int argc, char ** argv) PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_deposit_get", PERF_TALER_MINTDB_NB_DEPOSIT_GET), PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_get"), - PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("load deposit", - "loop_deposit_get", + PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("load deposit", + "loop_deposit_get", "array_depo"), - PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT ("get_deposit", + PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT ("get_deposit", "load_deposit"), PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"), PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("stop2", "loop_deposit_get"), PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_end"), - PERF_TALER_MINTDB_INIT_CMD_GAUGER ("deposit_get_commit", - "deposit_get_start", + PERF_TALER_MINTDB_INIT_CMD_GAUGER ("deposit_get_commit", + "deposit_get_start", "deposit_get_end", "time per deposit check", PERF_TALER_MINTDB_NB_DEPOSIT_GET), PERF_TALER_MINTDB_INIT_CMD_END("end"), }; // Plugin init + + GNUNET_log_setup ("perf-taler-mintdb", + "WARNING", + NULL); config = GNUNET_CONFIGURATION_create(); GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf"); GNUNET_assert (NULL != diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c index b54fda1c..dd36ae6d 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.c +++ b/src/mintdb/perf_taler_mintdb_interpreter.c @@ -86,7 +86,7 @@ data_free (union PERF_TALER_MINTDB_Data *data, enum PERF_TALER_MINTDB_Type type) default: return; } -} +} @@ -109,7 +109,7 @@ cmd_find (const struct PERF_TALER_MINTDB_Cmd *cmd, const char *search) /** - * Initialization of a command array + * Initialization of a command array */ static int cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[]) @@ -122,8 +122,8 @@ cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[]) { case PERF_TALER_MINTDB_CMD_SAVE_ARRAY: // Allocation of memory for saving data - cmd[i].details.save_array.data_saved = - GNUNET_new_array (cmd[i].details.save_array.nb_saved, + cmd[i].details.save_array.data_saved = + GNUNET_new_array (cmd[i].details.save_array.nb_saved, union PERF_TALER_MINTDB_Data); break; @@ -133,13 +133,13 @@ cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[]) (cmd[i].details.load_array.permutation = GNUNET_CRYPTO_random_permute ( GNUNET_CRYPTO_QUALITY_WEAK, - cmd[cmd_find (cmd, + cmd[cmd_find (cmd, cmd[i].details .load_array.label_save)] .details.save_array.nb_saved))); // Initializing the type based on the type of the saved array - cmd[i].exposed_type = cmd[cmd_find (cmd, + cmd[i].exposed_type = cmd[cmd_find (cmd, cmd[i].details.load_array.label_save)] .details.save_array.type_saved; break; @@ -200,7 +200,7 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state) { unsigned int i; union PERF_TALER_MINTDB_Data zero = {0}; - unsigned int jump = cmd_find (state->cmd, + unsigned 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++) @@ -215,7 +215,7 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state) state->cmd[jump].details.loop.curr_iteration++; // If the loop is not finished - if (state->cmd[jump].details.loop.max_iterations > + if (state->cmd[jump].details.loop.max_iterations > state->cmd[jump].details.loop.curr_iteration) { // jump back to the start @@ -239,16 +239,16 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) // Array initialization on first loop iteration // Alows for nested loops - if (0 == state->cmd[cmd_find (state->cmd, + 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, + 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 + // 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. selection_chance = state->cmd[loop_index].details.loop.max_iterations / state->cmd[state->i].details.save_array.nb_saved; @@ -258,13 +258,13 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) * * Else it is saved only if rdn is 0 */ - if ((0 < (state->cmd[state->i].details.save_array.nb_saved - + if ((0 < (state->cmd[state->i].details.save_array.nb_saved - state->cmd[state->i].details.save_array.index)) && - (((state->cmd[loop_index].details.loop.max_iterations - + (((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.nb_saved - state->cmd[state->i].details.save_array.index)) - || (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + || (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, selection_chance)))) { union PERF_TALER_MINTDB_Data *save_location; @@ -272,7 +272,7 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) 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, + item_saved = &state->cmd[cmd_find (state->cmd, state->cmd[state->i] .details.save_array.label_save)] .exposed; @@ -320,9 +320,9 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state) union PERF_TALER_MINTDB_Data zero = {0}; union PERF_TALER_MINTDB_Data *loaded_data; - loop_index = cmd_find (state->cmd, + loop_index = cmd_find (state->cmd, state->cmd[state->i].details.load_array.label_loop); - save_index = cmd_find (state->cmd, + save_index = cmd_find (state->cmd, state->cmd[state->i].details.load_array.label_save); /* Extracting the data from the loop_indexth indice in save_index * array. @@ -362,7 +362,7 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state) /** * Main interpreter loop. - * + * */ static int interpret (struct PERF_TALER_MINTDB_interpreter_state *state) @@ -392,22 +392,22 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GAUGER: { - unsigned int start_index, stop_index; + unsigned int start_index, stop_index; struct timespec start, stop; unsigned long elapsed_ms; - start_index = cmd_find (state->cmd, + start_index = cmd_find (state->cmd, state->cmd[state->i].details.gauger.label_start); - stop_index = cmd_find (state->cmd, + stop_index = cmd_find (state->cmd, state->cmd[state->i].details.gauger.label_stop); start = state->cmd[start_index].exposed.time; stop = state->cmd[stop_index].exposed.time; - elapsed_ms = (start.tv_sec - stop.tv_sec) * 1000 + + elapsed_ms = (start.tv_sec - stop.tv_sec) * 1000 + (start.tv_nsec - stop.tv_nsec) / 1000000; - GAUGER ("MINTDB", - state->cmd[state->i].details.gauger.description, - elapsed_ms / state->cmd[state->i].details.gauger.divide, + GAUGER ("MINTDB", + state->cmd[state->i].details.gauger.description, + elapsed_ms / state->cmd[state->i].details.gauger.divide, "milliseconds"); } break; @@ -441,8 +441,8 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) PERF_TALER_MINTDB_deposit_init (); GNUNET_assert ( - state->plugin->insert_deposit (state->plugin->cls, - state->session, + state->plugin->insert_deposit (state->plugin->cls, + state->session, deposit)); state->cmd[state->i].exposed.deposit = deposit; } @@ -450,24 +450,24 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GET_DEPOSIT: { - struct TALER_MINTDB_Deposit *deposit = - state->cmd[cmd_find (state->cmd, + struct TALER_MINTDB_Deposit *deposit = + state->cmd[cmd_find (state->cmd, state->cmd[state->i] .details.get_deposit.label_source)] .exposed.deposit; // Get the deposit from the source - - state->plugin->have_deposit (state->plugin->cls, - state->session, + GNUNET_assert (NULL != deposit); + state->plugin->have_deposit (state->plugin->cls, + state->session, deposit); } break; - + case PERF_TALER_MINTDB_CMD_INSERT_RESERVE: { struct TALER_MINTDB_Reserve *reserve; json_t *details = json_pack ("si","justification", GNUNET_CRYPTO_random_u32 ( - GNUNET_CRYPTO_QUALITY_WEAK, + GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX)); reserve = PERF_TALER_MINTDB_reserve_init (); state->plugin->reserves_in_insert ( @@ -476,7 +476,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) &reserve->pub, &reserve->balance, details - ); + ); json_decref (details); state->cmd[state->i].exposed.reserve = reserve; } @@ -485,16 +485,16 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GET_RESERVE: { struct TALER_MINTDB_Reserve *reserve = - state->cmd[cmd_find (state->cmd, + state->cmd[cmd_find (state->cmd, state->cmd[state->i] .details.get_reserve.label_source)] .exposed.reserve; // Get the deposit from the source - state->plugin->reserve_get (state->plugin->cls, - state->session, + state->plugin->reserve_get (state->plugin->cls, + state->session, reserve); } - break; + break; case PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION: { @@ -512,7 +512,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GET_DENOMINATION: { struct TALER_MINTDB_DenominationKeyIssueInformation *dki = - state->cmd[cmd_find (state->cmd, + state->cmd[cmd_find (state->cmd, state->cmd[state->i] .details.get_denomination.label_source)] .exposed.dki; @@ -538,11 +538,11 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GET_WITHDRAW: { struct TALER_MINTDB_CollectableBlindcoin *blindcoin = - state->cmd[cmd_find (state->cmd, + state->cmd[cmd_find (state->cmd, state->cmd[state->i] .details.get_denomination.label_source)] .exposed.blindcoin; - + state->plugin->get_withdraw_info (state->plugin->cls, state->session, &blindcoin->h_coin_envelope, @@ -566,7 +566,7 @@ int PERF_TALER_MINTDB_interpret (struct TALER_MINTDB_Plugin *db_plugin, struct PERF_TALER_MINTDB_Cmd cmd[]) { - struct PERF_TALER_MINTDB_interpreter_state state = + struct PERF_TALER_MINTDB_interpreter_state state = {.i = 0, .cmd = cmd, .plugin = db_plugin}; // Initializing commands -- cgit v1.2.3 From d98eabf6c30d589bffaf7a1dba4df51c26d56c74 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 26 Jun 2015 09:03:18 +0200 Subject: handle response code 0 more nicely --- src/mint-lib/mint_api_deposit.c | 2 ++ src/mint-lib/mint_api_handle.c | 24 ++++++++++++++++++++++++ src/mint-lib/mint_api_withdraw.c | 4 ++++ 3 files changed, 30 insertions(+) (limited to 'src') diff --git a/src/mint-lib/mint_api_deposit.c b/src/mint-lib/mint_api_deposit.c index f0cacb60..8c823bd0 100644 --- a/src/mint-lib/mint_api_deposit.c +++ b/src/mint-lib/mint_api_deposit.c @@ -343,6 +343,8 @@ handle_deposit_finished (void *cls, } switch (response_code) { + case 0: + break; case MHD_HTTP_OK: if (GNUNET_OK != verify_deposit_signature_ok (dh, diff --git a/src/mint-lib/mint_api_handle.c b/src/mint-lib/mint_api_handle.c index 530cd606..6bcae9f6 100644 --- a/src/mint-lib/mint_api_handle.c +++ b/src/mint-lib/mint_api_handle.c @@ -574,8 +574,32 @@ keys_completed_cb (void *cls, { struct KeysRequest *kr = cls; struct TALER_MINT_Handle *mint = kr->mint; + long response_code; /* FIXME: might want to check response code? */ + if (CURLE_OK != + curl_easy_getinfo (eh, + CURLINFO_RESPONSE_CODE, + &response_code)) + { + /* unexpected error... */ + GNUNET_break (0); + response_code = 0; + } + switch (response_code) { + case 0: + kr->errno = 1; + break; + case MHD_HTTP_OK: + break; + default: + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Mint returned status code %u for /keys\n", + response_code); + kr->errno = 1; + break; + } + if ( (0 != kr->eno) || (GNUNET_OK != parse_response_keys_get (kr)) ) diff --git a/src/mint-lib/mint_api_withdraw.c b/src/mint-lib/mint_api_withdraw.c index b877cf4d..c79f57da 100644 --- a/src/mint-lib/mint_api_withdraw.c +++ b/src/mint-lib/mint_api_withdraw.c @@ -324,6 +324,8 @@ handle_withdraw_status_finished (void *cls, } switch (response_code) { + case 0: + break; case MHD_HTTP_OK: { json_t *history; @@ -818,6 +820,8 @@ handle_withdraw_sign_finished (void *cls, } switch (response_code) { + case 0: + break; case MHD_HTTP_OK: if (GNUNET_OK != withdraw_sign_ok (wsh, -- cgit v1.2.3 From 5963e1136fcc566e9fc3070839ddaee518854d8f Mon Sep 17 00:00:00 2001 From: Fournier Nicolas Date: Fri, 26 Jun 2015 15:32:20 +0200 Subject: Remade memory management strategy of the interpreter. --- src/mintdb/perf_taler_mintdb.c | 10 +- src/mintdb/perf_taler_mintdb_init.c | 119 ++++++++++++++-- src/mintdb/perf_taler_mintdb_init.h | 34 ++++- src/mintdb/perf_taler_mintdb_interpreter.c | 214 +++++++++++++++++------------ src/mintdb/perf_taler_mintdb_interpreter.h | 56 ++++++-- src/mintdb/perf_taler_mintdb_values.h | 2 +- 6 files changed, 316 insertions(+), 119 deletions(-) (limited to 'src') diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c index ed7e80b3..50d351e2 100644 --- a/src/mintdb/perf_taler_mintdb.c +++ b/src/mintdb/perf_taler_mintdb.c @@ -33,10 +33,15 @@ main (int argc, char ** argv) struct GNUNET_CONFIGURATION_Handle *config; struct PERF_TALER_MINTDB_Cmd test[] = { + // Denomination used to create coins + PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION ("denomination"), + + PERF_TALER_MINTDB_INIT_CMD_DEBUG ("denomination inserted"), PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit", PERF_TALER_MINTDB_NB_DEPOSIT_INIT), 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_INSERT_DEPOSIT ("init_deposit_insert", + "denomination"), PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"), PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("array_depo", "loop_db_init_deposit", @@ -45,13 +50,12 @@ main (int argc, char ** argv) PERF_TALER_MINTDB_DEPOSIT), PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit", "loop_db_init_deposit"), - PERF_TALER_MINTDB_INIT_CMD_DEBUG("INIT_END"), // End of database initialization PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_start"), PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_deposit_get", PERF_TALER_MINTDB_NB_DEPOSIT_GET), PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_get"), - PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("load deposit", + PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("load_deposit", "loop_deposit_get", "array_depo"), PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT ("get_deposit", diff --git a/src/mintdb/perf_taler_mintdb_init.c b/src/mintdb/perf_taler_mintdb_init.c index 4ada307b..f93bd828 100644 --- a/src/mintdb/perf_taler_mintdb_init.c +++ b/src/mintdb/perf_taler_mintdb_init.c @@ -33,7 +33,9 @@ * @return a randomly generated CollectableBlindcoin */ struct TALER_MINTDB_CollectableBlindcoin * -PERF_TALER_MINTDB_collectable_blindcoin_init () +PERF_TALER_MINTDB_collectable_blindcoin_init ( + const struct TALER_MINTDB_DenominationKeyIssueInformation *dki, + const struct TALER_MINTDB_Reserve *reserve) { uint32_t random_int; struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key; @@ -45,12 +47,13 @@ PERF_TALER_MINTDB_collectable_blindcoin_init () struct TALER_MINTDB_CollectableBlindcoin *coin; - coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin); + GNUNET_assert (NULL != + (coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin))); GNUNET_assert (NULL != (reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ())); GNUNET_assert (NULL != (denomination_key = GNUNET_CRYPTO_rsa_private_key_create (512))); - GNUNET_assert (NULL == + GNUNET_assert (NULL != (coin->denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key))); GNUNET_CRYPTO_eddsa_key_get_public (reserve_sig_key, @@ -82,6 +85,35 @@ PERF_TALER_MINTDB_collectable_blindcoin_init () return coin; } + +struct TALER_MINTDB_CollectableBlindcoin * +PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin) +{ + struct TALER_MINTDB_CollectableBlindcoin *copy; + + GNUNET_assert (NULL != + (copy = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin))); + *copy = *coin; + // No signature copy function found, Hacking it in + { + char *buffer = NULL; + int size; + GNUNET_assert (0 < + (size = GNUNET_CRYPTO_rsa_signature_encode ( + coin->sig.rsa_signature, + &buffer))); + GNUNET_assert (NULL != + (copy->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_decode( + buffer, + size))); + GNUNET_free (buffer); + } + GNUNET_assert (NULL != + (copy->denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (coin->denom_pub.rsa_public_key))); + return copy; +} + /** * Liberate memory of @a coin */ @@ -121,12 +153,24 @@ PERF_TALER_MINTDB_reserve_init () } + +struct TALER_MINTDB_Reserve * +PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve) +{ + struct TALER_MINTDB_Reserve *copy; + GNUNET_assert (NULL != (copy = GNUNET_new (struct TALER_MINTDB_Reserve))); + *copy = *reserve; + return copy; +} + /** * Free memory of a reserve */ int PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve) { + if (NULL == reserve) + return GNUNET_OK; GNUNET_free (reserve); return GNUNET_OK; } @@ -165,7 +209,7 @@ PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refr * Create a randomly generated deposit */ struct TALER_MINTDB_Deposit * -PERF_TALER_MINTDB_deposit_init () +PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki) { struct TALER_MINTDB_Deposit *deposit; struct TALER_CoinPublicInfo coin; @@ -189,24 +233,20 @@ PERF_TALER_MINTDB_deposit_init () (deposit = GNUNET_malloc (sizeof (struct TALER_MINTDB_Deposit) + sizeof (wire)))); { // coin struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt; - struct GNUNET_CRYPTO_rsa_PrivateKey *rsa_prv; GNUNET_assert (NULL != (eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ())); - GNUNET_assert (NULL != - (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))); + GNUNET_assert (NULL != + (coin.denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key))); GNUNET_assert (NULL != (coin.denom_sig.rsa_signature = - GNUNET_CRYPTO_rsa_sign (rsa_prv, + GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, &coin.coin_pub.eddsa_pub, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))); - GNUNET_CRYPTO_rsa_private_key_free (rsa_prv); GNUNET_free (eddsa_prvt); } { //csig @@ -265,6 +305,33 @@ PERF_TALER_MINTDB_deposit_init () } +struct TALER_MINTDB_Deposit * +PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit) +{ + struct TALER_MINTDB_Deposit *copy; + + GNUNET_assert (NULL != (copy = GNUNET_new (struct TALER_MINTDB_Deposit))); + *copy = *deposit; + json_incref (copy->wire); + GNUNET_assert (NULL != + (copy->coin.denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (deposit->coin.denom_pub.rsa_public_key))); + { + char *buffer = NULL; + int size; + GNUNET_assert (0 < + (size = GNUNET_CRYPTO_rsa_signature_encode ( + deposit->coin.denom_sig.rsa_signature, + &buffer))); + GNUNET_assert (NULL != + (copy->coin.denom_sig.rsa_signature = + GNUNET_CRYPTO_rsa_signature_decode(buffer, size))); + GNUNET_free (buffer); + } + return copy; +} + + /** * Free memory of a deposit */ @@ -339,6 +406,34 @@ PERF_TALER_MINTDB_denomination_init () } + +struct TALER_MINTDB_DenominationKeyIssueInformation * +PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki) +{ + struct TALER_MINTDB_DenominationKeyIssueInformation *copy; + + GNUNET_assert (NULL != + (copy = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation))); + *copy = *dki; + { + char *buffer = NULL; + int size; + GNUNET_assert (0 < + (size = GNUNET_CRYPTO_rsa_private_key_encode ( + dki->denom_priv.rsa_private_key, + &buffer))); + GNUNET_assert (NULL != + (copy->denom_priv.rsa_private_key = + GNUNET_CRYPTO_rsa_private_key_decode(buffer, size))); + GNUNET_free (buffer); + } + GNUNET_assert (NULL != + (copy->denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key))); + return copy; +} + + /** * Free memory for a DenominationKeyIssueInformation */ diff --git a/src/mintdb/perf_taler_mintdb_init.h b/src/mintdb/perf_taler_mintdb_init.h index 5f2e44cd..3e2eb3cc 100644 --- a/src/mintdb/perf_taler_mintdb_init.h +++ b/src/mintdb/perf_taler_mintdb_init.h @@ -31,14 +31,21 @@ * @return a randomly generated CollectableBlindcoin */ struct TALER_MINTDB_CollectableBlindcoin * -PERF_TALER_MINTDB_collectable_blindcoin_init (void); +PERF_TALER_MINTDB_collectable_blindcoin_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki, + const struct TALER_MINTDB_Reserve *reserve); + +/** + * @returns a copy of @a coin + */ +struct TALER_MINTDB_CollectableBlindcoin * +PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin); /** * Liberate memory of @a coin */ int -PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *NAME); +PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin); /** @@ -49,7 +56,13 @@ PERF_TALER_MINTDB_reserve_init (void); /** - * Free memory of a reserve + * Returns a copy of @reserve + */ +struct TALER_MINTDB_Reserve * +PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve); + +/** + * Frees memory allocated to @a reserve */ int PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve); @@ -73,7 +86,14 @@ PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refr * Create a randomly generated deposit */ struct TALER_MINTDB_Deposit * -PERF_TALER_MINTDB_deposit_init (void); +PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); + + +/** + * @returns a copy of @a deposit + */ +struct TALER_MINTDB_Deposit * +PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit); /** @@ -90,6 +110,12 @@ struct TALER_MINTDB_DenominationKeyIssueInformation * PERF_TALER_MINTDB_denomination_init (void); +/** + * @returns a copy of @a dki + */ +struct TALER_MINTDB_DenominationKeyIssueInformation * +PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); + /** * Free memory for a DenominationKeyIssueInformation */ diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c index dd36ae6d..25999792 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.c +++ b/src/mintdb/perf_taler_mintdb_interpreter.c @@ -129,19 +129,21 @@ cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[]) case PERF_TALER_MINTDB_CMD_LOAD_ARRAY: // Creating the permutation array to randomize the data order - GNUNET_assert (NULL != - (cmd[i].details.load_array.permutation = - GNUNET_CRYPTO_random_permute ( - GNUNET_CRYPTO_QUALITY_WEAK, - cmd[cmd_find (cmd, - cmd[i].details - .load_array.label_save)] - .details.save_array.nb_saved))); - - // Initializing the type based on the type of the saved array - cmd[i].exposed_type = cmd[cmd_find (cmd, - cmd[i].details.load_array.label_save)] - .details.save_array.type_saved; + { + int save_index ; + + GNUNET_assert (GNUNET_SYSERR != + (save_index = cmd_find ( + cmd, + cmd[i].details.load_array.label_save))); + GNUNET_assert (NULL != + (cmd[i].details.load_array.permutation = + GNUNET_CRYPTO_random_permute ( + GNUNET_CRYPTO_QUALITY_WEAK, + cmd[save_index].details.save_array.nb_saved))); + // Initializing the type based on the type of the saved array + cmd[i].exposed_type = cmd[save_index].details.save_array.type_saved; + } break; default: @@ -200,16 +202,15 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state) { unsigned int i; union PERF_TALER_MINTDB_Data zero = {0}; - unsigned int jump = cmd_find (state->cmd, - state->cmd[state->i].details.end_loop.label_loop); + unsigned int jump; + GNUNET_assert (GNUNET_SYSERR != + (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; - // Anyway we need to make the data zero. + data_free (&state->cmd[i].exposed, state->cmd[i].exposed_type); state->cmd[i].exposed = zero; } @@ -234,20 +235,23 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state) static void interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) { - unsigned int loop_index; + unsigned int loop_index, save_index; unsigned int selection_chance; // 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) + GNUNET_assert (GNUNET_SYSERR != + (loop_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.save_array.label_loop))); + GNUNET_assert (GNUNET_SYSERR != + (save_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.save_array.label_save))); + if (0 == state->cmd[loop_index].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. selection_chance = state->cmd[loop_index].details.loop.max_iterations / @@ -272,10 +276,7 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) 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; + item_saved = &state->cmd[save_index].exposed; switch (state->cmd[state->i].details.save_array.type_saved) { case PERF_TALER_MINTDB_TIME: @@ -283,19 +284,19 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) break; case PERF_TALER_MINTDB_DEPOSIT: - save_location->deposit = item_saved->deposit; + save_location->deposit = PERF_TALER_MINTDB_deposit_copy (item_saved->deposit); break; case PERF_TALER_MINTDB_BLINDCOIN: - save_location->blindcoin = item_saved->blindcoin; + save_location->blindcoin = PERF_TALER_MINTDB_collectable_blindcoin_copy (item_saved->blindcoin); break; case PERF_TALER_MINTDB_RESERVE: - save_location->reserve = item_saved->reserve; + save_location->reserve = PERF_TALER_MINTDB_reserve_copy (item_saved->reserve); break; case PERF_TALER_MINTDB_DENOMINATION_INFO: - save_location->dki = item_saved->dki; + save_location->dki = PERF_TALER_MINTDB_denomination_copy (item_saved->dki); break; case PERF_TALER_MINTDB_COIN_INFO: @@ -305,9 +306,6 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) 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++; } } @@ -316,21 +314,24 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) static void interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state) { - unsigned int loop_index, save_index; + unsigned int loop_index, save_index, loop_iter, permut_index; union PERF_TALER_MINTDB_Data zero = {0}; union PERF_TALER_MINTDB_Data *loaded_data; - - loop_index = cmd_find (state->cmd, - state->cmd[state->i].details.load_array.label_loop); - save_index = cmd_find (state->cmd, - state->cmd[state->i].details.load_array.label_save); + + GNUNET_assert (GNUNET_SYSERR != + (loop_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.load_array.label_loop))); + GNUNET_assert (GNUNET_SYSERR != + (save_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.load_array.label_save))); + loop_iter = state->cmd[loop_index].details.loop.curr_iteration; + permut_index = state->cmd[state->i].details.load_array.permutation[loop_iter]; /* Extracting the data from the loop_indexth indice in save_index * array. */ - loaded_data = &state->cmd[save_index].details.save_array.data_saved[ - state->cmd[state->i].details.load_array.permutation[ - state->cmd[loop_index].details.loop.curr_iteration]]; - + loaded_data = &state->cmd[save_index].details.save_array.data_saved[permut_index]; switch (state->cmd[state->i].exposed_type) { case PERF_TALER_MINTDB_TIME: @@ -396,10 +397,14 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) struct timespec start, stop; unsigned long elapsed_ms; - start_index = cmd_find (state->cmd, - state->cmd[state->i].details.gauger.label_start); - stop_index = cmd_find (state->cmd, - state->cmd[state->i].details.gauger.label_stop); + GNUNET_assert (GNUNET_SYSERR != + (start_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.gauger.label_start))); + GNUNET_assert (GNUNET_SYSERR != + (stop_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.gauger.label_stop))); start = state->cmd[start_index].exposed.time; stop = state->cmd[stop_index].exposed.time; elapsed_ms = (start.tv_sec - stop.tv_sec) * 1000 + @@ -437,8 +442,15 @@ 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 (); + int dki_index; + struct TALER_MINTDB_Deposit *deposit; + GNUNET_assert (GNUNET_SYSERR != + (dki_index = cmd_find(state->cmd, + state->cmd[state->i] + .details.insert_deposit.label_dki))); + GNUNET_assert (NULL != + (deposit = PERF_TALER_MINTDB_deposit_init ( + state->cmd[dki_index].exposed.dki))); GNUNET_assert ( state->plugin->insert_deposit (state->plugin->cls, @@ -450,12 +462,15 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GET_DEPOSIT: { - struct TALER_MINTDB_Deposit *deposit = - state->cmd[cmd_find (state->cmd, - state->cmd[state->i] - .details.get_deposit.label_source)] - .exposed.deposit; // Get the deposit from the source - GNUNET_assert (NULL != deposit); + int source_index; + struct TALER_MINTDB_Deposit *deposit; + + GNUNET_assert (GNUNET_SYSERR != + (source_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.get_deposit.label_source))); + GNUNET_assert (NULL != + (deposit = state->cmd[source_index].exposed.deposit)); state->plugin->have_deposit (state->plugin->cls, state->session, deposit); @@ -465,10 +480,12 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_INSERT_RESERVE: { struct TALER_MINTDB_Reserve *reserve; - json_t *details = json_pack ("si","justification", - GNUNET_CRYPTO_random_u32 ( - GNUNET_CRYPTO_QUALITY_WEAK, - UINT32_MAX)); + json_t *details = NULL; + GNUNET_assert (NULL != + (details = json_pack ("{s:i}","justification", + GNUNET_CRYPTO_random_u32 ( + GNUNET_CRYPTO_QUALITY_WEAK, + UINT32_MAX)))); reserve = PERF_TALER_MINTDB_reserve_init (); state->plugin->reserves_in_insert ( state->plugin->cls, @@ -484,15 +501,19 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GET_RESERVE: { - struct TALER_MINTDB_Reserve *reserve = - state->cmd[cmd_find (state->cmd, - state->cmd[state->i] - .details.get_reserve.label_source)] - .exposed.reserve; // Get the deposit from the source - - state->plugin->reserve_get (state->plugin->cls, - state->session, - reserve); + int source_index; + struct TALER_MINTDB_Reserve *reserve; + + GNUNET_assert (GNUNET_SYSERR != + (source_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.get_reserve.label_source))); + GNUNET_assert (NULL != + (reserve = state->cmd[source_index].exposed.reserve)); + GNUNET_assert (GNUNET_OK == + (state->plugin->reserve_get (state->plugin->cls, + state->session, + reserve))); } break; @@ -511,11 +532,15 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GET_DENOMINATION: { - struct TALER_MINTDB_DenominationKeyIssueInformation *dki = - state->cmd[cmd_find (state->cmd, - state->cmd[state->i] - .details.get_denomination.label_source)] - .exposed.dki; + int source_index; + struct TALER_MINTDB_DenominationKeyIssueInformation *dki; + + GNUNET_assert (GNUNET_SYSERR != + (source_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.get_denomination.label_source))); + GNUNET_assert (NULL != + (dki = state->cmd[source_index].exposed.dki)); state->plugin->get_denomination_info (state->plugin->cls, state->session, &dki->denom_pub, @@ -525,8 +550,22 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW: { - struct TALER_MINTDB_CollectableBlindcoin *blindcoin = - PERF_TALER_MINTDB_collectable_blindcoin_init (); + int dki_index, reserve_index; + struct TALER_MINTDB_CollectableBlindcoin *blindcoin ; + + GNUNET_assert (GNUNET_SYSERR != + (dki_index = cmd_find ( + state->cmd, + state->cmd[state->i].details.insert_withdraw.label_dki))); + GNUNET_assert (GNUNET_SYSERR != + (reserve_index = cmd_find ( + state->cmd, + state->cmd[state->i].details.insert_withdraw.label_reserve))); + GNUNET_assert (NULL != + (blindcoin = + PERF_TALER_MINTDB_collectable_blindcoin_init ( + state->cmd[dki_index].exposed.dki, + state->cmd[reserve_index].exposed.reserve))); state->plugin->insert_withdraw_info (state->plugin->cls, state->session, @@ -537,12 +576,15 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GET_WITHDRAW: { - struct TALER_MINTDB_CollectableBlindcoin *blindcoin = - state->cmd[cmd_find (state->cmd, - state->cmd[state->i] - .details.get_denomination.label_source)] - .exposed.blindcoin; - + int source_index; + struct TALER_MINTDB_CollectableBlindcoin *blindcoin ; + + GNUNET_assert (GNUNET_SYSERR != + (source_index = cmd_find (state->cmd, + state->cmd[state->i] + .details.get_denomination.label_source))); + GNUNET_assert (NULL != + (blindcoin = state->cmd[source_index].exposed.blindcoin)); state->plugin->get_withdraw_info (state->plugin->cls, state->session, &blindcoin->h_coin_envelope, diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h index 49f06b6e..9f7ee420 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.h +++ b/src/mintdb/perf_taler_mintdb_interpreter.h @@ -46,6 +46,7 @@ .label = _label, \ .exposed_type = PERF_TALER_MINTDB_NONE \ } + /** * The begining of a loop * @param _label the name of the loop @@ -153,11 +154,12 @@ /** * Insert a deposit into the database */ -#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label) \ +#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_dki) \ { \ .command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\ .label = _label, \ .exposed_type = PERF_TALER_MINTDB_DEPOSIT, \ + .details.insert_deposit.label_dki = _label_dki, \ } /** @@ -177,8 +179,8 @@ */ #define PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE(_label) \ { \ - .command = PERF_TALER_MINTDB_CMD_INSERT_RESERVE \ - .label = _label \ + .command = PERF_TALER_MINTDB_CMD_INSERT_RESERVE, \ + .label = _label, \ .exposed_type = PERF_TALER_MINTDB_RESERVE \ } @@ -189,7 +191,7 @@ */ #define PERF_TALER_MINTDB_INIT_CMD_GET_RESERVE(_label, _label_source) \ { \ - .command = PERF_TALER_MINTDB_CMD_GET_RESERVE \ + .command = PERF_TALER_MINTDB_CMD_GET_RESERVE, \ .label = _label, \ .exposed_type = PERF_TALER_MINTDB_NONE, \ .details.get_reserve.label_source = _label_source \ @@ -199,11 +201,15 @@ /** * Inserts informations about a withdrawal in the database */ -#define PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW(_label) \ +#define PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_dki, _label_reserve) \ { \ .command = PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW, \ .label = _label, \ .exposed_type = PERF_TALER_MINTDB_BLINDCOIN, \ + .details.insert_withdraw = {\ + .label_dki = _label_dki, \ + .label.reserve = _label_reserve, \ + } \ }\ @@ -223,9 +229,9 @@ */ #define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \ { \ - .command = PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW, \ + .command = PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION, \ .label = _label, \ - .exposed_type = PERF_TALER_MINTDB_DENOMINATION_KEY, \ + .exposed_type = PERF_TALER_MINTDB_DENOMINATION_INFO, \ } /** @@ -445,6 +451,18 @@ struct PERF_TALER_MINTDB_CMD_load_array_details }; +/** + * Data used by the command insert_deposit + */ +struct PERF_TALER_MINTDB_CMD_insert_deposit_details +{ + /** + * Label of the source where the reserve used to create the coin is + */ + const char *label_dki; +}; + + /** * Extra data requiered for the GET_DEPOSIT command */ @@ -478,6 +496,22 @@ struct PERF_TALER_MINTDB_CMD_get_denomination_details }; +/** + * Extra data related to the get withdraw command + */ +struct PERF_TALER_MINTDB_CMD_insert_withdraw_details +{ + /** + * label of the denomination key used to sign the coin + */ + const char *label_dki; + + /** + * label of the reserve the money to mint the coin comes from + */ + const char *label_reserve; +}; + /** * Extra data requiered for refreshing coins */ @@ -500,10 +534,12 @@ union PERF_TALER_MINTDB_CMD_Details struct PERF_TALER_MINTDB_CMD_gauger_details gauger; struct PERF_TALER_MINTDB_CMD_save_array_details save_array; struct PERF_TALER_MINTDB_CMD_load_array_details load_array; + struct PERF_TALER_MINTDB_CMD_insert_deposit_details insert_deposit; struct PERF_TALER_MINTDB_CMD_get_deposit_details get_deposit; struct PERF_TALER_MINTDB_CMD_get_reserve_details get_reserve; struct PERF_TALER_MINTDB_CMD_get_denomination_details get_denomination; struct PERF_TALER_MINTDB_CMD_refresh_coin_details refresh; + struct PERF_TALER_MINTDB_CMD_insert_withdraw_details insert_withdraw; }; @@ -536,12 +572,6 @@ struct PERF_TALER_MINTDB_Cmd * Data easily accessible */ union PERF_TALER_MINTDB_Data exposed; - - /** - * GNUNET_YES if the exposed value hav been saved during last loop iteration - * GNUNET_NO if it hasn't - */ - unsigned int exposed_saved; }; diff --git a/src/mintdb/perf_taler_mintdb_values.h b/src/mintdb/perf_taler_mintdb_values.h index 4b982b8b..f0cdd4f1 100644 --- a/src/mintdb/perf_taler_mintdb_values.h +++ b/src/mintdb/perf_taler_mintdb_values.h @@ -24,7 +24,7 @@ #define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100 -#define PERF_TALER_MINTDB_NB_DEPOSIT_GET 10 +#define PERF_TALER_MINTDB_NB_DEPOSIT_GET 1 -- cgit v1.2.3 From 582e623b13457f372f22edd8d8c1c99d26e07626 Mon Sep 17 00:00:00 2001 From: Fournier Nicolas Date: Tue, 30 Jun 2015 09:23:04 +0200 Subject: initialization of the database --- src/mintdb/perf_taler_mintdb.c | 99 +++++--- src/mintdb/perf_taler_mintdb_init.c | 366 ++++++++++++++++------------- src/mintdb/perf_taler_mintdb_init.h | 103 +++++--- src/mintdb/perf_taler_mintdb_interpreter.c | 20 +- src/mintdb/perf_taler_mintdb_interpreter.h | 74 +++--- src/mintdb/perf_taler_mintdb_values.h | 11 +- 6 files changed, 398 insertions(+), 275 deletions(-) (limited to 'src') diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c index 50d351e2..58cf6d88 100644 --- a/src/mintdb/perf_taler_mintdb.c +++ b/src/mintdb/perf_taler_mintdb.c @@ -34,43 +34,74 @@ main (int argc, char ** argv) struct PERF_TALER_MINTDB_Cmd test[] = { // Denomination used to create coins - PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION ("denomination"), - - PERF_TALER_MINTDB_INIT_CMD_DEBUG ("denomination inserted"), - PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit", + PERF_TALER_MINTDB_INIT_CMD_LOOP ("01 - denomination loop", + PERF_TALER_MINTDB_NB_DENOMINATION_INIT), + PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"), + PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION ("01 - denomination"), + PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("01 - commit transaction"), + PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination", + "01 - denomination loop", + "01 - denomination", + PERF_TALER_MINTDB_NB_DENOMINATION_SAVE, + PERF_TALER_MINTDB_BLINDCOIN), + PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("01 - denomination loop end", + "01 - denomination loop"), + PERF_TALER_MINTDB_INIT_CMD_DEBUG ("01 - init denomination complete"), + // End of initialization + // Reserve initialization + PERF_TALER_MINTDB_INIT_CMD_LOOP ("02 - init reserve loop", + PERF_TALER_MINTDB_NB_RESERVE_INIT), + PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE ("02 - reserve"), + PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve", + "02 - init reserve loop", + "02 - reserve", + PERF_TALER_MINTDB_NB_RESERVE_SAVE, + PERF_TALER_MINTDB_RESERVE), + PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("02 - init reserve end loop", + "02 - init reserve loop"), + PERF_TALER_MINTDB_INIT_CMD_DEBUG ("02 - reserve init complete"), + // End reserve init + // Withdrawal initialization + PERF_TALER_MINTDB_INIT_CMD_LOOP ("03 - init withdraw loop", + PERF_TALER_MINTDB_NB_WITHDRAW_INIT), + // PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("03 - start transaction"), + PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load", + "03 - init withdraw loop", + "01 - save denomination"), + PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load", + "03 - init withdraw loop", + "02 - save reserve"), + PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW ("03 - withdraw", + "03 - denomination load", + "03 - reserve load"), + // PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("03 - commit transaction"), + PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("03 - blindcoin array", + "03 - init withdraw loop", + "03 - withdraw", + PERF_TALER_MINTDB_NB_WITHDRAW_SAVE, + PERF_TALER_MINTDB_BLINDCOIN), + PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop", + "03 - init withdraw loop"), + PERF_TALER_MINTDB_INIT_CMD_DEBUG ("03 - withdraw init complete"), + //End of withdrawal initialization + //Deposit initialization + PERF_TALER_MINTDB_INIT_CMD_LOOP ("04 - deposit init loop", PERF_TALER_MINTDB_NB_DEPOSIT_INIT), - PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_init"), - PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("init_deposit_insert", - "denomination"), - PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"), - PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("array_depo", - "loop_db_init_deposit", - "init_deposit_insert", - PERF_TALER_MINTDB_NB_DEPOSIT_GET, + PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"), + PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit", + "01 - denomination"), + PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"), + PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", + "04 - deposit init loop", + "04 - deposit", + PERF_TALER_MINTDB_NB_DEPOSIT_SAVE, PERF_TALER_MINTDB_DEPOSIT), - PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit", - "loop_db_init_deposit"), - // End of database initialization - PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_start"), - PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_deposit_get", - PERF_TALER_MINTDB_NB_DEPOSIT_GET), - PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_get"), - PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("load_deposit", - "loop_deposit_get", - "array_depo"), - PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT ("get_deposit", - "load_deposit"), - PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"), - PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("stop2", "loop_deposit_get"), - PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_end"), - PERF_TALER_MINTDB_INIT_CMD_GAUGER ("deposit_get_commit", - "deposit_get_start", - "deposit_get_end", - "time per deposit check", - PERF_TALER_MINTDB_NB_DEPOSIT_GET), - PERF_TALER_MINTDB_INIT_CMD_END("end"), + PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("04 - deposit init loop end", + "04 - deposit init loop"), + PERF_TALER_MINTDB_INIT_CMD_DEBUG ("04 - deposit init complete"), + // End of deposit initialization + PERF_TALER_MINTDB_INIT_CMD_END ("end"), }; - // Plugin init GNUNET_log_setup ("perf-taler-mintdb", "WARNING", diff --git a/src/mintdb/perf_taler_mintdb_init.c b/src/mintdb/perf_taler_mintdb_init.c index f93bd828..a0019f84 100644 --- a/src/mintdb/perf_taler_mintdb_init.c +++ b/src/mintdb/perf_taler_mintdb_init.c @@ -30,108 +30,115 @@ /** - * @return a randomly generated CollectableBlindcoin + * Generate a dummy DenominationKeyInformation for testing purposes + * @return a dummy denomination key */ -struct TALER_MINTDB_CollectableBlindcoin * -PERF_TALER_MINTDB_collectable_blindcoin_init ( - const struct TALER_MINTDB_DenominationKeyIssueInformation *dki, - const struct TALER_MINTDB_Reserve *reserve) +struct TALER_MINTDB_DenominationKeyIssueInformation * +PERF_TALER_MINTDB_denomination_init () { - uint32_t random_int; - struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key; - struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key; - struct { - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - uint32_t data; - } unsigned_data; - struct TALER_MINTDB_CollectableBlindcoin *coin; - + struct TALER_MINTDB_DenominationKeyIssueInformation *dki; + struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt; + struct GNUNET_TIME_Absolute anchor; + struct TALER_Amount amount; - GNUNET_assert (NULL != - (coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin))); GNUNET_assert (NULL != - (reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ())); + (dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation))); GNUNET_assert (NULL != - (denomination_key = GNUNET_CRYPTO_rsa_private_key_create (512))); + (dki->denom_priv.rsa_private_key + = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_MINTDB_RSA_SIZE))); GNUNET_assert (NULL != - (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); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1.1", - &coin->amount_with_fee)); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1.1", - &coin->withdraw_fee)); - random_int = - GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); + (dki->denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key))); + GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, + &dki->issue.denom_hash); GNUNET_assert (NULL != - (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); - unsigned_data.purpose.size = htonl (sizeof (unsigned_data)); - unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST); - unsigned_data.data = htonl (random_int); + (master_prvt = GNUNET_CRYPTO_eddsa_key_create ())); + GNUNET_CRYPTO_eddsa_key_get_public (master_prvt, + &dki->issue.master.eddsa_pub); + anchor = GNUNET_TIME_absolute_get (); + dki->issue.start = GNUNET_TIME_absolute_hton (anchor); + dki->issue.expire_withdraw = + GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor, + GNUNET_TIME_relative_get_hour_ ())); + dki->issue.expire_spend = + GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor, + GNUNET_TIME_relative_get_hour_ ())); + dki->issue.expire_legal = + GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor, + GNUNET_TIME_relative_get_hour_ ())); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (reserve_sig_key, - (struct GNUNET_CRYPTO_EccSignaturePurpose *) &unsigned_data, - &coin->reserve_sig.eddsa_signature)); - GNUNET_free (reserve_sig_key); - GNUNET_CRYPTO_rsa_private_key_free (denomination_key); - return coin; + TALER_string_to_amount (CURRENCY ":1.1", &amount)); + TALER_amount_hton (&dki->issue.value, &amount); + TALER_amount_hton (&dki->issue.fee_withdraw, &amount); + TALER_amount_hton (&dki->issue.fee_deposit, &amount); + TALER_amount_hton (&dki->issue.fee_refresh, &amount); + dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); + dki->issue.purpose.size = + htonl (sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation) - + offsetof (struct TALER_MINTDB_DenominationKeyIssueInformation, + issue.purpose)); + GNUNET_assert (GNUNET_OK == + GNUNET_CRYPTO_eddsa_sign (master_prvt, + &dki->issue.purpose, + &dki->issue.signature.eddsa_signature)); + GNUNET_free (master_prvt); + + return dki; } -struct TALER_MINTDB_CollectableBlindcoin * -PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin) +/** + * Copies the given denomination + * @param reserve the deposit copy + * @return a copy of @a deposit; NULL if error + */ +struct TALER_MINTDB_DenominationKeyIssueInformation * +PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki) { - struct TALER_MINTDB_CollectableBlindcoin *copy; + struct TALER_MINTDB_DenominationKeyIssueInformation *copy; - GNUNET_assert (NULL != - (copy = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin))); - *copy = *coin; - // No signature copy function found, Hacking it in + GNUNET_assert (NULL != + (copy = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation))); + *copy = *dki; { char *buffer = NULL; int size; GNUNET_assert (0 < - (size = GNUNET_CRYPTO_rsa_signature_encode ( - coin->sig.rsa_signature, + (size = GNUNET_CRYPTO_rsa_private_key_encode ( + dki->denom_priv.rsa_private_key, &buffer))); GNUNET_assert (NULL != - (copy->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_decode( - buffer, - size))); + (copy->denom_priv.rsa_private_key = + GNUNET_CRYPTO_rsa_private_key_decode(buffer, size))); GNUNET_free (buffer); } GNUNET_assert (NULL != (copy->denom_pub.rsa_public_key = - GNUNET_CRYPTO_rsa_public_key_dup (coin->denom_pub.rsa_public_key))); + GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key))); return copy; } + /** - * Liberate memory of @a coin + * Free memory of a DenominationKeyIssueInformation + * @param dki pointer to the struct to free */ int -PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin) +PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki) { - if (NULL == coin) + if (NULL ==dki) return GNUNET_OK; + GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key); + GNUNET_free (dki); - GNUNET_CRYPTO_rsa_signature_free (coin->sig.rsa_signature); - GNUNET_CRYPTO_rsa_public_key_free (coin->denom_pub.rsa_public_key); - GNUNET_free (coin); return GNUNET_OK; } /** - * @return a randomly generated reserve + * Generate a dummy reserve for testing + * @return a reserve with 1000 EUR in it */ struct TALER_MINTDB_Reserve * PERF_TALER_MINTDB_reserve_init () @@ -146,14 +153,18 @@ PERF_TALER_MINTDB_reserve_init () GNUNET_CRYPTO_eddsa_key_get_public (reserve_priv , &reserve->pub.eddsa_pub); GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1.1", &reserve->balance)); + TALER_string_to_amount (CURRENCY ":1000", &reserve->balance)); reserve->expiry = GNUNET_TIME_absolute_get_forever_ (); GNUNET_free (reserve_priv); return reserve; } - +/** + * Copies the given reserve + * @param reserve the reserve to copy + * @return a copy of @a reserve; NULL if error + */ struct TALER_MINTDB_Reserve * PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve) { @@ -165,6 +176,7 @@ PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve) /** * Free memory of a reserve + * @param reserve pointer to the structure to be freed */ int PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve) @@ -177,36 +189,8 @@ PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve) /** - * @return a randomly generated refresh session - */ -struct TALER_MINTDB_RefreshSession * -PERF_TALER_MINTDB_refresh_session_init () -{ - struct TALER_MINTDB_RefreshSession *refresh_session; - - GNUNET_assert (NULL != - (refresh_session = GNUNET_new (struct TALER_MINTDB_RefreshSession))); - refresh_session->noreveal_index = 1; - refresh_session->num_oldcoins = 1; - refresh_session->num_newcoins = 1; - - return refresh_session; -} - - -/** - * Free a refresh session - */ -int -PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refresh_session) -{ - GNUNET_free (refresh_session); - return GNUNET_OK; -} - - -/** - * Create a randomly generated deposit + * Generate a dummy deposit for testing purposes + * @param dki the denomination key used to sign the key */ struct TALER_MINTDB_Deposit * PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki) @@ -275,8 +259,8 @@ PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueIn GNUNET_assert(NULL != (eddsa_prv = GNUNET_CRYPTO_eddsa_key_create ())); GNUNET_CRYPTO_eddsa_key_get_public ( - eddsa_prv, - &merchant_pub.eddsa_pub); + eddsa_prv, + &merchant_pub.eddsa_pub); GNUNET_free (eddsa_prv); } GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, @@ -305,6 +289,11 @@ PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueIn } +/** + * Copies the given deposit + * @param reserve the deposit copy + * @return a copy of @a deposit; NULL if error + */ struct TALER_MINTDB_Deposit * PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit) { @@ -334,6 +323,7 @@ PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit) /** * Free memory of a deposit + * @param deposit pointer to the structure to free */ int PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit) @@ -350,102 +340,150 @@ PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit) /** - * Generate a randomly generate DenominationKeyInformation + * Generate a CollectableBlindcoin for testing purpuses + * @param dki denomination key used to sign the coin + * @param reserve reserve providing the money for the coin + * @return a randomly generated CollectableBlindcoin */ -struct TALER_MINTDB_DenominationKeyIssueInformation * -PERF_TALER_MINTDB_denomination_init () +struct TALER_MINTDB_CollectableBlindcoin * +PERF_TALER_MINTDB_collectable_blindcoin_init ( + const struct TALER_MINTDB_DenominationKeyIssueInformation *dki, + const struct TALER_MINTDB_Reserve *reserve) { - struct TALER_MINTDB_DenominationKeyIssueInformation *dki; - struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt; - struct GNUNET_TIME_Absolute anchor; - struct TALER_Amount amount; + uint32_t random_int; + struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key; + struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key; + struct { + struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + uint32_t data; + } unsigned_data; + struct TALER_MINTDB_CollectableBlindcoin *coin; + + GNUNET_assert (NULL != + (coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin))); GNUNET_assert (NULL != - (dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation))); - GNUNET_assert (NULL != - (dki->denom_priv.rsa_private_key - = 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))); - GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, - &dki->issue.denom_hash); + (reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ())); + { + char *buffer = NULL; + int size; + GNUNET_assert (0 < + (size = GNUNET_CRYPTO_rsa_private_key_encode ( + dki->denom_priv.rsa_private_key, + &buffer))); + GNUNET_assert (NULL != + (denomination_key = + GNUNET_CRYPTO_rsa_private_key_decode (buffer, size))); + GNUNET_free (buffer); + } + GNUNET_assert (NULL != - (master_prvt = GNUNET_CRYPTO_eddsa_key_create ())); - GNUNET_CRYPTO_eddsa_key_get_public (master_prvt, - &dki->issue.master.eddsa_pub); - anchor = GNUNET_TIME_absolute_get (); - dki->issue.start = GNUNET_TIME_absolute_hton (anchor); - dki->issue.expire_withdraw = - GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor, - GNUNET_TIME_relative_get_hour_ ())); - dki->issue.expire_spend = - GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor, - GNUNET_TIME_relative_get_hour_ ())); - dki->issue.expire_legal = - GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor, - GNUNET_TIME_relative_get_hour_ ())); + (coin->denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key))); + coin->reserve_pub.eddsa_pub = reserve->pub.eddsa_pub; GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1.1", &amount)); - TALER_amount_hton (&dki->issue.value, &amount); - TALER_amount_hton (&dki->issue.fee_withdraw, &amount); - TALER_amount_hton (&dki->issue.fee_deposit, &amount); - TALER_amount_hton (&dki->issue.fee_refresh, &amount); - dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); - dki->issue.purpose.size = - htonl (sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation) - - offsetof (struct TALER_MINTDB_DenominationKeyIssueInformation, - issue.purpose)); + TALER_string_to_amount (CURRENCY ":1.1", + &coin->amount_with_fee)); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (master_prvt, - &dki->issue.purpose, - &dki->issue.signature.eddsa_signature)); - GNUNET_free (master_prvt); - - return dki; + TALER_string_to_amount (CURRENCY ":1.1", + &coin->withdraw_fee)); + random_int = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); + GNUNET_assert (NULL != + (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); + unsigned_data.purpose.size = htonl (sizeof (unsigned_data)); + unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST); + unsigned_data.data = htonl (random_int); + GNUNET_assert (GNUNET_OK == + GNUNET_CRYPTO_eddsa_sign (reserve_sig_key, + (struct GNUNET_CRYPTO_EccSignaturePurpose *) &unsigned_data, + &coin->reserve_sig.eddsa_signature)); + GNUNET_free (reserve_sig_key); + GNUNET_CRYPTO_rsa_private_key_free (denomination_key); + return coin; } - -struct TALER_MINTDB_DenominationKeyIssueInformation * -PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki) +/** + * Copies the given coin + * @param coin the coin to copy + * @return a copy of coin; NULL if error + */ +struct TALER_MINTDB_CollectableBlindcoin * +PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin) { - struct TALER_MINTDB_DenominationKeyIssueInformation *copy; + struct TALER_MINTDB_CollectableBlindcoin *copy; - GNUNET_assert (NULL != - (copy = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation))); - *copy = *dki; + GNUNET_assert (NULL != + (copy = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin))); + *copy = *coin; + // No signature copy function found, Hacking it in { char *buffer = NULL; int size; GNUNET_assert (0 < - (size = GNUNET_CRYPTO_rsa_private_key_encode ( - dki->denom_priv.rsa_private_key, + (size = GNUNET_CRYPTO_rsa_signature_encode ( + coin->sig.rsa_signature, &buffer))); GNUNET_assert (NULL != - (copy->denom_priv.rsa_private_key = - GNUNET_CRYPTO_rsa_private_key_decode(buffer, size))); + (copy->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_decode( + buffer, + size))); GNUNET_free (buffer); } GNUNET_assert (NULL != (copy->denom_pub.rsa_public_key = - GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key))); + GNUNET_CRYPTO_rsa_public_key_dup (coin->denom_pub.rsa_public_key))); return copy; } - /** - * Free memory for a DenominationKeyIssueInformation + * Liberate memory of @a coin + * @param coin pointer to the structure to free */ int -PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki) +PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin) { - if (NULL ==dki) + if (NULL == coin) return GNUNET_OK; - GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key); - GNUNET_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key); - GNUNET_free (dki); + GNUNET_CRYPTO_rsa_signature_free (coin->sig.rsa_signature); + GNUNET_CRYPTO_rsa_public_key_free (coin->denom_pub.rsa_public_key); + GNUNET_free (coin); + return GNUNET_OK; +} + + +/** + * @return a randomly generated refresh session + */ +struct TALER_MINTDB_RefreshSession * +PERF_TALER_MINTDB_refresh_session_init () +{ + struct TALER_MINTDB_RefreshSession *refresh_session; + + GNUNET_assert (NULL != + (refresh_session = GNUNET_new (struct TALER_MINTDB_RefreshSession))); + refresh_session->noreveal_index = 1; + refresh_session->num_oldcoins = 1; + refresh_session->num_newcoins = 1; + + return refresh_session; +} + + +/** + * Free a refresh session + */ +int +PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refresh_session) +{ + GNUNET_free (refresh_session); return GNUNET_OK; } diff --git a/src/mintdb/perf_taler_mintdb_init.h b/src/mintdb/perf_taler_mintdb_init.h index 3e2eb3cc..4682f800 100644 --- a/src/mintdb/perf_taler_mintdb_init.h +++ b/src/mintdb/perf_taler_mintdb_init.h @@ -27,70 +27,72 @@ #define CURRENCY "EUR" + /** - * @return a randomly generated CollectableBlindcoin + * Generate a dummy DenominationKeyInformation for testing purposes + * @return a dummy denomination key */ -struct TALER_MINTDB_CollectableBlindcoin * -PERF_TALER_MINTDB_collectable_blindcoin_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki, - const struct TALER_MINTDB_Reserve *reserve); +struct TALER_MINTDB_DenominationKeyIssueInformation * +PERF_TALER_MINTDB_denomination_init (void); + /** - * @returns a copy of @a coin + * Copies the given denomination + * @param reserve the deposit copy + * @return a copy of @a deposit; NULL if error */ -struct TALER_MINTDB_CollectableBlindcoin * -PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin); +struct TALER_MINTDB_DenominationKeyIssueInformation * +PERF_TALER_MINTDB_denomination_copy ( + const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); /** - * Liberate memory of @a coin + * Free memory of a DenominationKeyIssueInformation + * @param dki pointer to the struct to free */ int -PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin); +PERF_TALER_MINTDB_denomination_free ( + struct TALER_MINTDB_DenominationKeyIssueInformation *dki); /** - * @return a randomly generated reserve + * Generate a dummy reserve for testing + * @return a reserve with 1000 EUR in it */ struct TALER_MINTDB_Reserve * PERF_TALER_MINTDB_reserve_init (void); /** - * Returns a copy of @reserve + * Copies the given reserve + * @param reserve the reserve to copy + * @return a copy of @a reserve; NULL if error */ struct TALER_MINTDB_Reserve * PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve); -/** - * Frees memory allocated to @a reserve - */ -int -PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve); - /** - * @return a randomly generated refresh session - */ -struct TALER_MINTDB_RefreshSession * -PERF_TALER_MINTDB_refresh_session_init (void); - - -/** - * Frees memory of a refresh_session + * Free memory of a reserve + * @param reserve pointer to the structure to be freed */ int -PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refresh_session); +PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve); /** - * Create a randomly generated deposit + * Generate a dummy deposit for testing purposes + * @param dki the denomination key used to sign the key */ struct TALER_MINTDB_Deposit * -PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); +PERF_TALER_MINTDB_deposit_init ( + const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); /** - * @returns a copy of @a deposit + * Copies the given deposit + * @param reserve the deposit copy + * @return a copy of @a deposit; NULL if error */ struct TALER_MINTDB_Deposit * PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit); @@ -98,29 +100,41 @@ PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit); /** * Free memory of a deposit + * @param deposit pointer to the structure to free */ int PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit); /** - * Generate a randomly generate DenominationKeyInformation + * Generate a CollectableBlindcoin for testing purpuses + * @param dki denomination key used to sign the coin + * @param reserve reserve providing the money for the coin + * @return a randomly generated CollectableBlindcoin */ -struct TALER_MINTDB_DenominationKeyIssueInformation * -PERF_TALER_MINTDB_denomination_init (void); +struct TALER_MINTDB_CollectableBlindcoin * +PERF_TALER_MINTDB_collectable_blindcoin_init ( + const struct TALER_MINTDB_DenominationKeyIssueInformation *dki, + const struct TALER_MINTDB_Reserve *reserve); /** - * @returns a copy of @a dki + * Copies the given coin + * @param coin the coin to copy + * @return a copy of coin; NULL if error */ -struct TALER_MINTDB_DenominationKeyIssueInformation * -PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); +struct TALER_MINTDB_CollectableBlindcoin * +PERF_TALER_MINTDB_collectable_blindcoin_copy ( + const struct TALER_MINTDB_CollectableBlindcoin *coin); + /** - * Free memory for a DenominationKeyIssueInformation + * Liberate memory of @a coin + * @param coin pointer to the structure to free */ int -PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki); +PERF_TALER_MINTDB_collectable_blindcoin_free ( + struct TALER_MINTDB_CollectableBlindcoin *coin); /** @@ -135,4 +149,19 @@ PERF_TALER_MINTDB_coin_public_info_init (void); */ int PERF_TALER_MINTDB_coin_public_info_free (struct TALER_CoinPublicInfo *cpi); + +/** + * @return a randomly generated refresh session + */ +struct TALER_MINTDB_RefreshSession * +PERF_TALER_MINTDB_refresh_session_init (void); + + +/** + * Frees memory of a refresh_session + */ +int +PERF_TALER_MINTDB_refresh_session_free ( + struct TALER_MINTDB_RefreshSession *refresh_session); + #endif diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c index 25999792..c377c814 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.c +++ b/src/mintdb/perf_taler_mintdb_interpreter.c @@ -202,7 +202,7 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state) { unsigned int i; union PERF_TALER_MINTDB_Data zero = {0}; - unsigned int jump; + int jump; GNUNET_assert (GNUNET_SYSERR != (jump = cmd_find (state->cmd, state->cmd[state->i] @@ -235,7 +235,7 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state) static void interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) { - unsigned int loop_index, save_index; + int loop_index, save_index; unsigned int selection_chance; // Array initialization on first loop iteration @@ -314,7 +314,8 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) static void interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state) { - unsigned int loop_index, save_index, loop_iter, permut_index; + unsigned int loop_iter; + int loop_index, save_index; union PERF_TALER_MINTDB_Data zero = {0}; union PERF_TALER_MINTDB_Data *loaded_data; @@ -327,11 +328,18 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state) state->cmd[state->i] .details.load_array.label_save))); loop_iter = state->cmd[loop_index].details.loop.curr_iteration; - permut_index = state->cmd[state->i].details.load_array.permutation[loop_iter]; + { + int i, quotient; + quotient = loop_iter / state->cmd[save_index].details.save_array.nb_saved; + loop_iter = loop_iter % state->cmd[save_index].details.save_array.nb_saved; + for (i=0; i<=quotient; i++){ + loop_iter = state->cmd[state->i].details.load_array.permutation[loop_iter]; + } + } /* Extracting the data from the loop_indexth indice in save_index * array. */ - loaded_data = &state->cmd[save_index].details.save_array.data_saved[permut_index]; + loaded_data = &state->cmd[save_index].details.save_array.data_saved[loop_index]; switch (state->cmd[state->i].exposed_type) { case PERF_TALER_MINTDB_TIME: @@ -393,7 +401,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) case PERF_TALER_MINTDB_CMD_GAUGER: { - unsigned int start_index, stop_index; + int start_index, stop_index; struct timespec start, stop; unsigned long elapsed_ms; diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h index 9f7ee420..b69e39eb 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.h +++ b/src/mintdb/perf_taler_mintdb_interpreter.h @@ -38,7 +38,7 @@ /** - * + * Prints @ _label to stdout */ #define PERF_TALER_MINTDB_INIT_CMD_DEBUG(_label) \ { \ @@ -86,6 +86,10 @@ /** * Commits the duration between @a _label_start and @a _label_stop * to Gauger with @a _description explaining + * @param _label_start label of the start of the measurment + * @param _label_stop label of the end of the measurment + * @param _description description of the measure displayed in gauger + * @param _divide number of measurments in the interval */ #define PERF_TALER_MINTDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, _description, _divide) \ { \ @@ -151,27 +155,26 @@ .label_save = _label_save \ } \ } + /** - * Insert a deposit into the database + * Inserts informations about a denomination key in the database */ -#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_dki) \ +#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \ { \ - .command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\ + .command = PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION, \ .label = _label, \ - .exposed_type = PERF_TALER_MINTDB_DEPOSIT, \ - .details.insert_deposit.label_dki = _label_dki, \ + .exposed_type = PERF_TALER_MINTDB_DENOMINATION_INFO, \ } /** - * Check if a deposit is in the database - * @param _label_deposit Label of the deposit to use + * Polls the database about informations regarding a specific denomination key */ -#define PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \ +#define PERF_TALER_MINTDB_INIT_CMD_GET_DENOMINATION(_label, _label_source) \ { \ - .command = PERF_TALER_MINTDB_CMD_GET_DEPOSIT, \ + .command = PERF_TALER_MINTDB_CMD_GET_DENOMINATION, \ .label = _label, \ .exposed_type = PERF_TALER_MINTDB_NONE, \ - .details.get_deposit.label_source = _label_deposit \ + .details.get_denomination.label_source = _label_source, \ } /** @@ -199,50 +202,57 @@ /** - * Inserts informations about a withdrawal in the database + * Insert a deposit into the database + * @param _label_dki source to use for the denomination key */ -#define PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_dki, _label_reserve) \ +#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_dki) \ { \ - .command = PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW, \ + .command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\ .label = _label, \ - .exposed_type = PERF_TALER_MINTDB_BLINDCOIN, \ - .details.insert_withdraw = {\ - .label_dki = _label_dki, \ - .label.reserve = _label_reserve, \ - } \ -}\ + .exposed_type = PERF_TALER_MINTDB_DEPOSIT, \ + .details.insert_deposit.label_dki = _label_dki, \ +} /** - * Polls the database about informations regarding a secific withdrawal + * Check if a deposit is in the database + * @param _label_deposit Label of the deposit to use */ -#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \ +#define PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \ { \ - .command = PERF_TALER_MINTDB_CMD_GET_WITHDRAW, \ + .command = PERF_TALER_MINTDB_CMD_GET_DEPOSIT, \ .label = _label, \ .exposed_type = PERF_TALER_MINTDB_NONE, \ - .details.get_withdraw.label_source = _label_source, \ + .details.get_deposit.label_source = _label_deposit \ } + /** - * Inserts informations about a denomination key in the database + * Inserts informations about a withdrawal in the database + * @param _label_dki denomination key used to sign the coin + * @param _label_reserve reserve used to emmit the coin */ -#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \ +#define PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_dki, _label_reserve) \ { \ - .command = PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION, \ + .command = PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW, \ .label = _label, \ - .exposed_type = PERF_TALER_MINTDB_DENOMINATION_INFO, \ + .exposed_type = PERF_TALER_MINTDB_BLINDCOIN, \ + .details.insert_withdraw = {\ + .label_dki = _label_dki, \ + .label_reserve = _label_reserve, \ + } \ } + /** - * Polls the database about informations regarding a specific denomination key + * Polls the database about informations regarding a secific withdrawal */ -#define PERF_TALER_MINTDB_INIT_CMD_GET_DENOMINATION(_label, _label_source) \ +#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \ { \ - .command = PERF_TALER_MINTDB_CMD_GET_DENOMINATION, \ + .command = PERF_TALER_MINTDB_CMD_GET_WITHDRAW, \ .label = _label, \ .exposed_type = PERF_TALER_MINTDB_NONE, \ - .details.get_denomination.label_source = _label_source, \ + .details.get_withdraw.label_source = _label_source, \ } diff --git a/src/mintdb/perf_taler_mintdb_values.h b/src/mintdb/perf_taler_mintdb_values.h index f0cdd4f1..f8a8fde0 100644 --- a/src/mintdb/perf_taler_mintdb_values.h +++ b/src/mintdb/perf_taler_mintdb_values.h @@ -22,10 +22,17 @@ #define __PERF_TALER_MINTDB__VALUES_H__ +#define PERF_TALER_MINTDB_NB_DENOMINATION_INIT 100 +#define PERF_TALER_MINTDB_NB_DENOMINATION_SAVE 100 -#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100 -#define PERF_TALER_MINTDB_NB_DEPOSIT_GET 1 +#define PERF_TALER_MINTDB_NB_RESERVE_INIT 10000 +#define PERF_TALER_MINTDB_NB_RESERVE_SAVE 1000 +#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100000 +#define PERF_TALER_MINTDB_NB_DEPOSIT_SAVE 1000 + +#define PERF_TALER_MINTDB_NB_WITHDRAW_INIT 100000 +#define PERF_TALER_MINTDB_NB_WITHDRAW_SAVE 1000 #endif -- cgit v1.2.3 From 585287dc8d779deef7052a5455c2eded09f4d965 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 30 Jun 2015 13:55:39 +0200 Subject: fix #3869: outdated FSF address --- doc/logos/fonts/perpetue/Perpetua Bold Italic.ttf | Bin 75620 -> 0 bytes doc/logos/fonts/perpetue/Perpetua Bold.ttf | Bin 58512 -> 0 bytes doc/logos/fonts/perpetue/Perpetua Italic.ttf | Bin 76080 -> 0 bytes doc/logos/fonts/perpetue/Perpetua_Bold.ttf | Bin 0 -> 58512 bytes doc/logos/fonts/perpetue/Perpetua_Bold_Italic.ttf | Bin 0 -> 75620 bytes doc/logos/fonts/perpetue/Perpetua_Italic.ttf | Bin 0 -> 76080 bytes doc/logos/fonts/smoth_bight/ELUA-es.txt | 77 ++++++++++++ doc/logos/fonts/smoth_bight/ELUA.txt | 133 +++++++++++++++++++++ .../smoth_bight/End User Licence Agreement.txt | 133 --------------------- ...a de la fuente - Version en Espa\302\247ol.txt" | 77 ------------ .../smoth_bight/Smoth-Bight - Por Kustren.otf | Bin 50396 -> 0 bytes .../Smoth-Bight Italic - Por Kustren.otf | Bin 50820 -> 0 bytes doc/logos/fonts/smoth_bight/Smoth-Bight.otf | Bin 0 -> 50396 bytes src/util/os_installation.c | 4 +- 14 files changed, 212 insertions(+), 212 deletions(-) delete mode 100644 doc/logos/fonts/perpetue/Perpetua Bold Italic.ttf delete mode 100644 doc/logos/fonts/perpetue/Perpetua Bold.ttf delete mode 100644 doc/logos/fonts/perpetue/Perpetua Italic.ttf create mode 100644 doc/logos/fonts/perpetue/Perpetua_Bold.ttf create mode 100644 doc/logos/fonts/perpetue/Perpetua_Bold_Italic.ttf create mode 100644 doc/logos/fonts/perpetue/Perpetua_Italic.ttf create mode 100755 doc/logos/fonts/smoth_bight/ELUA-es.txt create mode 100755 doc/logos/fonts/smoth_bight/ELUA.txt delete mode 100755 doc/logos/fonts/smoth_bight/End User Licence Agreement.txt delete mode 100755 "doc/logos/fonts/smoth_bight/Licencia de la fuente - Version en Espa\302\247ol.txt" delete mode 100755 doc/logos/fonts/smoth_bight/Smoth-Bight - Por Kustren.otf delete mode 100755 doc/logos/fonts/smoth_bight/Smoth-Bight Italic - Por Kustren.otf create mode 100755 doc/logos/fonts/smoth_bight/Smoth-Bight.otf (limited to 'src') diff --git a/doc/logos/fonts/perpetue/Perpetua Bold Italic.ttf b/doc/logos/fonts/perpetue/Perpetua Bold Italic.ttf deleted file mode 100644 index 3882fe92..00000000 Binary files a/doc/logos/fonts/perpetue/Perpetua Bold Italic.ttf and /dev/null differ diff --git a/doc/logos/fonts/perpetue/Perpetua Bold.ttf b/doc/logos/fonts/perpetue/Perpetua Bold.ttf deleted file mode 100644 index c73833db..00000000 Binary files a/doc/logos/fonts/perpetue/Perpetua Bold.ttf and /dev/null differ diff --git a/doc/logos/fonts/perpetue/Perpetua Italic.ttf b/doc/logos/fonts/perpetue/Perpetua Italic.ttf deleted file mode 100644 index e4f295ed..00000000 Binary files a/doc/logos/fonts/perpetue/Perpetua Italic.ttf and /dev/null differ diff --git a/doc/logos/fonts/perpetue/Perpetua_Bold.ttf b/doc/logos/fonts/perpetue/Perpetua_Bold.ttf new file mode 100644 index 00000000..c73833db Binary files /dev/null and b/doc/logos/fonts/perpetue/Perpetua_Bold.ttf differ diff --git a/doc/logos/fonts/perpetue/Perpetua_Bold_Italic.ttf b/doc/logos/fonts/perpetue/Perpetua_Bold_Italic.ttf new file mode 100644 index 00000000..3882fe92 Binary files /dev/null and b/doc/logos/fonts/perpetue/Perpetua_Bold_Italic.ttf differ diff --git a/doc/logos/fonts/perpetue/Perpetua_Italic.ttf b/doc/logos/fonts/perpetue/Perpetua_Italic.ttf new file mode 100644 index 00000000..e4f295ed Binary files /dev/null and b/doc/logos/fonts/perpetue/Perpetua_Italic.ttf differ diff --git a/doc/logos/fonts/smoth_bight/ELUA-es.txt b/doc/logos/fonts/smoth_bight/ELUA-es.txt new file mode 100755 index 00000000..39833a36 --- /dev/null +++ b/doc/logos/fonts/smoth_bight/ELUA-es.txt @@ -0,0 +1,77 @@ +Contrato de licencia de usuario final e Inclusión del acuerdo de Software + +"Comprador " y "Usuario " se pueden utilizar indistintamente en el presente acuerdo . + + +La página oficial de lanzamiento de la fuente es: +http://kustren.deviantart.com/ + + + + Derechos de autor 2013 Kustren + Marcas 2013 licencia Kustren + Se prohíbe la distribución comercial, la representación y la impresión de la fuente y el trabajo derivado . + + + + + +Uso + +La fuente de Kustren llamada Smoth-Bight es freware en su mayoria, de uso libre, pero solo para fines personales y/o comerciales, no hay limite en la cantidad de copias realizadas de la mis ma fuente en los pcs que usted utilice. +Sin embargo no pueden ofrecer esta tipografia ni como suyas y/o comercializarla, tampoco estara permitida la descarga directa en otras paginas web, a menos que sea con consentimiento de su creador Kustren. +Si usted usa mi fuente deme creditos por ello y/o coloque la pagina web mia, esto es de agradecer. + +licencia del derecho de uso + +Esta fuente es para uso personal y/o comercial, puede ser usadas para cualquier tipo de trabajo, pero no podra ser modificadas de ningun tipo de manera. +Recuerden que si ustedes compran alguna tipografia no se convierten en propietariuo de la fuente, solo obtienen la licencia de uso, es decir la misma que estan leyendo. +Esta licencia es de multiuso, mi fuente pueden ser usadas en multiples computadores a la vez. + + + + + +pago + +El pago no es necesaria para el uso de esta fuente de software gratuito creada por kustren. + + + +apoyo + +Si tienen problema con la fuente (como problemas de espaciado o caracteres que faltan ) , por favor, compruebe que tiene la versión correcta y actualizada de la fuente. En el caso de fuentes de dominio público , la descarga de la fuente directamente desde el sitio http://kustren.deviantart.com/ se asegurará de que los archivos de fuentes no han sido alterados. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/logos/fonts/smoth_bight/ELUA.txt b/doc/logos/fonts/smoth_bight/ELUA.txt new file mode 100755 index 00000000..04209197 --- /dev/null +++ b/doc/logos/fonts/smoth_bight/ELUA.txt @@ -0,0 +1,133 @@ +End User License Agreement and Software Inclusion Agreement + + +"Purchaser" and "User" may be used interchangeably in this agreement. + + +The official release page is at kustren.deviantart.com/ + +or + + + + Copyright 2013 Kustren + Trademark 2013 Kustren licence + Commercial distribution, rendering and printing of the font and derived work is prohibited. + + + + + +Usage + +Smoth-Bight is freeware Font is free to use for personal and commercial purposes. No payment is necessary, and there is no limit to the amount of prints, pages, or other medium to be produced using them. However, you cannot offer the font for commercial sale, or offer for direct download. The inclusion othe font name and/or site URL in the credits or documentation when it is used is appreciated, but this is not mandatory. +My font is for personal and commercial use, can be used for any type of work, while nature, neither will be able to be modified in any kind of way. +This license is multipurpose, my font can be used on multiple computers at once. + + + + + +Payment + +Payment is not required for the use of kustren's freeware Font. + + + +Support + +If you experience problems with any Kustren's Freeware font (such as spacing issues or missing characters), please verify that you have the correct and current version of the fonts. In the case of Freeware font, downloading the font directly from the http://kustren.deviantart.com/ site will ensure that the font files have not been altered. + + + + +Copyright (c) 2014 by Kustren. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/logos/fonts/smoth_bight/End User Licence Agreement.txt b/doc/logos/fonts/smoth_bight/End User Licence Agreement.txt deleted file mode 100755 index 04209197..00000000 --- a/doc/logos/fonts/smoth_bight/End User Licence Agreement.txt +++ /dev/null @@ -1,133 +0,0 @@ -End User License Agreement and Software Inclusion Agreement - - -"Purchaser" and "User" may be used interchangeably in this agreement. - - -The official release page is at kustren.deviantart.com/ - -or - - - - Copyright 2013 Kustren - Trademark 2013 Kustren licence - Commercial distribution, rendering and printing of the font and derived work is prohibited. - - - - - -Usage - -Smoth-Bight is freeware Font is free to use for personal and commercial purposes. No payment is necessary, and there is no limit to the amount of prints, pages, or other medium to be produced using them. However, you cannot offer the font for commercial sale, or offer for direct download. The inclusion othe font name and/or site URL in the credits or documentation when it is used is appreciated, but this is not mandatory. -My font is for personal and commercial use, can be used for any type of work, while nature, neither will be able to be modified in any kind of way. -This license is multipurpose, my font can be used on multiple computers at once. - - - - - -Payment - -Payment is not required for the use of kustren's freeware Font. - - - -Support - -If you experience problems with any Kustren's Freeware font (such as spacing issues or missing characters), please verify that you have the correct and current version of the fonts. In the case of Freeware font, downloading the font directly from the http://kustren.deviantart.com/ site will ensure that the font files have not been altered. - - - - -Copyright (c) 2014 by Kustren. All rights reserved. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git "a/doc/logos/fonts/smoth_bight/Licencia de la fuente - Version en Espa\302\247ol.txt" "b/doc/logos/fonts/smoth_bight/Licencia de la fuente - Version en Espa\302\247ol.txt" deleted file mode 100755 index 39833a36..00000000 --- "a/doc/logos/fonts/smoth_bight/Licencia de la fuente - Version en Espa\302\247ol.txt" +++ /dev/null @@ -1,77 +0,0 @@ -Contrato de licencia de usuario final e Inclusión del acuerdo de Software - -"Comprador " y "Usuario " se pueden utilizar indistintamente en el presente acuerdo . - - -La página oficial de lanzamiento de la fuente es: -http://kustren.deviantart.com/ - - - - Derechos de autor 2013 Kustren - Marcas 2013 licencia Kustren - Se prohíbe la distribución comercial, la representación y la impresión de la fuente y el trabajo derivado . - - - - - -Uso - -La fuente de Kustren llamada Smoth-Bight es freware en su mayoria, de uso libre, pero solo para fines personales y/o comerciales, no hay limite en la cantidad de copias realizadas de la mis ma fuente en los pcs que usted utilice. -Sin embargo no pueden ofrecer esta tipografia ni como suyas y/o comercializarla, tampoco estara permitida la descarga directa en otras paginas web, a menos que sea con consentimiento de su creador Kustren. -Si usted usa mi fuente deme creditos por ello y/o coloque la pagina web mia, esto es de agradecer. - -licencia del derecho de uso - -Esta fuente es para uso personal y/o comercial, puede ser usadas para cualquier tipo de trabajo, pero no podra ser modificadas de ningun tipo de manera. -Recuerden que si ustedes compran alguna tipografia no se convierten en propietariuo de la fuente, solo obtienen la licencia de uso, es decir la misma que estan leyendo. -Esta licencia es de multiuso, mi fuente pueden ser usadas en multiples computadores a la vez. - - - - - -pago - -El pago no es necesaria para el uso de esta fuente de software gratuito creada por kustren. - - - -apoyo - -Si tienen problema con la fuente (como problemas de espaciado o caracteres que faltan ) , por favor, compruebe que tiene la versión correcta y actualizada de la fuente. En el caso de fuentes de dominio público , la descarga de la fuente directamente desde el sitio http://kustren.deviantart.com/ se asegurará de que los archivos de fuentes no han sido alterados. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/logos/fonts/smoth_bight/Smoth-Bight - Por Kustren.otf b/doc/logos/fonts/smoth_bight/Smoth-Bight - Por Kustren.otf deleted file mode 100755 index 33fd9793..00000000 Binary files a/doc/logos/fonts/smoth_bight/Smoth-Bight - Por Kustren.otf and /dev/null differ diff --git a/doc/logos/fonts/smoth_bight/Smoth-Bight Italic - Por Kustren.otf b/doc/logos/fonts/smoth_bight/Smoth-Bight Italic - Por Kustren.otf deleted file mode 100755 index 5fb25e64..00000000 Binary files a/doc/logos/fonts/smoth_bight/Smoth-Bight Italic - Por Kustren.otf and /dev/null differ diff --git a/doc/logos/fonts/smoth_bight/Smoth-Bight.otf b/doc/logos/fonts/smoth_bight/Smoth-Bight.otf new file mode 100755 index 00000000..33fd9793 Binary files /dev/null and b/doc/logos/fonts/smoth_bight/Smoth-Bight.otf differ diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 1308fa3f..ec1868a8 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /** -- cgit v1.2.3 From 245adcaab2cd866a476d0f3e48aa29f26c8fbc7f Mon Sep 17 00:00:00 2001 From: Fournier Nicolas Date: Tue, 30 Jun 2015 14:01:06 +0200 Subject: Using GNUNET logging rather than printf --- src/mintdb/perf_taler_mintdb.c | 4 +++- src/mintdb/perf_taler_mintdb_interpreter.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c index 58cf6d88..49fe073a 100644 --- a/src/mintdb/perf_taler_mintdb.c +++ b/src/mintdb/perf_taler_mintdb.c @@ -34,6 +34,8 @@ main (int argc, char ** argv) struct PERF_TALER_MINTDB_Cmd test[] = { // Denomination used to create coins + PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpretor"), + PERF_TALER_MINTDB_INIT_CMD_LOOP ("01 - denomination loop", PERF_TALER_MINTDB_NB_DENOMINATION_INIT), PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"), @@ -104,7 +106,7 @@ main (int argc, char ** argv) }; GNUNET_log_setup ("perf-taler-mintdb", - "WARNING", + "INFO", NULL); config = GNUNET_CONFIGURATION_create(); GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf"); diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c index c377c814..05907030 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.c +++ b/src/mintdb/perf_taler_mintdb_interpreter.c @@ -385,7 +385,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) return GNUNET_YES; case PERF_TALER_MINTDB_CMD_DEBUG: - printf ("%s\n", state->cmd[state->i].label); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", state->cmd[state->i].label); break; case PERF_TALER_MINTDB_CMD_LOOP: -- cgit v1.2.3 From d0a6b47099384e39e820687fe7b83628514a6382 Mon Sep 17 00:00:00 2001 From: Fournier Nicolas Date: Tue, 30 Jun 2015 18:18:31 +0200 Subject: Finished work on database initialization --- src/mintdb/perf_taler_mintdb.c | 18 +++---- src/mintdb/perf_taler_mintdb_init.c | 7 ++- src/mintdb/perf_taler_mintdb_interpreter.c | 76 +++++++++++++++++++----------- src/mintdb/perf_taler_mintdb_interpreter.h | 3 +- src/mintdb/perf_taler_mintdb_values.h | 16 +++---- 5 files changed, 70 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c index 49fe073a..53c9a1c2 100644 --- a/src/mintdb/perf_taler_mintdb.c +++ b/src/mintdb/perf_taler_mintdb.c @@ -44,8 +44,7 @@ main (int argc, char ** argv) PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination", "01 - denomination loop", "01 - denomination", - PERF_TALER_MINTDB_NB_DENOMINATION_SAVE, - PERF_TALER_MINTDB_BLINDCOIN), + PERF_TALER_MINTDB_NB_DENOMINATION_SAVE), PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("01 - denomination loop end", "01 - denomination loop"), PERF_TALER_MINTDB_INIT_CMD_DEBUG ("01 - init denomination complete"), @@ -57,8 +56,7 @@ main (int argc, char ** argv) PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve", "02 - init reserve loop", "02 - reserve", - PERF_TALER_MINTDB_NB_RESERVE_SAVE, - PERF_TALER_MINTDB_RESERVE), + PERF_TALER_MINTDB_NB_RESERVE_SAVE), PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("02 - init reserve end loop", "02 - init reserve loop"), PERF_TALER_MINTDB_INIT_CMD_DEBUG ("02 - reserve init complete"), @@ -80,8 +78,7 @@ main (int argc, char ** argv) PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("03 - blindcoin array", "03 - init withdraw loop", "03 - withdraw", - PERF_TALER_MINTDB_NB_WITHDRAW_SAVE, - PERF_TALER_MINTDB_BLINDCOIN), + PERF_TALER_MINTDB_NB_WITHDRAW_SAVE), PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop", "03 - init withdraw loop"), PERF_TALER_MINTDB_INIT_CMD_DEBUG ("03 - withdraw init complete"), @@ -90,14 +87,17 @@ main (int argc, char ** argv) PERF_TALER_MINTDB_INIT_CMD_LOOP ("04 - deposit init loop", PERF_TALER_MINTDB_NB_DEPOSIT_INIT), PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"), + PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("04 - denomination load", + "04 - deposit init loop", + "01 - save denomination"), + PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit", - "01 - denomination"), + "04 - denomination load"), PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"), PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", "04 - deposit init loop", "04 - deposit", - PERF_TALER_MINTDB_NB_DEPOSIT_SAVE, - PERF_TALER_MINTDB_DEPOSIT), + PERF_TALER_MINTDB_NB_DEPOSIT_SAVE), PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("04 - deposit init loop end", "04 - deposit init loop"), PERF_TALER_MINTDB_INIT_CMD_DEBUG ("04 - deposit init complete"), diff --git a/src/mintdb/perf_taler_mintdb_init.c b/src/mintdb/perf_taler_mintdb_init.c index a0019f84..ab55248c 100644 --- a/src/mintdb/perf_taler_mintdb_init.c +++ b/src/mintdb/perf_taler_mintdb_init.c @@ -230,8 +230,6 @@ PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueIn GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, &coin.coin_pub.eddsa_pub, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))); - - GNUNET_free (eddsa_prvt); } { //csig struct u32_presign @@ -359,7 +357,6 @@ PERF_TALER_MINTDB_collectable_blindcoin_init ( } unsigned_data; struct TALER_MINTDB_CollectableBlindcoin *coin; - GNUNET_assert (NULL != (coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin))); GNUNET_assert (NULL != @@ -376,7 +373,6 @@ PERF_TALER_MINTDB_collectable_blindcoin_init ( GNUNET_CRYPTO_rsa_private_key_decode (buffer, size))); GNUNET_free (buffer); } - GNUNET_assert (NULL != (coin->denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key))); @@ -394,6 +390,9 @@ PERF_TALER_MINTDB_collectable_blindcoin_init ( GNUNET_CRYPTO_rsa_sign (denomination_key, &random_int, sizeof (random_int)))); + char *buffer; + GNUNET_CRYPTO_rsa_signature_encode (coin->sig.rsa_signature, &buffer); + free (buffer); GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &coin->h_coin_envelope); unsigned_data.purpose.size = htonl (sizeof (unsigned_data)); diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c index 05907030..5a1ec292 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.c +++ b/src/mintdb/perf_taler_mintdb_interpreter.c @@ -50,6 +50,7 @@ struct PERF_TALER_MINTDB_interpreter_state unsigned int i; }; + /** * Free the memory of @a data, with data of type @a type */ @@ -89,7 +90,6 @@ data_free (union PERF_TALER_MINTDB_Data *data, enum PERF_TALER_MINTDB_Type type) } - /** * Finds the first command in cmd with the name search * @@ -121,14 +121,25 @@ cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[]) switch (cmd[i].command) { case PERF_TALER_MINTDB_CMD_SAVE_ARRAY: - // Allocation of memory for saving data + { + int save_label; + + GNUNET_assert (GNUNET_SYSERR != + (save_label = cmd_find (cmd, + cmd[i].details.save_array.label_save))); + /* Allocation of memory for saving data */ cmd[i].details.save_array.data_saved = GNUNET_new_array (cmd[i].details.save_array.nb_saved, union PERF_TALER_MINTDB_Data); + /* Getting the type saved from the given label */ + cmd[i].details.save_array.type_saved = + cmd[save_label].exposed_type; + } + break; case PERF_TALER_MINTDB_CMD_LOAD_ARRAY: - // Creating the permutation array to randomize the data order + /* Creating the permutation array to randomize the data order */ { int save_index ; @@ -141,7 +152,7 @@ cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[]) GNUNET_CRYPTO_random_permute ( GNUNET_CRYPTO_QUALITY_WEAK, cmd[save_index].details.save_array.nb_saved))); - // Initializing the type based on the type of the saved array + /* Initializing the type based on the type of the saved array */ cmd[i].exposed_type = cmd[save_index].details.save_array.type_saved; } break; @@ -215,14 +226,14 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state) } state->cmd[jump].details.loop.curr_iteration++; - // If the loop is not finished + /* If the loop is not finished */ if (state->cmd[jump].details.loop.max_iterations > state->cmd[jump].details.loop.curr_iteration) { - // jump back to the start + /* jump back to the start */ state->i = jump; }else{ - // Reset the loop counter and continue running + /* Reset the loop counter and continue running */ state->cmd[jump].details.loop.curr_iteration = 0; } } @@ -238,8 +249,6 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) int loop_index, save_index; unsigned int selection_chance; - // Array initialization on first loop iteration - // Alows for nested loops GNUNET_assert (GNUNET_SYSERR != (loop_index = cmd_find (state->cmd, state->cmd[state->i] @@ -248,19 +257,21 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) (save_index = cmd_find (state->cmd, state->cmd[state->i] .details.save_array.label_save))); - if (0 == state->cmd[loop_index].details.loop.curr_iteration) + /* Array initialization on first loop iteration + Alows for nested loops */ + if (0 == state->cmd[loop_index].details.loop.curr_iteration) { state->cmd[state->i].details.save_array.index = 0; } - // 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. + /* 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. */ selection_chance = state->cmd[loop_index].details.loop.max_iterations / state->cmd[state->i].details.save_array.nb_saved; /* - * If the remaining sapce is equal to the remaining number of + * If the remaining space is equal to the remaining number of * iterations, the item is automaticly saved. * - * Else it is saved only if rdn is 0 + * Else it is saved only if the random numbre generated is 0 */ if ((0 < (state->cmd[state->i].details.save_array.nb_saved - state->cmd[state->i].details.save_array.index)) && @@ -311,14 +322,17 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state) } +/** + * Run when the current command is LOAD_ARRAY + * Get data from a SAVE_ARRAY and exposes a copy + */ static void interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state) { unsigned int loop_iter; int loop_index, save_index; - union PERF_TALER_MINTDB_Data zero = {0}; union PERF_TALER_MINTDB_Data *loaded_data; - + GNUNET_assert (GNUNET_SYSERR != (loop_index = cmd_find (state->cmd, state->cmd[state->i] @@ -330,16 +344,18 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state) loop_iter = state->cmd[loop_index].details.loop.curr_iteration; { int i, quotient; + + /* in case the iteration number is higher than the amount saved, + * the number is run several times in the permutation array */ quotient = loop_iter / state->cmd[save_index].details.save_array.nb_saved; loop_iter = loop_iter % state->cmd[save_index].details.save_array.nb_saved; - for (i=0; i<=quotient; i++){ + for (i=0; i<=quotient; i++) loop_iter = state->cmd[state->i].details.load_array.permutation[loop_iter]; - } } /* Extracting the data from the loop_indexth indice in save_index * array. */ - loaded_data = &state->cmd[save_index].details.save_array.data_saved[loop_index]; + loaded_data = &state->cmd[save_index].details.save_array.data_saved[loop_iter]; switch (state->cmd[state->i].exposed_type) { case PERF_TALER_MINTDB_TIME: @@ -347,26 +363,32 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state) break; case PERF_TALER_MINTDB_DEPOSIT: - state->cmd[state->i].exposed.deposit = loaded_data->deposit; + state->cmd[state->i].exposed.deposit = + PERF_TALER_MINTDB_deposit_copy (loaded_data->deposit); break; case PERF_TALER_MINTDB_BLINDCOIN: - state->cmd[state->i].exposed.blindcoin = loaded_data->blindcoin; + state->cmd[state->i].exposed.blindcoin = + PERF_TALER_MINTDB_collectable_blindcoin_copy (loaded_data->blindcoin); break; case PERF_TALER_MINTDB_RESERVE: - state->cmd[state->i].exposed.reserve = loaded_data->reserve; + state->cmd[state->i].exposed.reserve = + PERF_TALER_MINTDB_reserve_copy (loaded_data->reserve); break; case PERF_TALER_MINTDB_DENOMINATION_INFO: - state->cmd[state->i].exposed.dki = loaded_data->dki; + state->cmd[state->i].exposed.dki = + PERF_TALER_MINTDB_denomination_copy (loaded_data->dki); + break; case PERF_TALER_MINTDB_COIN_INFO: state->cmd[state->i].exposed.cpi = loaded_data->cpi; + break; + default: break; } - *loaded_data = zero; } /** @@ -472,7 +494,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) { int source_index; struct TALER_MINTDB_Deposit *deposit; - + GNUNET_assert (GNUNET_SYSERR != (source_index = cmd_find (state->cmd, state->cmd[state->i] @@ -511,7 +533,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) { int source_index; struct TALER_MINTDB_Reserve *reserve; - + GNUNET_assert (GNUNET_SYSERR != (source_index = cmd_find (state->cmd, state->cmd[state->i] @@ -560,7 +582,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) { int dki_index, reserve_index; struct TALER_MINTDB_CollectableBlindcoin *blindcoin ; - + GNUNET_assert (GNUNET_SYSERR != (dki_index = cmd_find ( state->cmd, diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h index b69e39eb..1d64c393 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.h +++ b/src/mintdb/perf_taler_mintdb_interpreter.h @@ -128,7 +128,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_SAVE_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) \ { \ .command = PERF_TALER_MINTDB_CMD_SAVE_ARRAY, \ .label = _label, \ @@ -137,7 +137,6 @@ .label_loop = _label_loop, \ .label_save = _label_save, \ .nb_saved = _nb_saved, \ - .type_saved = _save_type \ } \ } diff --git a/src/mintdb/perf_taler_mintdb_values.h b/src/mintdb/perf_taler_mintdb_values.h index f8a8fde0..b3527224 100644 --- a/src/mintdb/perf_taler_mintdb_values.h +++ b/src/mintdb/perf_taler_mintdb_values.h @@ -22,17 +22,17 @@ #define __PERF_TALER_MINTDB__VALUES_H__ -#define PERF_TALER_MINTDB_NB_DENOMINATION_INIT 100 -#define PERF_TALER_MINTDB_NB_DENOMINATION_SAVE 100 +#define PERF_TALER_MINTDB_NB_DENOMINATION_INIT 10 +#define PERF_TALER_MINTDB_NB_DENOMINATION_SAVE 10 -#define PERF_TALER_MINTDB_NB_RESERVE_INIT 10000 -#define PERF_TALER_MINTDB_NB_RESERVE_SAVE 1000 +#define PERF_TALER_MINTDB_NB_RESERVE_INIT 100 +#define PERF_TALER_MINTDB_NB_RESERVE_SAVE 10 -#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100000 -#define PERF_TALER_MINTDB_NB_DEPOSIT_SAVE 1000 +#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 1000 +#define PERF_TALER_MINTDB_NB_DEPOSIT_SAVE 10 -#define PERF_TALER_MINTDB_NB_WITHDRAW_INIT 100000 -#define PERF_TALER_MINTDB_NB_WITHDRAW_SAVE 1000 +#define PERF_TALER_MINTDB_NB_WITHDRAW_INIT 100 +#define PERF_TALER_MINTDB_NB_WITHDRAW_SAVE 10 #endif -- cgit v1.2.3