aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFournier Nicolas <nicolas.fournier@ensta-paristech.fr>2015-06-26 15:32:20 +0200
committerFournier Nicolas <nicolas.fournier@ensta-paristech.fr>2015-06-26 15:32:20 +0200
commit5963e1136fcc566e9fc3070839ddaee518854d8f (patch)
treeae4c3eac224810de2c083942a694a2a4a7e14db6 /src
parent47262f4316874f321ffdcbcdcb1d98c182375730 (diff)
Remade memory management strategy of the interpreter.
Diffstat (limited to 'src')
-rw-r--r--src/mintdb/perf_taler_mintdb.c10
-rw-r--r--src/mintdb/perf_taler_mintdb_init.c119
-rw-r--r--src/mintdb/perf_taler_mintdb_init.h34
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.c214
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.h56
-rw-r--r--src/mintdb/perf_taler_mintdb_values.h2
6 files changed, 316 insertions, 119 deletions
diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c
index ed7e80b3d..50d351e2a 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 4ada307bc..f93bd8284 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 5f2e44cd5..3e2eb3cc2 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);
/**
@@ -91,6 +111,12 @@ 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
*/
int
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c
index dd36ae6d2..25999792a 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 49f06b6ea..9f7ee4207 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, \
}
/**
@@ -446,6 +452,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
*/
struct PERF_TALER_MINTDB_CMD_get_deposit_details
@@ -479,6 +497,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
*/
struct PERF_TALER_MINTDB_CMD_refresh_coin_details
@@ -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 4b982b8bd..f0cdd4f10 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