Merge branch 'master' of git+ssh://git.taler.net/var/git/mint
This commit is contained in:
commit
de430aa464
Binary file not shown.
@ -343,6 +343,8 @@ handle_deposit_finished (void *cls,
|
|||||||
}
|
}
|
||||||
switch (response_code)
|
switch (response_code)
|
||||||
{
|
{
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
case MHD_HTTP_OK:
|
case MHD_HTTP_OK:
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
verify_deposit_signature_ok (dh,
|
verify_deposit_signature_ok (dh,
|
||||||
|
@ -574,8 +574,32 @@ keys_completed_cb (void *cls,
|
|||||||
{
|
{
|
||||||
struct KeysRequest *kr = cls;
|
struct KeysRequest *kr = cls;
|
||||||
struct TALER_MINT_Handle *mint = kr->mint;
|
struct TALER_MINT_Handle *mint = kr->mint;
|
||||||
|
long response_code;
|
||||||
|
|
||||||
/* FIXME: might want to check 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) ||
|
if ( (0 != kr->eno) ||
|
||||||
(GNUNET_OK !=
|
(GNUNET_OK !=
|
||||||
parse_response_keys_get (kr)) )
|
parse_response_keys_get (kr)) )
|
||||||
|
@ -324,6 +324,8 @@ handle_withdraw_status_finished (void *cls,
|
|||||||
}
|
}
|
||||||
switch (response_code)
|
switch (response_code)
|
||||||
{
|
{
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
case MHD_HTTP_OK:
|
case MHD_HTTP_OK:
|
||||||
{
|
{
|
||||||
json_t *history;
|
json_t *history;
|
||||||
@ -818,6 +820,8 @@ handle_withdraw_sign_finished (void *cls,
|
|||||||
}
|
}
|
||||||
switch (response_code)
|
switch (response_code)
|
||||||
{
|
{
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
case MHD_HTTP_OK:
|
case MHD_HTTP_OK:
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
withdraw_sign_ok (wsh,
|
withdraw_sign_ok (wsh,
|
||||||
|
@ -33,30 +33,81 @@ main (int argc, char ** argv)
|
|||||||
struct GNUNET_CONFIGURATION_Handle *config;
|
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",10000),
|
// Denomination used to create coins
|
||||||
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_init"),
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpretor"),
|
||||||
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_LOOP ("01 - denomination loop",
|
||||||
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("array_depo",
|
PERF_TALER_MINTDB_NB_DENOMINATION_INIT),
|
||||||
"loop_db_init_deposit",
|
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"),
|
||||||
"init_deposit_insert",
|
PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION ("01 - denomination"),
|
||||||
100,
|
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("01 - commit transaction"),
|
||||||
PERF_TALER_MINTDB_DEPOSIT),
|
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination",
|
||||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit",
|
"01 - denomination loop",
|
||||||
"loop_db_init_deposit"),
|
"01 - denomination",
|
||||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG("Fin loop 1"),
|
PERF_TALER_MINTDB_NB_DENOMINATION_SAVE),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_deposit_get",100),
|
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("01 - denomination loop end",
|
||||||
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_get"),
|
"01 - denomination loop"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY("load deposit",
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("01 - init denomination complete"),
|
||||||
"loop_deposit_get",
|
// End of initialization
|
||||||
"array_depo"),
|
// Reserve initialization
|
||||||
PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT("get_deposit",
|
PERF_TALER_MINTDB_INIT_CMD_LOOP ("02 - init reserve loop",
|
||||||
"load_deposit"),
|
PERF_TALER_MINTDB_NB_RESERVE_INIT),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"),
|
PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE ("02 - reserve"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP("stop2", "loop_deposit_get"),
|
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve",
|
||||||
PERF_TALER_MINTDB_INIT_CMD_END("end")
|
"02 - init reserve loop",
|
||||||
|
"02 - 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"),
|
||||||
|
// 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_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 ("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",
|
||||||
|
"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_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",
|
||||||
|
"INFO",
|
||||||
|
NULL);
|
||||||
config = GNUNET_CONFIGURATION_create();
|
config = GNUNET_CONFIGURATION_create();
|
||||||
GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf");
|
GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf");
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
|
@ -30,76 +30,115 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a randomly generated CollectableBlindcoin
|
* Generate a dummy DenominationKeyInformation for testing purposes
|
||||||
|
* @return a dummy denomination key
|
||||||
*/
|
*/
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *
|
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
||||||
PERF_TALER_MINTDB_collectable_blindcoin_init ()
|
PERF_TALER_MINTDB_denomination_init ()
|
||||||
{
|
{
|
||||||
uint32_t random_int;
|
struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
|
||||||
struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt;
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key;
|
struct GNUNET_TIME_Absolute anchor;
|
||||||
struct {
|
struct TALER_Amount amount;
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
|
||||||
uint32_t data;
|
|
||||||
} unsigned_data;
|
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *coin;
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
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_ ()));
|
||||||
|
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));
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
GNUNET_CRYPTO_eddsa_sign (master_prvt,
|
||||||
|
&dki->issue.purpose,
|
||||||
|
&dki->issue.signature.eddsa_signature));
|
||||||
|
GNUNET_free (master_prvt);
|
||||||
|
|
||||||
coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin);
|
return dki;
|
||||||
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 ==
|
|
||||||
(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);
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Liberate memory of @a 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_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 of a DenominationKeyIssueInformation
|
||||||
|
* @param dki pointer to the struct to free
|
||||||
*/
|
*/
|
||||||
int
|
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;
|
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 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 *
|
struct TALER_MINTDB_Reserve *
|
||||||
PERF_TALER_MINTDB_reserve_init ()
|
PERF_TALER_MINTDB_reserve_init ()
|
||||||
@ -114,58 +153,47 @@ PERF_TALER_MINTDB_reserve_init ()
|
|||||||
GNUNET_CRYPTO_eddsa_key_get_public (reserve_priv ,
|
GNUNET_CRYPTO_eddsa_key_get_public (reserve_priv ,
|
||||||
&reserve->pub.eddsa_pub);
|
&reserve->pub.eddsa_pub);
|
||||||
GNUNET_assert (GNUNET_OK ==
|
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_ ();
|
reserve->expiry = GNUNET_TIME_absolute_get_forever_ ();
|
||||||
GNUNET_free (reserve_priv);
|
GNUNET_free (reserve_priv);
|
||||||
return reserve;
|
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)
|
||||||
|
{
|
||||||
|
struct TALER_MINTDB_Reserve *copy;
|
||||||
|
GNUNET_assert (NULL != (copy = GNUNET_new (struct TALER_MINTDB_Reserve)));
|
||||||
|
*copy = *reserve;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free memory of a reserve
|
* Free memory of a reserve
|
||||||
|
* @param reserve pointer to the structure to be freed
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve)
|
PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve)
|
||||||
{
|
{
|
||||||
|
if (NULL == reserve)
|
||||||
|
return GNUNET_OK;
|
||||||
GNUNET_free (reserve);
|
GNUNET_free (reserve);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a randomly generated refresh session
|
* Generate a dummy deposit for testing purposes
|
||||||
*/
|
* @param dki the denomination key used to sign the key
|
||||||
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
|
|
||||||
*/
|
*/
|
||||||
struct TALER_MINTDB_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_MINTDB_Deposit *deposit;
|
||||||
struct TALER_CoinPublicInfo coin;
|
struct TALER_CoinPublicInfo coin;
|
||||||
@ -189,25 +217,19 @@ PERF_TALER_MINTDB_deposit_init ()
|
|||||||
(deposit = GNUNET_malloc (sizeof (struct TALER_MINTDB_Deposit) + sizeof (wire))));
|
(deposit = GNUNET_malloc (sizeof (struct TALER_MINTDB_Deposit) + sizeof (wire))));
|
||||||
{ // coin
|
{ // coin
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt;
|
||||||
struct GNUNET_CRYPTO_rsa_PrivateKey *rsa_prv;
|
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ()));
|
(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,
|
GNUNET_CRYPTO_eddsa_key_get_public (eddsa_prvt,
|
||||||
&coin.coin_pub.eddsa_pub);
|
&coin.coin_pub.eddsa_pub);
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(coin.denom_pub.rsa_public_key =
|
(coin.denom_pub.rsa_public_key =
|
||||||
GNUNET_CRYPTO_rsa_private_key_get_public (rsa_prv)));
|
GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key)));
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(coin.denom_sig.rsa_signature =
|
(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,
|
&coin.coin_pub.eddsa_pub,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))));
|
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))));
|
||||||
|
|
||||||
GNUNET_CRYPTO_rsa_private_key_free (rsa_prv);
|
|
||||||
GNUNET_free (eddsa_prvt);
|
|
||||||
}
|
}
|
||||||
{ //csig
|
{ //csig
|
||||||
struct u32_presign
|
struct u32_presign
|
||||||
@ -265,8 +287,41 @@ PERF_TALER_MINTDB_deposit_init ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
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
|
* Free memory of a deposit
|
||||||
|
* @param deposit pointer to the structure to free
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit)
|
PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit)
|
||||||
@ -283,74 +338,151 @@ 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 *
|
struct TALER_MINTDB_CollectableBlindcoin *
|
||||||
PERF_TALER_MINTDB_denomination_init ()
|
PERF_TALER_MINTDB_collectable_blindcoin_init (
|
||||||
|
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
|
||||||
|
const struct TALER_MINTDB_Reserve *reserve)
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
|
uint32_t random_int;
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt;
|
struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key;
|
||||||
struct GNUNET_TIME_Absolute anchor;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key;
|
||||||
struct TALER_Amount amount;
|
struct {
|
||||||
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
|
uint32_t data;
|
||||||
|
} unsigned_data;
|
||||||
|
struct TALER_MINTDB_CollectableBlindcoin *coin;
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)));
|
(coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin)));
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(dki->denom_priv.rsa_private_key
|
(reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ()));
|
||||||
= GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_MINTDB_RSA_SIZE)));
|
{
|
||||||
|
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 !=
|
GNUNET_assert (NULL !=
|
||||||
(dki->denom_pub.rsa_public_key =
|
(denomination_key =
|
||||||
GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key)));
|
GNUNET_CRYPTO_rsa_private_key_decode (buffer, size)));
|
||||||
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
|
GNUNET_free (buffer);
|
||||||
&dki->issue.denom_hash);
|
}
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(master_prvt = GNUNET_CRYPTO_eddsa_key_create ()));
|
(coin->denom_pub.rsa_public_key =
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (master_prvt,
|
GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key)));
|
||||||
&dki->issue.master.eddsa_pub);
|
coin->reserve_pub.eddsa_pub = reserve->pub.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_assert (GNUNET_OK ==
|
||||||
TALER_string_to_amount (CURRENCY ":1.1", &amount));
|
TALER_string_to_amount (CURRENCY ":1.1",
|
||||||
TALER_amount_hton (&dki->issue.value, &amount);
|
&coin->amount_with_fee));
|
||||||
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_assert (GNUNET_OK ==
|
||||||
GNUNET_CRYPTO_eddsa_sign (master_prvt,
|
TALER_string_to_amount (CURRENCY ":1.1",
|
||||||
&dki->issue.purpose,
|
&coin->withdraw_fee));
|
||||||
&dki->issue.signature.eddsa_signature));
|
random_int =
|
||||||
GNUNET_free (master_prvt);
|
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
|
||||||
|
GNUNET_assert (NULL !=
|
||||||
return dki;
|
(coin->sig.rsa_signature =
|
||||||
|
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));
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free memory for a DenominationKeyIssueInformation
|
* 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_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
|
||||||
|
* @param coin pointer to the structure to free
|
||||||
*/
|
*/
|
||||||
int
|
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;
|
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;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,74 +27,114 @@
|
|||||||
#define CURRENCY "EUR"
|
#define CURRENCY "EUR"
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a randomly generated CollectableBlindcoin
|
|
||||||
*/
|
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *
|
|
||||||
PERF_TALER_MINTDB_collectable_blindcoin_init (void);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Liberate memory of @a coin
|
* Generate a dummy DenominationKeyInformation for testing purposes
|
||||||
*/
|
* @return a dummy denomination key
|
||||||
int
|
|
||||||
PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *NAME);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a randomly generated reserve
|
|
||||||
*/
|
|
||||||
struct TALER_MINTDB_Reserve *
|
|
||||||
PERF_TALER_MINTDB_reserve_init (void);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Free memory of 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
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refresh_session);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a randomly generated deposit
|
|
||||||
*/
|
|
||||||
struct TALER_MINTDB_Deposit *
|
|
||||||
PERF_TALER_MINTDB_deposit_init (void);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Free memory of a deposit
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a randomly generate DenominationKeyInformation
|
|
||||||
*/
|
*/
|
||||||
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
||||||
PERF_TALER_MINTDB_denomination_init (void);
|
PERF_TALER_MINTDB_denomination_init (void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free memory for a DenominationKeyIssueInformation
|
* 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);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free memory of a DenominationKeyIssueInformation
|
||||||
|
* @param dki pointer to the struct to free
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
PERF_TALER_MINTDB_denomination_free (
|
||||||
|
struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a dummy reserve for testing
|
||||||
|
* @return a reserve with 1000 EUR in it
|
||||||
|
*/
|
||||||
|
struct TALER_MINTDB_Reserve *
|
||||||
|
PERF_TALER_MINTDB_reserve_init (void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 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_CollectableBlindcoin *
|
||||||
|
PERF_TALER_MINTDB_collectable_blindcoin_init (
|
||||||
|
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
|
||||||
|
const struct TALER_MINTDB_Reserve *reserve);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Liberate memory of @a coin
|
||||||
|
* @param coin pointer to the structure to free
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
PERF_TALER_MINTDB_collectable_blindcoin_free (
|
||||||
|
struct TALER_MINTDB_CollectableBlindcoin *coin);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,4 +149,19 @@ PERF_TALER_MINTDB_coin_public_info_init (void);
|
|||||||
*/
|
*/
|
||||||
int PERF_TALER_MINTDB_coin_public_info_free (struct TALER_CoinPublicInfo *cpi);
|
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
|
#endif
|
||||||
|
@ -47,9 +47,10 @@ struct PERF_TALER_MINTDB_interpreter_state
|
|||||||
/**
|
/**
|
||||||
* The current index of the interpreter
|
* The current index of the interpreter
|
||||||
*/
|
*/
|
||||||
int i;
|
unsigned int i;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free the memory of @a data, with data of type @a type
|
* 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
|
* Finds the first command in cmd with the name search
|
||||||
*
|
*
|
||||||
@ -99,7 +99,7 @@ data_free (union PERF_TALER_MINTDB_Data *data, enum PERF_TALER_MINTDB_Type type)
|
|||||||
static int
|
static int
|
||||||
cmd_find (const struct PERF_TALER_MINTDB_Cmd *cmd, const char *search)
|
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++)
|
for (i=0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++)
|
||||||
if (0 == strcmp (cmd[i].label, search))
|
if (0 == strcmp (cmd[i].label, search))
|
||||||
@ -114,34 +114,47 @@ cmd_find (const struct PERF_TALER_MINTDB_Cmd *cmd, const char *search)
|
|||||||
static int
|
static int
|
||||||
cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[])
|
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++)
|
for (i=0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++)
|
||||||
{
|
{
|
||||||
switch (cmd[i].command)
|
switch (cmd[i].command)
|
||||||
{
|
{
|
||||||
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
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 =
|
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,
|
||||||
union PERF_TALER_MINTDB_Data);
|
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;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
|
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 ;
|
||||||
|
|
||||||
|
GNUNET_assert (GNUNET_SYSERR !=
|
||||||
|
(save_index = cmd_find (
|
||||||
|
cmd,
|
||||||
|
cmd[i].details.load_array.label_save)));
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(cmd[i].details.load_array.permutation =
|
(cmd[i].details.load_array.permutation =
|
||||||
GNUNET_CRYPTO_random_permute (
|
GNUNET_CRYPTO_random_permute (
|
||||||
GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
cmd[cmd_find (cmd,
|
cmd[save_index].details.save_array.nb_saved)));
|
||||||
cmd[i].details
|
/* Initializing the type based on the type of the saved array */
|
||||||
.load_array.label_save)]
|
cmd[i].exposed_type = cmd[save_index].details.save_array.type_saved;
|
||||||
.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;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -158,7 +171,7 @@ cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[])
|
|||||||
static int
|
static int
|
||||||
cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[])
|
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++)
|
for (i = 0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++)
|
||||||
{
|
{
|
||||||
@ -166,7 +179,7 @@ cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[])
|
|||||||
{
|
{
|
||||||
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
||||||
{
|
{
|
||||||
int j;
|
unsigned int j;
|
||||||
for (j = 0; j < cmd[i].details.save_array.nb_saved; j++)
|
for (j = 0; j < cmd[i].details.save_array.nb_saved; j++)
|
||||||
{
|
{
|
||||||
data_free (&cmd[i].details.save_array.data_saved[j],
|
data_free (&cmd[i].details.save_array.data_saved[j],
|
||||||
@ -198,30 +211,29 @@ cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[])
|
|||||||
static void
|
static void
|
||||||
interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
|
interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
union PERF_TALER_MINTDB_Data zero = {0};
|
union PERF_TALER_MINTDB_Data zero = {0};
|
||||||
int jump = cmd_find (state->cmd,
|
int jump;
|
||||||
state->cmd[state->i].details.end_loop.label_loop);
|
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
|
// Cleaning up the memory in the loop
|
||||||
for (i = jump; i < state->i; i++)
|
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);
|
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.
|
|
||||||
state->cmd[i].exposed = zero;
|
state->cmd[i].exposed = zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->cmd[jump].details.loop.curr_iteration++;
|
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 >
|
if (state->cmd[jump].details.loop.max_iterations >
|
||||||
state->cmd[jump].details.loop.curr_iteration)
|
state->cmd[jump].details.loop.curr_iteration)
|
||||||
{
|
{
|
||||||
// jump back to the start
|
/* jump back to the start */
|
||||||
state->i = jump;
|
state->i = jump;
|
||||||
}else{
|
}else{
|
||||||
// Reset the loop counter and continue running
|
/* Reset the loop counter and continue running */
|
||||||
state->cmd[jump].details.loop.curr_iteration = 0;
|
state->cmd[jump].details.loop.curr_iteration = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,29 +246,32 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
static void
|
static void
|
||||||
interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||||
{
|
{
|
||||||
int loop_index;
|
int loop_index, save_index;
|
||||||
int selection_chance;
|
unsigned int selection_chance;
|
||||||
|
|
||||||
// Array initialization on first loop iteration
|
GNUNET_assert (GNUNET_SYSERR !=
|
||||||
// Alows for nested loops
|
(loop_index = cmd_find (state->cmd,
|
||||||
if (0 == state->cmd[cmd_find (state->cmd,
|
|
||||||
state->cmd[state->i]
|
state->cmd[state->i]
|
||||||
.details.save_array.label_loop)]
|
.details.save_array.label_loop)));
|
||||||
.details.loop.curr_iteration)
|
GNUNET_assert (GNUNET_SYSERR !=
|
||||||
|
(save_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i]
|
||||||
|
.details.save_array.label_save)));
|
||||||
|
/* 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;
|
state->cmd[state->i].details.save_array.index = 0;
|
||||||
}
|
}
|
||||||
loop_index = cmd_find (state->cmd,
|
/* The probobility distribution of the saved items will be a little biased
|
||||||
state->cmd[state->i].details.save_array.label_loop);
|
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 /
|
selection_chance = state->cmd[loop_index].details.loop.max_iterations /
|
||||||
state->cmd[state->i].details.save_array.nb_saved;
|
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.
|
* 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 -
|
if ((0 < (state->cmd[state->i].details.save_array.nb_saved -
|
||||||
state->cmd[state->i].details.save_array.index)) &&
|
state->cmd[state->i].details.save_array.index)) &&
|
||||||
@ -272,10 +287,7 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
save_location = &state->cmd[state->i].details.save_array
|
save_location = &state->cmd[state->i].details.save_array
|
||||||
.data_saved[state->cmd[state->i].details.save_array.index];
|
.data_saved[state->cmd[state->i].details.save_array.index];
|
||||||
item_saved = &state->cmd[cmd_find (state->cmd,
|
item_saved = &state->cmd[save_index].exposed;
|
||||||
state->cmd[state->i]
|
|
||||||
.details.save_array.label_save)]
|
|
||||||
.exposed;
|
|
||||||
switch (state->cmd[state->i].details.save_array.type_saved)
|
switch (state->cmd[state->i].details.save_array.type_saved)
|
||||||
{
|
{
|
||||||
case PERF_TALER_MINTDB_TIME:
|
case PERF_TALER_MINTDB_TIME:
|
||||||
@ -283,19 +295,19 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_DEPOSIT:
|
case PERF_TALER_MINTDB_DEPOSIT:
|
||||||
save_location->deposit = item_saved->deposit;
|
save_location->deposit = PERF_TALER_MINTDB_deposit_copy (item_saved->deposit);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_BLINDCOIN:
|
case PERF_TALER_MINTDB_BLINDCOIN:
|
||||||
save_location->blindcoin = item_saved->blindcoin;
|
save_location->blindcoin = PERF_TALER_MINTDB_collectable_blindcoin_copy (item_saved->blindcoin);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_RESERVE:
|
case PERF_TALER_MINTDB_RESERVE:
|
||||||
save_location->reserve = item_saved->reserve;
|
save_location->reserve = PERF_TALER_MINTDB_reserve_copy (item_saved->reserve);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_DENOMINATION_INFO:
|
case PERF_TALER_MINTDB_DENOMINATION_INFO:
|
||||||
save_location->dki = item_saved->dki;
|
save_location->dki = PERF_TALER_MINTDB_denomination_copy (item_saved->dki);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_COIN_INFO:
|
case PERF_TALER_MINTDB_COIN_INFO:
|
||||||
@ -305,32 +317,45 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
default:
|
default:
|
||||||
break;
|
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++;
|
state->cmd[state->i].details.save_array.index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run when the current command is LOAD_ARRAY
|
||||||
|
* Get data from a 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)
|
||||||
{
|
{
|
||||||
|
unsigned int loop_iter;
|
||||||
int loop_index, save_index;
|
int loop_index, save_index;
|
||||||
union PERF_TALER_MINTDB_Data zero = {0};
|
|
||||||
union PERF_TALER_MINTDB_Data *loaded_data;
|
union PERF_TALER_MINTDB_Data *loaded_data;
|
||||||
|
|
||||||
loop_index = cmd_find (state->cmd,
|
GNUNET_assert (GNUNET_SYSERR !=
|
||||||
state->cmd[state->i].details.load_array.label_loop);
|
(loop_index = cmd_find (state->cmd,
|
||||||
save_index = cmd_find (state->cmd,
|
state->cmd[state->i]
|
||||||
state->cmd[state->i].details.load_array.label_save);
|
.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;
|
||||||
|
{
|
||||||
|
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++)
|
||||||
|
loop_iter = state->cmd[state->i].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[
|
loaded_data = &state->cmd[save_index].details.save_array.data_saved[loop_iter];
|
||||||
state->cmd[state->i].details.load_array.permutation[
|
|
||||||
state->cmd[loop_index].details.loop.curr_iteration]];
|
|
||||||
|
|
||||||
switch (state->cmd[state->i].exposed_type)
|
switch (state->cmd[state->i].exposed_type)
|
||||||
{
|
{
|
||||||
case PERF_TALER_MINTDB_TIME:
|
case PERF_TALER_MINTDB_TIME:
|
||||||
@ -338,26 +363,32 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_DEPOSIT:
|
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;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_BLINDCOIN:
|
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;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_RESERVE:
|
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;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_DENOMINATION_INFO:
|
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:
|
case PERF_TALER_MINTDB_COIN_INFO:
|
||||||
state->cmd[state->i].exposed.cpi = loaded_data->cpi;
|
state->cmd[state->i].exposed.cpi = loaded_data->cpi;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*loaded_data = zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -376,7 +407,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
return GNUNET_YES;
|
return GNUNET_YES;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_DEBUG:
|
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;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_LOOP:
|
case PERF_TALER_MINTDB_CMD_LOOP:
|
||||||
@ -396,10 +427,14 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
struct timespec start, stop;
|
struct timespec start, stop;
|
||||||
unsigned long elapsed_ms;
|
unsigned long elapsed_ms;
|
||||||
|
|
||||||
start_index = cmd_find (state->cmd,
|
GNUNET_assert (GNUNET_SYSERR !=
|
||||||
state->cmd[state->i].details.gauger.label_start);
|
(start_index = cmd_find (state->cmd,
|
||||||
stop_index = cmd_find (state->cmd,
|
state->cmd[state->i]
|
||||||
state->cmd[state->i].details.gauger.label_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.time;
|
start = state->cmd[start_index].exposed.time;
|
||||||
stop = state->cmd[stop_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 +
|
||||||
@ -407,7 +442,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
GAUGER ("MINTDB",
|
GAUGER ("MINTDB",
|
||||||
state->cmd[state->i].details.gauger.description,
|
state->cmd[state->i].details.gauger.description,
|
||||||
elapsed_ms,
|
elapsed_ms / state->cmd[state->i].details.gauger.divide,
|
||||||
"milliseconds");
|
"milliseconds");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -437,8 +472,15 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT:
|
case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT:
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Deposit *deposit =
|
int dki_index;
|
||||||
PERF_TALER_MINTDB_deposit_init ();
|
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 (
|
GNUNET_assert (
|
||||||
state->plugin->insert_deposit (state->plugin->cls,
|
state->plugin->insert_deposit (state->plugin->cls,
|
||||||
@ -450,12 +492,15 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_DEPOSIT:
|
case PERF_TALER_MINTDB_CMD_GET_DEPOSIT:
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Deposit *deposit =
|
int source_index;
|
||||||
state->cmd[cmd_find (state->cmd,
|
struct TALER_MINTDB_Deposit *deposit;
|
||||||
state->cmd[state->i]
|
|
||||||
.details.get_deposit.label_source)]
|
|
||||||
.exposed.deposit; // Get the deposit from the source
|
|
||||||
|
|
||||||
|
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->plugin->have_deposit (state->plugin->cls,
|
||||||
state->session,
|
state->session,
|
||||||
deposit);
|
deposit);
|
||||||
@ -465,10 +510,12 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
case PERF_TALER_MINTDB_CMD_INSERT_RESERVE:
|
case PERF_TALER_MINTDB_CMD_INSERT_RESERVE:
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Reserve *reserve;
|
struct TALER_MINTDB_Reserve *reserve;
|
||||||
json_t *details = json_pack ("si","justification",
|
json_t *details = NULL;
|
||||||
|
GNUNET_assert (NULL !=
|
||||||
|
(details = json_pack ("{s:i}","justification",
|
||||||
GNUNET_CRYPTO_random_u32 (
|
GNUNET_CRYPTO_random_u32 (
|
||||||
GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
UINT32_MAX));
|
UINT32_MAX))));
|
||||||
reserve = PERF_TALER_MINTDB_reserve_init ();
|
reserve = PERF_TALER_MINTDB_reserve_init ();
|
||||||
state->plugin->reserves_in_insert (
|
state->plugin->reserves_in_insert (
|
||||||
state->plugin->cls,
|
state->plugin->cls,
|
||||||
@ -484,15 +531,19 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_RESERVE:
|
case PERF_TALER_MINTDB_CMD_GET_RESERVE:
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Reserve *reserve =
|
int source_index;
|
||||||
state->cmd[cmd_find (state->cmd,
|
struct TALER_MINTDB_Reserve *reserve;
|
||||||
state->cmd[state->i]
|
|
||||||
.details.get_reserve.label_source)]
|
|
||||||
.exposed.reserve; // Get the deposit from the source
|
|
||||||
|
|
||||||
state->plugin->reserve_get (state->plugin->cls,
|
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,
|
state->session,
|
||||||
reserve);
|
reserve)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -511,11 +562,15 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_DENOMINATION:
|
case PERF_TALER_MINTDB_CMD_GET_DENOMINATION:
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_DenominationKeyIssueInformation *dki =
|
int source_index;
|
||||||
state->cmd[cmd_find (state->cmd,
|
struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
|
||||||
|
|
||||||
|
GNUNET_assert (GNUNET_SYSERR !=
|
||||||
|
(source_index = cmd_find (state->cmd,
|
||||||
state->cmd[state->i]
|
state->cmd[state->i]
|
||||||
.details.get_denomination.label_source)]
|
.details.get_denomination.label_source)));
|
||||||
.exposed.dki;
|
GNUNET_assert (NULL !=
|
||||||
|
(dki = state->cmd[source_index].exposed.dki));
|
||||||
state->plugin->get_denomination_info (state->plugin->cls,
|
state->plugin->get_denomination_info (state->plugin->cls,
|
||||||
state->session,
|
state->session,
|
||||||
&dki->denom_pub,
|
&dki->denom_pub,
|
||||||
@ -525,8 +580,22 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW:
|
case PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW:
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *blindcoin =
|
int dki_index, reserve_index;
|
||||||
PERF_TALER_MINTDB_collectable_blindcoin_init ();
|
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->plugin->insert_withdraw_info (state->plugin->cls,
|
||||||
state->session,
|
state->session,
|
||||||
@ -537,12 +606,15 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_WITHDRAW:
|
case PERF_TALER_MINTDB_CMD_GET_WITHDRAW:
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *blindcoin =
|
int source_index;
|
||||||
state->cmd[cmd_find (state->cmd,
|
struct TALER_MINTDB_CollectableBlindcoin *blindcoin ;
|
||||||
state->cmd[state->i]
|
|
||||||
.details.get_denomination.label_source)]
|
|
||||||
.exposed.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->plugin->get_withdraw_info (state->plugin->cls,
|
||||||
state->session,
|
state->session,
|
||||||
&blindcoin->h_coin_envelope,
|
&blindcoin->h_coin_envelope,
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Prints @ _label to stdout
|
||||||
*/
|
*/
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_DEBUG(_label) \
|
#define PERF_TALER_MINTDB_INIT_CMD_DEBUG(_label) \
|
||||||
{ \
|
{ \
|
||||||
@ -46,6 +46,7 @@
|
|||||||
.label = _label, \
|
.label = _label, \
|
||||||
.exposed_type = PERF_TALER_MINTDB_NONE \
|
.exposed_type = PERF_TALER_MINTDB_NONE \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The begining of a loop
|
* The begining of a loop
|
||||||
* @param _label the name of the loop
|
* @param _label the name of the loop
|
||||||
@ -85,16 +86,21 @@
|
|||||||
/**
|
/**
|
||||||
* Commits the duration between @a _label_start and @a _label_stop
|
* Commits the duration between @a _label_start and @a _label_stop
|
||||||
* to Gauger with @a _description explaining
|
* 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, _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, \
|
.command = PERF_TALER_MINTDB_CMD_GAUGER, \
|
||||||
.label = _label, \
|
.label = _label, \
|
||||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||||
.details.gauger = { \
|
.details.gauger = { \
|
||||||
.label_start = _label_start, \
|
.label_start = _label_start, \
|
||||||
.label_end = _label_end, \
|
.label_stop = _label_stop, \
|
||||||
.description = _description \
|
.description = _description, \
|
||||||
|
.divide = _divide, \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +128,7 @@
|
|||||||
* Extracts @a _nb_saved items of type @a _save_type
|
* Extracts @a _nb_saved items of type @a _save_type
|
||||||
* from the command @a _label_save during the loop @a _label_loop
|
* 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, \
|
.command = PERF_TALER_MINTDB_CMD_SAVE_ARRAY, \
|
||||||
.label = _label, \
|
.label = _label, \
|
||||||
@ -131,7 +137,6 @@
|
|||||||
.label_loop = _label_loop, \
|
.label_loop = _label_loop, \
|
||||||
.label_save = _label_save, \
|
.label_save = _label_save, \
|
||||||
.nb_saved = _nb_saved, \
|
.nb_saved = _nb_saved, \
|
||||||
.type_saved = _save_type \
|
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,82 +154,15 @@
|
|||||||
.label_save = _label_save \
|
.label_save = _label_save \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Insert a deposit into the database
|
|
||||||
*/
|
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label) \
|
|
||||||
{ \
|
|
||||||
.command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\
|
|
||||||
.label = _label, \
|
|
||||||
.exposed_type = PERF_TALER_MINTDB_DEPOSIT, \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a deposit is in the database
|
|
||||||
* @param _label_deposit Label of the deposit to use
|
|
||||||
*/
|
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \
|
|
||||||
{ \
|
|
||||||
.command = PERF_TALER_MINTDB_CMD_GET_DEPOSIT, \
|
|
||||||
.label = _label, \
|
|
||||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
|
||||||
.details.get_deposit.label_source = _label_deposit \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new reserve in the database
|
|
||||||
*/
|
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE(_label) \
|
|
||||||
{ \
|
|
||||||
.command = PERF_TALER_MINTDB_CMD_INSERT_RESERVE \
|
|
||||||
.label = _label \
|
|
||||||
.exposed_type = PERF_TALER_MINTDB_RESERVE \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Polls the database for a secific reserve's details
|
|
||||||
* @param _label_source Source for the reserve to poll
|
|
||||||
*/
|
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_RESERVE(_label, _label_source) \
|
|
||||||
{ \
|
|
||||||
.command = PERF_TALER_MINTDB_CMD_GET_RESERVE \
|
|
||||||
.label = _label, \
|
|
||||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
|
||||||
.details.get_reserve.label_source = _label_source \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inserts informations about a withdrawal in the database
|
|
||||||
*/
|
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW(_label) \
|
|
||||||
{ \
|
|
||||||
.command = PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW, \
|
|
||||||
.label = _label, \
|
|
||||||
.exposed_type = PERF_TALER_MINTDB_BLINDCOIN, \
|
|
||||||
}\
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Polls the database about informations regarding a secific withdrawal
|
|
||||||
*/
|
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \
|
|
||||||
{ \
|
|
||||||
.command = PERF_TALER_MINTDB_CMD_GET_WITHDRAW, \
|
|
||||||
.label = _label, \
|
|
||||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
|
||||||
.details.get_withdraw.label_source = _label_source, \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts informations about a denomination key in the database
|
* Inserts informations about a denomination key in the database
|
||||||
*/
|
*/
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \
|
#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, \
|
.label = _label, \
|
||||||
.exposed_type = PERF_TALER_MINTDB_DENOMINATION_KEY, \
|
.exposed_type = PERF_TALER_MINTDB_DENOMINATION_INFO, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -238,6 +176,84 @@
|
|||||||
.details.get_denomination.label_source = _label_source, \
|
.details.get_denomination.label_source = _label_source, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new reserve in the database
|
||||||
|
*/
|
||||||
|
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE(_label) \
|
||||||
|
{ \
|
||||||
|
.command = PERF_TALER_MINTDB_CMD_INSERT_RESERVE, \
|
||||||
|
.label = _label, \
|
||||||
|
.exposed_type = PERF_TALER_MINTDB_RESERVE \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polls the database for a secific reserve's details
|
||||||
|
* @param _label_source Source for the reserve to poll
|
||||||
|
*/
|
||||||
|
#define PERF_TALER_MINTDB_INIT_CMD_GET_RESERVE(_label, _label_source) \
|
||||||
|
{ \
|
||||||
|
.command = PERF_TALER_MINTDB_CMD_GET_RESERVE, \
|
||||||
|
.label = _label, \
|
||||||
|
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||||
|
.details.get_reserve.label_source = _label_source \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a deposit into the database
|
||||||
|
* @param _label_dki source to use for the denomination key
|
||||||
|
*/
|
||||||
|
#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, \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a deposit is in the database
|
||||||
|
* @param _label_deposit Label of the deposit to use
|
||||||
|
*/
|
||||||
|
#define PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \
|
||||||
|
{ \
|
||||||
|
.command = PERF_TALER_MINTDB_CMD_GET_DEPOSIT, \
|
||||||
|
.label = _label, \
|
||||||
|
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||||
|
.details.get_deposit.label_source = _label_deposit \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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_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, \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polls the database about informations regarding a secific withdrawal
|
||||||
|
*/
|
||||||
|
#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \
|
||||||
|
{ \
|
||||||
|
.command = PERF_TALER_MINTDB_CMD_GET_WITHDRAW, \
|
||||||
|
.label = _label, \
|
||||||
|
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||||
|
.details.get_withdraw.label_source = _label_source, \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of data stored
|
* The type of data stored
|
||||||
@ -249,9 +265,7 @@ enum PERF_TALER_MINTDB_Type
|
|||||||
PERF_TALER_MINTDB_TIME,
|
PERF_TALER_MINTDB_TIME,
|
||||||
PERF_TALER_MINTDB_DEPOSIT,
|
PERF_TALER_MINTDB_DEPOSIT,
|
||||||
PERF_TALER_MINTDB_BLINDCOIN,
|
PERF_TALER_MINTDB_BLINDCOIN,
|
||||||
PERF_TALER_MINTDB_RESERVE_KEY,
|
|
||||||
PERF_TALER_MINTDB_RESERVE,
|
PERF_TALER_MINTDB_RESERVE,
|
||||||
PERF_TALER_MINTDB_DENOMINATION_KEY,
|
|
||||||
PERF_TALER_MINTDB_DENOMINATION_INFO,
|
PERF_TALER_MINTDB_DENOMINATION_INFO,
|
||||||
PERF_TALER_MINTDB_COIN_INFO,
|
PERF_TALER_MINTDB_COIN_INFO,
|
||||||
};
|
};
|
||||||
@ -266,7 +280,6 @@ union PERF_TALER_MINTDB_Data
|
|||||||
struct TALER_MINTDB_Deposit *deposit;
|
struct TALER_MINTDB_Deposit *deposit;
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *blindcoin;
|
struct TALER_MINTDB_CollectableBlindcoin *blindcoin;
|
||||||
struct TALER_MINTDB_Reserve *reserve;
|
struct TALER_MINTDB_Reserve *reserve;
|
||||||
struct TALER_DenominationPublicKey *dpk;
|
|
||||||
struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
|
struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
|
||||||
struct TALER_CoinPublicInfo *cpi;
|
struct TALER_CoinPublicInfo *cpi;
|
||||||
};
|
};
|
||||||
@ -334,8 +347,11 @@ enum PERF_TALER_MINTDB_CMD_Name
|
|||||||
// Insert informations about a denomination key in the database
|
// Insert informations about a denomination key in the database
|
||||||
PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION,
|
PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION,
|
||||||
|
|
||||||
// polls the database for informations about a specific denomination key
|
// Polls the database for informations about a specific denomination key
|
||||||
PERF_TALER_MINTDB_CMD_GET_DENOMINATION
|
PERF_TALER_MINTDB_CMD_GET_DENOMINATION,
|
||||||
|
|
||||||
|
// Refresh a coin
|
||||||
|
PERF_TALER_MINTDB_CMD_REFRESH_COIN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -346,7 +362,7 @@ struct PERF_TALER_MINTDB_CMD_loop_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;
|
||||||
int curr_iteration;
|
unsigned int curr_iteration;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -381,6 +397,12 @@ struct PERF_TALER_MINTDB_CMD_gauger_details
|
|||||||
* Description of the metric, used in GAUGER
|
* Description of the metric, used in GAUGER
|
||||||
*/
|
*/
|
||||||
const char *description;
|
const char *description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant the result needs to be divided by
|
||||||
|
* to get the result per unit
|
||||||
|
*/
|
||||||
|
float divide;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -438,6 +460,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
|
* Extra data requiered for the GET_DEPOSIT command
|
||||||
*/
|
*/
|
||||||
@ -470,6 +504,35 @@ struct PERF_TALER_MINTDB_CMD_get_denomination_details
|
|||||||
const char *label_source;
|
const char *label_source;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The label of the coin to refresh
|
||||||
|
*/
|
||||||
|
const char *label_source;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains extra data required for any command
|
* Contains extra data required for any command
|
||||||
*/
|
*/
|
||||||
@ -480,9 +543,12 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
struct PERF_TALER_MINTDB_CMD_gauger_details gauger;
|
struct PERF_TALER_MINTDB_CMD_gauger_details gauger;
|
||||||
struct PERF_TALER_MINTDB_CMD_save_array_details save_array;
|
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_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_deposit_details get_deposit;
|
||||||
struct PERF_TALER_MINTDB_CMD_get_reserve_details get_reserve;
|
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_get_denomination_details get_denomination;
|
||||||
|
struct PERF_TALER_MINTDB_CMD_refresh_coin_details refresh;
|
||||||
|
struct PERF_TALER_MINTDB_CMD_insert_withdraw_details insert_withdraw;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -515,12 +581,6 @@ struct PERF_TALER_MINTDB_Cmd
|
|||||||
* Data easily accessible
|
* Data easily accessible
|
||||||
*/
|
*/
|
||||||
union PERF_TALER_MINTDB_Data exposed;
|
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
|
|
||||||
*/
|
|
||||||
int exposed_saved;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -533,5 +593,4 @@ PERF_TALER_MINTDB_interpret(
|
|||||||
struct TALER_MINTDB_Plugin *db_plugin,
|
struct TALER_MINTDB_Plugin *db_plugin,
|
||||||
struct PERF_TALER_MINTDB_Cmd cmd[]);
|
struct PERF_TALER_MINTDB_Cmd cmd[]);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,16 +22,17 @@
|
|||||||
#define __PERF_TALER_MINTDB__VALUES_H__
|
#define __PERF_TALER_MINTDB__VALUES_H__
|
||||||
|
|
||||||
|
|
||||||
|
#define PERF_TALER_MINTDB_NB_DENOMINATION_INIT 10
|
||||||
|
#define PERF_TALER_MINTDB_NB_DENOMINATION_SAVE 10
|
||||||
|
|
||||||
#define NB_DEPOSIT_INIT 100000
|
#define PERF_TALER_MINTDB_NB_RESERVE_INIT 100
|
||||||
#define NB_DEPOSIT_GET 1000
|
#define PERF_TALER_MINTDB_NB_RESERVE_SAVE 10
|
||||||
#define NB_DEPOSIT_MARGIN 10000
|
|
||||||
|
|
||||||
#define NB_BLINDCOIN_INIT 100000
|
|
||||||
|
|
||||||
|
|
||||||
// Temporary macro to compile
|
#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 1000
|
||||||
#define GAUGER(a,b,c,d)
|
#define PERF_TALER_MINTDB_NB_DEPOSIT_SAVE 10
|
||||||
|
|
||||||
|
|
||||||
|
#define PERF_TALER_MINTDB_NB_WITHDRAW_INIT 100
|
||||||
|
#define PERF_TALER_MINTDB_NB_WITHDRAW_SAVE 10
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with GNUnet; see the file COPYING. If not, write to the
|
along with GNUnet; see the file COPYING. If not, write to the
|
||||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
Boston, MA 02111-1307, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user