better command check
This commit is contained in:
parent
fe11e2f4dc
commit
da0b72311f
@ -109,7 +109,7 @@ main (int argc, char ** argv)
|
|||||||
"04 - deposit init loop"),
|
"04 - deposit init loop"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("End of initialization"),
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("End of initialization"),
|
||||||
// End of deposit initialization
|
// End of deposit initialization
|
||||||
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("Start of performances measuring"),
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("Start of performances measuring"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("05 - start"),
|
PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("05 - start"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("05 - reserve insert measure",
|
PERF_TALER_MINTDB_INIT_CMD_LOOP ("05 - reserve insert measure",
|
||||||
@ -235,7 +235,7 @@ main (int argc, char ** argv)
|
|||||||
"item/sec",
|
"item/sec",
|
||||||
NB_WITHDRAW_SAVE),
|
NB_WITHDRAW_SAVE),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("End of transaction loading"),
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("End of transaction loading"),
|
||||||
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("11 - start"),
|
PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("11 - start"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("11 - /withdraw/sign",
|
PERF_TALER_MINTDB_INIT_CMD_LOOP ("11 - /withdraw/sign",
|
||||||
NB_WITHDRAW_SAVE),
|
NB_WITHDRAW_SAVE),
|
||||||
@ -261,7 +261,7 @@ main (int argc, char ** argv)
|
|||||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("End of /withdraw/sign"),
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("End of /withdraw/sign"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_END (""),
|
PERF_TALER_MINTDB_INIT_CMD_END (""),
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = PERF_TALER_MINTDB_run_benchmark (
|
ret = PERF_TALER_MINTDB_run_benchmark (
|
||||||
"perf-taler-mintdb",
|
"perf-taler-mintdb",
|
||||||
"./test-mint-db-postgres.conf",
|
"./test-mint-db-postgres.conf",
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
#include "gauger.h"
|
#include "gauger.h"
|
||||||
|
|
||||||
|
|
||||||
#define FIND_TEST(cmd, string, arg) \
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the state of the interpreter
|
* Represents the state of the interpreter
|
||||||
*/
|
*/
|
||||||
@ -169,8 +167,11 @@ cmd_find (const struct PERF_TALER_MINTDB_Cmd *cmd, const char *search)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization of a command array
|
* Initialization of a command array
|
||||||
*
|
* and check for the type of the label
|
||||||
|
*
|
||||||
* @param cmd the comand array initialized
|
* @param cmd the comand array initialized
|
||||||
|
* @return #GNUNET_OK if the initialization was sucessful
|
||||||
|
* #GNUNET_SYSERR if there was a probleb. See the log for details
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[])
|
cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[])
|
||||||
@ -181,34 +182,412 @@ cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[])
|
|||||||
{
|
{
|
||||||
switch (cmd[i].command)
|
switch (cmd[i].command)
|
||||||
{
|
{
|
||||||
|
case PERF_TALER_MINTDB_CMD_END_LOOP:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.end_loop.label_loop);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.end_loop.label_loop);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PERF_TALER_MINTDB_CMD_LOOP != cmd[ret].command)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.end_loop.label_loop);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.end_loop.index_loop = ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
||||||
{
|
{
|
||||||
int save_label;
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.save_array.label_save);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.save_array.label_save);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_NONE == cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.save_array.label_save);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.save_array.index_save = ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.save_array.label_loop);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.save_array.label_loop);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_CMD_LOOP != cmd[ret].command)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.save_array.label_loop);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.save_array.index_loop = ret;
|
||||||
|
|
||||||
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 =
|
cmd[i].details.save_array.data_saved =
|
||||||
GNUNET_new_array (cmd[i].details.save_array.nb_saved,
|
GNUNET_new_array (cmd[i].details.save_array.nb_saved,
|
||||||
struct PERF_TALER_MINTDB_Data);
|
struct PERF_TALER_MINTDB_Data);
|
||||||
|
GNUNET_assert (NULL != cmd[i].details.save_array.data_saved);
|
||||||
|
cmd[i].details.save_array.data_saved->type =
|
||||||
|
cmd[cmd[i].details.save_array.index_save].exposed.type;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
|
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
|
||||||
/* Creating the permutation array to randomize the data order */
|
|
||||||
{
|
{
|
||||||
int save_index;
|
int ret;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_SYSERR !=
|
ret = cmd_find (cmd,
|
||||||
(save_index = cmd_find (
|
cmd[i].details.load_array.label_save);
|
||||||
cmd,
|
if (GNUNET_SYSERR == ret)
|
||||||
cmd[i].details.load_array.label_save)));
|
{
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
(cmd[i].details.load_array.permutation =
|
"%d:Undefined reference to %s",
|
||||||
GNUNET_CRYPTO_random_permute (
|
i,
|
||||||
GNUNET_CRYPTO_QUALITY_WEAK,
|
cmd[i].details.load_array.label_save);
|
||||||
cmd[save_index].details.save_array.nb_saved)));
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_CMD_SAVE_ARRAY != cmd[ret].command)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.load_array.label_save);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.load_array.index_save = ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.load_array.label_loop);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.load_array.label_loop);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_CMD_LOOP != cmd[ret].command)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.load_array.label_loop);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.load_array.index_loop = ret;
|
||||||
|
|
||||||
|
cmd[i].details.load_array.permutation =
|
||||||
|
GNUNET_CRYPTO_random_permute (
|
||||||
|
GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
|
cmd[cmd[i].details.load_array.index_loop].details.save_array.nb_saved);
|
||||||
|
GNUNET_assert (NULL != cmd[i].details.load_array.permutation);
|
||||||
|
|
||||||
|
cmd[i].exposed.type = cmd[cmd[i].details.load_array.index_save].details.save_array.data_saved->type;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_LOAD_RANDOM:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.load_random.label_save);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.load_random.label_save);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PERF_TALER_MINTDB_CMD_SAVE_ARRAY != cmd[ret].command)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.load_random.label_save);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.load_random.index_save = ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GAUGER:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.gauger.label_start);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.gauger.label_start);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_TIME != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.gauger.label_start);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.gauger.index_start = ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.gauger.label_stop);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.gauger.label_stop);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_TIME != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.gauger.label_stop);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.gauger.index_stop = ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find( cmd,
|
||||||
|
cmd[i].details.insert_deposit.label_coin);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.insert_deposit.label_coin);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_COIN != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.insert_deposit.label_coin);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.insert_deposit.index_coin = ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_DEPOSIT:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.get_deposit.label_deposit);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_deposit.label_deposit);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_DEPOSIT != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_deposit.label_deposit);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.get_deposit.index_deposit = ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_RESERVE:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.get_reserve.label_reserve);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_reserve.label_reserve);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_RESERVE != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_reserve.label_reserve);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.get_reserve.index_reserve = ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_RESERVE_HISTORY:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.get_reserve_history.label_reserve);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_reserve_history.label_reserve);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_RESERVE != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_reserve_history.label_reserve);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.get_reserve_history.index_reserve = ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_DENOMINATION:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.get_denomination.label_denom);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_denomination.label_denom);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_DENOMINATION_INFO != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_denomination.label_denom);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.get_denomination.index_denom = ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.insert_withdraw.label_dki);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.insert_withdraw.label_dki);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_DENOMINATION_INFO != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.insert_withdraw.label_dki);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.insert_withdraw.index_dki = ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.insert_withdraw.label_reserve);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.insert_withdraw.label_reserve);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_RESERVE != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.insert_withdraw.label_reserve);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.insert_withdraw.index_reserve = ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_WITHDRAW:
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cmd_find (cmd,
|
||||||
|
cmd[i].details.get_withdraw.label_coin);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Undefined reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_withdraw.label_coin);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (PERF_TALER_MINTDB_COIN != cmd[ret].exposed.type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"%d:Wrong type reference to %s",
|
||||||
|
i,
|
||||||
|
cmd[i].details.get_withdraw.label_coin);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
cmd[i].details.get_withdraw.index_coin = ret;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -270,10 +649,7 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
int jump;
|
int jump;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_SYSERR !=
|
jump = state->cmd[state->i].details.end_loop.index_loop;
|
||||||
(jump = cmd_find (state->cmd,
|
|
||||||
state->cmd[state->i]
|
|
||||||
.details.end_loop.label_loop)));
|
|
||||||
// Cleaning up the memory in the loop
|
// Cleaning up the memory in the loop
|
||||||
for (i = jump; i < state->i; i++)
|
for (i = jump; i < state->i; i++)
|
||||||
{
|
{
|
||||||
@ -297,7 +673,7 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part of the interpreter specific to
|
* Part of the interpreter specific to
|
||||||
* #PERF_TALER_MINTDB_CMD_SAVE_ARRAY
|
* #PERF_TALER_MINTDB_CMD_SAVE_ARRAY
|
||||||
* Saves the data exposed by another command into
|
* Saves the data exposed by another command into
|
||||||
* an array in the command specific struct.
|
* an array in the command specific struct.
|
||||||
@ -312,13 +688,9 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
int save_index;
|
int save_index;
|
||||||
unsigned int selection_chance;
|
unsigned int selection_chance;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_SYSERR !=
|
loop_index = cmd->details.save_array.index_loop;
|
||||||
(loop_index = cmd_find (state->cmd,
|
save_index = cmd->details.save_array.index_save;
|
||||||
cmd->details.save_array.label_loop)));
|
|
||||||
loop_ref = &state->cmd[loop_index];
|
loop_ref = &state->cmd[loop_index];
|
||||||
GNUNET_assert (GNUNET_SYSERR !=
|
|
||||||
(save_index = cmd_find (state->cmd,
|
|
||||||
cmd->details.save_array.label_save)));
|
|
||||||
save_ref = &state->cmd[save_index];
|
save_ref = &state->cmd[save_index];
|
||||||
/* Array initialization on first loop iteration
|
/* Array initialization on first loop iteration
|
||||||
Alows for nested loops */
|
Alows for nested loops */
|
||||||
@ -358,25 +730,20 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Part of the interpreter specific to
|
* Part of the interpreter specific to
|
||||||
* #PERF_TALER_MINTDB_CMD_LOAD_ARRAY
|
* #PERF_TALER_MINTDB_CMD_LOAD_ARRAY
|
||||||
* Gets data from a #PERF_TALER_MINTDB_CMD_SAVE_ARRAY and exposes a copy
|
* Gets data from a #PERF_TALER_MINTDB_CMD_SAVE_ARRAY and exposes a copy
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||||
{
|
{
|
||||||
|
struct PERF_TALER_MINTDB_Cmd *cmd = &state->cmd[state->i];
|
||||||
unsigned int loop_iter;
|
unsigned int loop_iter;
|
||||||
int loop_index;
|
int loop_index;
|
||||||
int save_index;
|
int save_index;
|
||||||
struct PERF_TALER_MINTDB_Data *loaded_data;
|
struct PERF_TALER_MINTDB_Data *loaded_data;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_SYSERR !=
|
loop_index = cmd->details.load_array.index_loop;
|
||||||
(loop_index = cmd_find (state->cmd,
|
save_index = cmd->details.load_array.index_save;
|
||||||
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;
|
loop_iter = state->cmd[loop_index].details.loop.curr_iteration;
|
||||||
{
|
{
|
||||||
int i, quotient;
|
int i, quotient;
|
||||||
@ -386,34 +753,33 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
quotient = loop_iter / state->cmd[save_index].details.save_array.nb_saved;
|
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;
|
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];
|
loop_iter = cmd->details.load_array.permutation[loop_iter];
|
||||||
}
|
}
|
||||||
/* Extracting the data from the loop_indexth indice in save_index
|
/* Extracting the data from the loop_indexth indice in save_index
|
||||||
* array.
|
* array.
|
||||||
*/
|
*/
|
||||||
loaded_data = &state->cmd[save_index].details.save_array.data_saved[loop_iter];
|
loaded_data = &state->cmd[save_index].details.save_array.data_saved[loop_iter];
|
||||||
data_copy (loaded_data, &state->cmd[state->i].exposed);
|
data_copy (loaded_data, &cmd->exposed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part of the interpreter specific to
|
* Part of the interpreter specific to
|
||||||
* #PERF_TALER_MINTDB_CMD_LOAD_RANDOM
|
* #PERF_TALER_MINTDB_CMD_LOAD_RANDOM
|
||||||
* Get a random element from a #PERF_TALER_MINTDB_CMD_SAVE_ARRAY and exposes it
|
* Get a random element from a #PERF_TALER_MINTDB_CMD_SAVE_ARRAY and exposes it
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
interprete_load_random (struct PERF_TALER_MINTDB_interpreter_state *state)
|
interprete_load_random (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||||
{
|
{
|
||||||
|
struct PERF_TALER_MINTDB_Cmd *cmd = &state->cmd[state->i];
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
int save_index;
|
int save_index;
|
||||||
|
|
||||||
GNUNET_assert (0 <=
|
save_index = cmd->details.load_random.index_save;
|
||||||
(save_index = cmd_find (state->cmd,
|
index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
state->cmd[state->i].details.load_random.label_save)));
|
state->cmd[save_index].details.save_array.nb_saved);
|
||||||
index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
|
data_copy (&state->cmd[save_index].details.save_array.data_saved[index],
|
||||||
state->cmd[save_index].details.save_array.nb_saved);
|
&cmd->exposed);
|
||||||
data_copy (&state->cmd[save_index].details.save_array.data_saved[index],
|
|
||||||
&state->cmd[state->i].exposed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -445,9 +811,9 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_TIME:
|
case PERF_TALER_MINTDB_CMD_GET_TIME:
|
||||||
state->cmd[state->i].exposed.data.time =
|
state->cmd[state->i].exposed.data.time =
|
||||||
GNUNET_new (struct GNUNET_TIME_Absolute);
|
GNUNET_new (struct GNUNET_TIME_Absolute);
|
||||||
*state->cmd[state->i].exposed.data.time =
|
*state->cmd[state->i].exposed.data.time =
|
||||||
GNUNET_TIME_absolute_get ();
|
GNUNET_TIME_absolute_get ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -457,22 +823,17 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
float ips;
|
float ips;
|
||||||
struct GNUNET_TIME_Absolute start, stop;
|
struct GNUNET_TIME_Absolute start, stop;
|
||||||
struct GNUNET_TIME_Relative elapsed;
|
struct GNUNET_TIME_Relative elapsed;
|
||||||
GNUNET_assert (GNUNET_SYSERR !=
|
|
||||||
(start_index = cmd_find (state->cmd,
|
start_index = state->cmd[state->i].details.gauger.index_start;
|
||||||
state->cmd[state->i]
|
stop_index = state->cmd[state->i].details.gauger.index_stop;
|
||||||
.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.data.time;
|
start = *state->cmd[start_index].exposed.data.time;
|
||||||
stop = *state->cmd[stop_index].exposed.data.time;
|
stop = *state->cmd[stop_index].exposed.data.time;
|
||||||
elapsed = GNUNET_TIME_absolute_get_difference (start,
|
elapsed = GNUNET_TIME_absolute_get_difference (start,
|
||||||
stop);
|
stop);
|
||||||
ips = (1.0 * state->cmd[state->i].details.gauger.divide) / (elapsed.rel_value_us/1000000.0);
|
ips = (1.0 * state->cmd[state->i].details.gauger.divide) / (elapsed.rel_value_us/1000000.0);
|
||||||
GAUGER (state->cmd[state->i].details.gauger.category,
|
GAUGER (state->cmd[state->i].details.gauger.category,
|
||||||
state->cmd[state->i].details.gauger.description,
|
state->cmd[state->i].details.gauger.description,
|
||||||
ips,
|
ips,
|
||||||
state->cmd[state->i].details.gauger.unit);
|
state->cmd[state->i].details.gauger.unit);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -511,12 +872,9 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
int coin_index;
|
int coin_index;
|
||||||
struct TALER_MINTDB_Deposit *deposit;
|
struct TALER_MINTDB_Deposit *deposit;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_SYSERR !=
|
coin_index = state->cmd[state->i].details.insert_deposit.index_coin;
|
||||||
(coin_index = cmd_find (state->cmd,
|
deposit = PERF_TALER_MINTDB_deposit_init (state->cmd[coin_index].exposed.data.coin);
|
||||||
state->cmd[state->i].details.insert_deposit.label_coin)));
|
GNUNET_assert (NULL != deposit);
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(deposit = PERF_TALER_MINTDB_deposit_init (state->cmd[coin_index].exposed.data.coin)));
|
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
state->plugin->insert_deposit (state->plugin->cls,
|
state->plugin->insert_deposit (state->plugin->cls,
|
||||||
state->session,
|
state->session,
|
||||||
@ -584,7 +942,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
case PERF_TALER_MINTDB_CMD_GET_RESERVE_HISTORY:
|
case PERF_TALER_MINTDB_CMD_GET_RESERVE_HISTORY:
|
||||||
{
|
{
|
||||||
int reserve_index;
|
int reserve_index;
|
||||||
struct TALER_MINTDB_ReserveHistory *history;
|
struct TALER_MINTDB_ReserveHistory *history;
|
||||||
struct PERF_TALER_MINTDB_Data data;
|
struct PERF_TALER_MINTDB_Data data;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_SYSERR !=
|
GNUNET_assert (GNUNET_SYSERR !=
|
||||||
@ -682,7 +1040,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
int coin_index;
|
int coin_index;
|
||||||
struct PERF_TALER_MINTDB_Coin *coin;
|
struct PERF_TALER_MINTDB_Coin *coin;
|
||||||
struct TALER_MINTDB_TransactionList *transactions;
|
struct TALER_MINTDB_TransactionList *transactions;
|
||||||
|
|
||||||
coin_index = cmd_find (state->cmd,
|
coin_index = cmd_find (state->cmd,
|
||||||
state->cmd[state->i].details.get_coin_transaction.label_coin);
|
state->cmd[state->i].details.get_coin_transaction.label_coin);
|
||||||
GNUNET_assert (GNUNET_SYSERR != coin_index);
|
GNUNET_assert (GNUNET_SYSERR != coin_index);
|
||||||
@ -760,7 +1118,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
int hash_index;
|
int hash_index;
|
||||||
struct GNUNET_HashCode hash;
|
struct GNUNET_HashCode hash;
|
||||||
struct TALER_MINTDB_RefreshMelt melt;
|
struct TALER_MINTDB_RefreshMelt melt;
|
||||||
|
|
||||||
hash_index = cmd_find (state->cmd,
|
hash_index = cmd_find (state->cmd,
|
||||||
state->cmd[state->i].details.get_refresh_melt.label_hash);
|
state->cmd[state->i].details.get_refresh_melt.label_hash);
|
||||||
hash = state->cmd[hash_index].exposed.data.session_hash;
|
hash = state->cmd[hash_index].exposed.data.session_hash;
|
||||||
@ -823,7 +1181,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
GNUNET_assert (GNUNET_SYSERR != hash_index);
|
GNUNET_assert (GNUNET_SYSERR != hash_index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_REFRESH_COMMIT_COIN:
|
case PERF_TALER_MINTDB_CMD_GET_REFRESH_COMMIT_COIN:
|
||||||
{
|
{
|
||||||
int hash_index;
|
int hash_index;
|
||||||
@ -833,7 +1191,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
GNUNET_assert (GNUNET_SYSERR != hash_index);
|
GNUNET_assert (GNUNET_SYSERR != hash_index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_INSERT_REFRESH_COMMIT_LINK:
|
case PERF_TALER_MINTDB_CMD_INSERT_REFRESH_COMMIT_LINK:
|
||||||
{
|
{
|
||||||
int hash_index;
|
int hash_index;
|
||||||
@ -870,7 +1228,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
/**
|
/**
|
||||||
* Runs the commands given in @a cmd, working with
|
* Runs the commands given in @a cmd, working with
|
||||||
* the database referenced by @a db_plugin
|
* the database referenced by @a db_plugin
|
||||||
*
|
*
|
||||||
* @param db_plugin the connection to the database
|
* @param db_plugin the connection to the database
|
||||||
* @param cmd the commands to run
|
* @param cmd the commands to run
|
||||||
*/
|
*/
|
||||||
@ -896,7 +1254,7 @@ PERF_TALER_MINTDB_interpret (struct TALER_MINTDB_Plugin *db_plugin,
|
|||||||
*
|
*
|
||||||
* @param benchmark_name the name of the benchmark, displayed in the logs
|
* @param benchmark_name the name of the benchmark, displayed in the logs
|
||||||
* @param configuration_file path to the taler configuration file to use
|
* @param configuration_file path to the taler configuration file to use
|
||||||
* @param init the commands to use for the database initialisation,
|
* @param init the commands to use for the database initialisation,
|
||||||
* if #NULL the standard initialization is used
|
* if #NULL the standard initialization is used
|
||||||
* @param benchmark the commands for the benchmark
|
* @param benchmark the commands for the benchmark
|
||||||
* @return #GNUNET_OK upon success; GNUNET_SYSERR upon failure
|
* @return #GNUNET_OK upon success; GNUNET_SYSERR upon failure
|
||||||
@ -910,7 +1268,7 @@ PERF_TALER_MINTDB_run_benchmark (const char *benchmark_name,
|
|||||||
struct TALER_MINTDB_Plugin *plugin;
|
struct TALER_MINTDB_Plugin *plugin;
|
||||||
struct GNUNET_CONFIGURATION_Handle *config;
|
struct GNUNET_CONFIGURATION_Handle *config;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct PERF_TALER_MINTDB_Cmd init_def[] =
|
struct PERF_TALER_MINTDB_Cmd init_def[] =
|
||||||
{
|
{
|
||||||
// Denomination used to create coins
|
// Denomination used to create coins
|
||||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpreter"),
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpreter"),
|
||||||
@ -988,7 +1346,7 @@ PERF_TALER_MINTDB_run_benchmark (const char *benchmark_name,
|
|||||||
NULL);
|
NULL);
|
||||||
config = GNUNET_CONFIGURATION_create ();
|
config = GNUNET_CONFIGURATION_create ();
|
||||||
|
|
||||||
ret = GNUNET_CONFIGURATION_load (config,
|
ret = GNUNET_CONFIGURATION_load (config,
|
||||||
configuration_file);
|
configuration_file);
|
||||||
if (GNUNET_OK != ret)
|
if (GNUNET_OK != ret)
|
||||||
{
|
{
|
||||||
@ -1003,7 +1361,7 @@ PERF_TALER_MINTDB_run_benchmark (const char *benchmark_name,
|
|||||||
"Error connectiong to the database");
|
"Error connectiong to the database");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = plugin->create_tables (plugin->cls,
|
ret = plugin->create_tables (plugin->cls,
|
||||||
GNUNET_YES);
|
GNUNET_YES);
|
||||||
if (GNUNET_OK != ret)
|
if (GNUNET_OK != ret)
|
||||||
{
|
{
|
||||||
@ -1011,17 +1369,14 @@ PERF_TALER_MINTDB_run_benchmark (const char *benchmark_name,
|
|||||||
"Error while creating the database architecture");
|
"Error while creating the database architecture");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Running the initialization
|
* Running the initialization
|
||||||
*/
|
*/
|
||||||
if (NULL == init)
|
if (NULL == init)
|
||||||
{
|
{
|
||||||
init = init_def;
|
init = init_def;
|
||||||
}
|
}
|
||||||
if (GNUNET_SYSERR == PERF_TALER_MINTDB_check (init))
|
ret = PERF_TALER_MINTDB_interpret (plugin,
|
||||||
return GNUNET_SYSERR;
|
|
||||||
|
|
||||||
ret = PERF_TALER_MINTDB_interpret (plugin,
|
|
||||||
init);
|
init);
|
||||||
if (GNUNET_OK != ret)
|
if (GNUNET_OK != ret)
|
||||||
{
|
{
|
||||||
@ -1032,9 +1387,7 @@ PERF_TALER_MINTDB_run_benchmark (const char *benchmark_name,
|
|||||||
/*
|
/*
|
||||||
* Running the benchmark
|
* Running the benchmark
|
||||||
*/
|
*/
|
||||||
if (GNUNET_SYSERR == PERF_TALER_MINTDB_check (benchmark))
|
ret = PERF_TALER_MINTDB_interpret (plugin,
|
||||||
return GNUNET_SYSERR;
|
|
||||||
ret = PERF_TALER_MINTDB_interpret (plugin,
|
|
||||||
benchmark);
|
benchmark);
|
||||||
if (GNUNET_OK != ret)
|
if (GNUNET_OK != ret)
|
||||||
{
|
{
|
||||||
@ -1046,9 +1399,9 @@ PERF_TALER_MINTDB_run_benchmark (const char *benchmark_name,
|
|||||||
{
|
{
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
|
|
||||||
session = plugin->get_session (plugin->cls,
|
session = plugin->get_session (plugin->cls,
|
||||||
GNUNET_YES);
|
GNUNET_YES);
|
||||||
ret = plugin->drop_temporary (plugin->cls,
|
ret = plugin->drop_temporary (plugin->cls,
|
||||||
session);
|
session);
|
||||||
if (GNUNET_OK != ret)
|
if (GNUNET_OK != ret)
|
||||||
{
|
{
|
||||||
@ -1062,140 +1415,3 @@ PERF_TALER_MINTDB_run_benchmark (const char *benchmark_name,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests if @a label is reference to a command of @a cmd
|
|
||||||
* Prints an error containing @a desc if a problem occurs
|
|
||||||
*
|
|
||||||
* @param cmd the cmd array checked
|
|
||||||
* @param label the label checked
|
|
||||||
* @param i the index of the command beeing checked (used for error reporting
|
|
||||||
* @param desc a description of the label checked
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
find_test (const struct PERF_TALER_MINTDB_Cmd *cmd,
|
|
||||||
const char *label,
|
|
||||||
const unsigned int i,
|
|
||||||
const char *desc)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = cmd_find (cmd, label);
|
|
||||||
if (GNUNET_SYSERR == ret)
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"Error at %s:index %d wrong label for %s",
|
|
||||||
cmd[i].label,
|
|
||||||
i,
|
|
||||||
desc);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the given command array is syntaxicly correct
|
|
||||||
* This will check if the label are corrects but will not check if
|
|
||||||
* they are pointing to an apropriate command.
|
|
||||||
*
|
|
||||||
* @param cmd the command array to check
|
|
||||||
* @return #GNUNET_OK is @a cmd is correct; #GNUNET_SYSERR if it is'nt
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PERF_TALER_MINTDB_check (const struct PERF_TALER_MINTDB_Cmd *cmd)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
int ret = GNUNET_OK;
|
|
||||||
|
|
||||||
for (i = 0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++)
|
|
||||||
{
|
|
||||||
int ret_loc = GNUNET_OK;
|
|
||||||
switch (cmd[i].command)
|
|
||||||
{
|
|
||||||
case PERF_TALER_MINTDB_CMD_END_LOOP:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.end_loop.label_loop,
|
|
||||||
i,
|
|
||||||
"label_loop");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GAUGER:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.gauger.label_start,
|
|
||||||
i,
|
|
||||||
"label_start");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.save_array.label_loop,
|
|
||||||
i,
|
|
||||||
"label_loop");
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.save_array.label_save,
|
|
||||||
i,
|
|
||||||
"label_save");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.load_array.label_loop,
|
|
||||||
i,
|
|
||||||
"label_loop");
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.load_array.label_save,
|
|
||||||
i,
|
|
||||||
"label_save");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_DENOMINATION:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.get_denomination.label_denom,
|
|
||||||
i,
|
|
||||||
"label_denom");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_RESERVE:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.get_reserve.label_reserve,
|
|
||||||
i,
|
|
||||||
"label_reserve");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.insert_deposit.label_coin,
|
|
||||||
i,
|
|
||||||
"label_dki");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_DEPOSIT:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.get_deposit.label_deposit,
|
|
||||||
i,
|
|
||||||
"label_deposit");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.insert_withdraw.label_dki,
|
|
||||||
i,
|
|
||||||
"label_dki");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_WITHDRAW:
|
|
||||||
ret_loc = find_test (cmd,
|
|
||||||
cmd[i].details.get_withdraw.label_coin,
|
|
||||||
i,
|
|
||||||
"label_coin");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default :
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (GNUNET_OK == ret)
|
|
||||||
ret = (GNUNET_SYSERR == ret_loc)?GNUNET_SYSERR:GNUNET_OK;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
@ -112,7 +112,7 @@
|
|||||||
{ \
|
{ \
|
||||||
.command = PERF_TALER_MINTDB_CMD_GET_TIME, \
|
.command = PERF_TALER_MINTDB_CMD_GET_TIME, \
|
||||||
.label = _label, \
|
.label = _label, \
|
||||||
.exposed.type = PERF_TALER_MINTDB_NONE \
|
.exposed.type = PERF_TALER_MINTDB_TIME \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -657,6 +657,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* Maximum number of iteration in the loop
|
* Maximum number of iteration in the loop
|
||||||
*/
|
*/
|
||||||
const unsigned int max_iterations;
|
const unsigned int max_iterations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current iteration of the loop
|
* The current iteration of the loop
|
||||||
*/
|
*/
|
||||||
@ -673,6 +674,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* Label of the loop closed by the command
|
* Label of the loop closed by the command
|
||||||
*/
|
*/
|
||||||
const char *label_loop;
|
const char *label_loop;
|
||||||
|
unsigned int index_loop;
|
||||||
} end_loop;
|
} end_loop;
|
||||||
|
|
||||||
|
|
||||||
@ -685,11 +687,13 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* Label of the starting timestamp
|
* Label of the starting timestamp
|
||||||
*/
|
*/
|
||||||
const char *label_start;
|
const char *label_start;
|
||||||
|
unsigned int index_start;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label of the ending timestamp
|
* Label of the ending timestamp
|
||||||
*/
|
*/
|
||||||
const char *label_stop;
|
const char *label_stop;
|
||||||
|
unsigned int index_stop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The category of the measurment
|
* The category of the measurment
|
||||||
@ -723,18 +727,24 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* Number of items to save
|
* Number of items to save
|
||||||
*/
|
*/
|
||||||
unsigned int nb_saved;
|
unsigned int nb_saved;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of items already saved
|
* Number of items already saved
|
||||||
*/
|
*/
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label of the loop it is attached to
|
* Label of the loop it is attached to
|
||||||
*/
|
*/
|
||||||
const char *label_loop;
|
const char *label_loop;
|
||||||
|
unsigned int index_loop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label of the command exposing the item
|
* Label of the command exposing the item
|
||||||
*/
|
*/
|
||||||
const char *label_save;
|
const char *label_save;
|
||||||
|
unsigned int index_save;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of data saved
|
* Array of data saved
|
||||||
*/
|
*/
|
||||||
@ -751,11 +761,13 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The loop in which the command is located
|
* The loop in which the command is located
|
||||||
*/
|
*/
|
||||||
const char *label_loop;
|
const char *label_loop;
|
||||||
|
unsigned int index_loop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label of the command where the items were saved
|
* Label of the command where the items were saved
|
||||||
*/
|
*/
|
||||||
const char *label_save;
|
const char *label_save;
|
||||||
|
unsigned int index_save;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A permutation array used to randomize the order the items are loaded in
|
* A permutation array used to randomize the order the items are loaded in
|
||||||
@ -773,6 +785,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The label of the #PERF_TALER_MINTDB_CMD_SAVE_ARRAY the items will be extracted from
|
* The label of the #PERF_TALER_MINTDB_CMD_SAVE_ARRAY the items will be extracted from
|
||||||
*/
|
*/
|
||||||
const char *label_save;
|
const char *label_save;
|
||||||
|
unsigned int index_save;
|
||||||
} load_random;
|
} load_random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -784,6 +797,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* Label of the source where the reserve used to create the coin is
|
* Label of the source where the reserve used to create the coin is
|
||||||
*/
|
*/
|
||||||
const char *label_coin;
|
const char *label_coin;
|
||||||
|
unsigned int index_coin;
|
||||||
} insert_deposit;
|
} insert_deposit;
|
||||||
|
|
||||||
|
|
||||||
@ -796,6 +810,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The label of the source of the deposit to check
|
* The label of the source of the deposit to check
|
||||||
*/
|
*/
|
||||||
const char *label_deposit;
|
const char *label_deposit;
|
||||||
|
unsigned int index_deposit;
|
||||||
} get_deposit;
|
} get_deposit;
|
||||||
|
|
||||||
|
|
||||||
@ -808,6 +823,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The label of the source of the reserve to check
|
* The label of the source of the reserve to check
|
||||||
*/
|
*/
|
||||||
const char *label_reserve;
|
const char *label_reserve;
|
||||||
|
unsigned int index_reserve;
|
||||||
} get_reserve;
|
} get_reserve;
|
||||||
|
|
||||||
|
|
||||||
@ -820,6 +836,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The label of the source of the reserve to check
|
* The label of the source of the reserve to check
|
||||||
*/
|
*/
|
||||||
const char *label_reserve;
|
const char *label_reserve;
|
||||||
|
unsigned int index_reserve;
|
||||||
} get_reserve_history;
|
} get_reserve_history;
|
||||||
|
|
||||||
|
|
||||||
@ -832,6 +849,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The label of the source of the denomination to check
|
* The label of the source of the denomination to check
|
||||||
*/
|
*/
|
||||||
const char *label_denom;
|
const char *label_denom;
|
||||||
|
unsigned int index_denom;
|
||||||
} get_denomination;
|
} get_denomination;
|
||||||
|
|
||||||
|
|
||||||
@ -844,11 +862,13 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* label of the denomination key used to sign the coin
|
* label of the denomination key used to sign the coin
|
||||||
*/
|
*/
|
||||||
const char *label_dki;
|
const char *label_dki;
|
||||||
|
unsigned int index_dki;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* label of the reserve the money to mint the coin comes from
|
* label of the reserve the money to mint the coin comes from
|
||||||
*/
|
*/
|
||||||
const char *label_reserve;
|
const char *label_reserve;
|
||||||
|
unsigned int index_reserve;
|
||||||
} insert_withdraw;
|
} insert_withdraw;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -860,6 +880,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* label of the source for the coin information
|
* label of the source for the coin information
|
||||||
*/
|
*/
|
||||||
const char *label_coin;
|
const char *label_coin;
|
||||||
|
unsigned int index_coin;
|
||||||
} get_withdraw;
|
} get_withdraw;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -871,6 +892,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The coin which history is checked
|
* The coin which history is checked
|
||||||
*/
|
*/
|
||||||
const char *label_coin;
|
const char *label_coin;
|
||||||
|
unsigned int index_coin;
|
||||||
} get_coin_transaction;
|
} get_coin_transaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -882,6 +904,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* label of the source of the hash of the session
|
* label of the source of the hash of the session
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
} get_refresh_session;
|
} get_refresh_session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -893,11 +916,13 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The label of the hash of the refresh session
|
* The label of the hash of the refresh session
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The label of the coin to melt
|
* The label of the coin to melt
|
||||||
*/
|
*/
|
||||||
const char *label_coin;
|
const char *label_coin;
|
||||||
|
const char coin;
|
||||||
} insert_refresh_melt;
|
} insert_refresh_melt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -909,6 +934,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The label of the hash of the session
|
* The label of the hash of the session
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
} get_refresh_melt;
|
} get_refresh_melt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -920,11 +946,13 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The refresh session hash
|
* The refresh session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The new coin denomination
|
* The new coin denomination
|
||||||
*/
|
*/
|
||||||
const char *label_denom;
|
const char *label_denom;
|
||||||
|
unsigned int index_denom;
|
||||||
} insert_refresh_order;
|
} insert_refresh_order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -936,6 +964,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The session hash
|
* The session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
|
|
||||||
} get_refresh_order;
|
} get_refresh_order;
|
||||||
|
|
||||||
@ -948,6 +977,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The refresh session hash
|
* The refresh session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
|
|
||||||
} insert_refresh_commit_coin;
|
} insert_refresh_commit_coin;
|
||||||
|
|
||||||
@ -960,6 +990,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The refresh session hash
|
* The refresh session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
|
|
||||||
} insert_refresh_commit_link;
|
} insert_refresh_commit_link;
|
||||||
|
|
||||||
@ -972,6 +1003,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The refresh session hash
|
* The refresh session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
} get_refresh_commit_link;
|
} get_refresh_commit_link;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -983,6 +1015,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The refresh session hash
|
* The refresh session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
} get_melt_commitment;
|
} get_melt_commitment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -994,6 +1027,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The refresh session hash
|
* The refresh session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
} insert_refresh_out;
|
} insert_refresh_out;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1005,6 +1039,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The refresh session hash
|
* The refresh session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
} get_link_datat_list;
|
} get_link_datat_list;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1016,6 +1051,7 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The refresh session hash
|
* The refresh session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
unsigned int index_hash;
|
||||||
} get_transfer;
|
} get_transfer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user