initialization of the database
This commit is contained in:
parent
c023cdc96a
commit
582e623b13
@ -34,43 +34,74 @@ main (int argc, char ** argv)
|
|||||||
struct PERF_TALER_MINTDB_Cmd test[] =
|
struct PERF_TALER_MINTDB_Cmd test[] =
|
||||||
{
|
{
|
||||||
// Denomination used to create coins
|
// Denomination used to create coins
|
||||||
PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION ("denomination"),
|
PERF_TALER_MINTDB_INIT_CMD_LOOP ("01 - denomination loop",
|
||||||
|
PERF_TALER_MINTDB_NB_DENOMINATION_INIT),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("denomination inserted"),
|
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit",
|
PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION ("01 - denomination"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("01 - commit transaction"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination",
|
||||||
|
"01 - denomination loop",
|
||||||
|
"01 - denomination",
|
||||||
|
PERF_TALER_MINTDB_NB_DENOMINATION_SAVE,
|
||||||
|
PERF_TALER_MINTDB_BLINDCOIN),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("01 - denomination loop end",
|
||||||
|
"01 - denomination loop"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("01 - init denomination complete"),
|
||||||
|
// End of initialization
|
||||||
|
// Reserve initialization
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_LOOP ("02 - init reserve loop",
|
||||||
|
PERF_TALER_MINTDB_NB_RESERVE_INIT),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE ("02 - reserve"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve",
|
||||||
|
"02 - init reserve loop",
|
||||||
|
"02 - reserve",
|
||||||
|
PERF_TALER_MINTDB_NB_RESERVE_SAVE,
|
||||||
|
PERF_TALER_MINTDB_RESERVE),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("02 - init reserve end loop",
|
||||||
|
"02 - init reserve loop"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("02 - reserve init complete"),
|
||||||
|
// End reserve init
|
||||||
|
// Withdrawal initialization
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_LOOP ("03 - init withdraw loop",
|
||||||
|
PERF_TALER_MINTDB_NB_WITHDRAW_INIT),
|
||||||
|
// PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("03 - start transaction"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load",
|
||||||
|
"03 - init withdraw loop",
|
||||||
|
"01 - save denomination"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load",
|
||||||
|
"03 - init withdraw loop",
|
||||||
|
"02 - save reserve"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW ("03 - withdraw",
|
||||||
|
"03 - denomination load",
|
||||||
|
"03 - reserve load"),
|
||||||
|
// PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("03 - commit transaction"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("03 - blindcoin array",
|
||||||
|
"03 - init withdraw loop",
|
||||||
|
"03 - withdraw",
|
||||||
|
PERF_TALER_MINTDB_NB_WITHDRAW_SAVE,
|
||||||
|
PERF_TALER_MINTDB_BLINDCOIN),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop",
|
||||||
|
"03 - init withdraw loop"),
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("03 - withdraw init complete"),
|
||||||
|
//End of withdrawal initialization
|
||||||
|
//Deposit initialization
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_LOOP ("04 - deposit init loop",
|
||||||
PERF_TALER_MINTDB_NB_DEPOSIT_INIT),
|
PERF_TALER_MINTDB_NB_DEPOSIT_INIT),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_init"),
|
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("init_deposit_insert",
|
PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit",
|
||||||
"denomination"),
|
"01 - denomination"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"),
|
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("array_depo",
|
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
|
||||||
"loop_db_init_deposit",
|
"04 - deposit init loop",
|
||||||
"init_deposit_insert",
|
"04 - deposit",
|
||||||
PERF_TALER_MINTDB_NB_DEPOSIT_GET,
|
PERF_TALER_MINTDB_NB_DEPOSIT_SAVE,
|
||||||
PERF_TALER_MINTDB_DEPOSIT),
|
PERF_TALER_MINTDB_DEPOSIT),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit",
|
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("04 - deposit init loop end",
|
||||||
"loop_db_init_deposit"),
|
"04 - deposit init loop"),
|
||||||
// End of database initialization
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("04 - deposit init complete"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_start"),
|
// End of deposit initialization
|
||||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_deposit_get",
|
PERF_TALER_MINTDB_INIT_CMD_END ("end"),
|
||||||
PERF_TALER_MINTDB_NB_DEPOSIT_GET),
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("start_transaction_get"),
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("load_deposit",
|
|
||||||
"loop_deposit_get",
|
|
||||||
"array_depo"),
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT ("get_deposit",
|
|
||||||
"load_deposit"),
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("commit_transaction_init"),
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("stop2", "loop_deposit_get"),
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("deposit_get_end"),
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_GAUGER ("deposit_get_commit",
|
|
||||||
"deposit_get_start",
|
|
||||||
"deposit_get_end",
|
|
||||||
"time per deposit check",
|
|
||||||
PERF_TALER_MINTDB_NB_DEPOSIT_GET),
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_END("end"),
|
|
||||||
};
|
};
|
||||||
// Plugin init
|
|
||||||
|
|
||||||
GNUNET_log_setup ("perf-taler-mintdb",
|
GNUNET_log_setup ("perf-taler-mintdb",
|
||||||
"WARNING",
|
"WARNING",
|
||||||
|
@ -30,108 +30,115 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a randomly generated CollectableBlindcoin
|
* Generate a dummy DenominationKeyInformation for testing purposes
|
||||||
|
* @return a dummy denomination key
|
||||||
*/
|
*/
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *
|
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
||||||
PERF_TALER_MINTDB_collectable_blindcoin_init (
|
PERF_TALER_MINTDB_denomination_init ()
|
||||||
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
|
|
||||||
const struct TALER_MINTDB_Reserve *reserve)
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
return dki;
|
||||||
(coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin)));
|
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ()));
|
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(denomination_key = GNUNET_CRYPTO_rsa_private_key_create (512)));
|
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *
|
/**
|
||||||
PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin)
|
* Copies the given denomination
|
||||||
|
* @param reserve the deposit copy
|
||||||
|
* @return a copy of @a deposit; NULL if error
|
||||||
|
*/
|
||||||
|
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
||||||
|
PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *copy;
|
struct TALER_MINTDB_DenominationKeyIssueInformation *copy;
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(copy = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin)));
|
(copy = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)));
|
||||||
*copy = *coin;
|
*copy = *dki;
|
||||||
// No signature copy function found, Hacking it in
|
|
||||||
{
|
{
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
int size;
|
int size;
|
||||||
GNUNET_assert (0 <
|
GNUNET_assert (0 <
|
||||||
(size = GNUNET_CRYPTO_rsa_signature_encode (
|
(size = GNUNET_CRYPTO_rsa_private_key_encode (
|
||||||
coin->sig.rsa_signature,
|
dki->denom_priv.rsa_private_key,
|
||||||
&buffer)));
|
&buffer)));
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(copy->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_decode(
|
(copy->denom_priv.rsa_private_key =
|
||||||
buffer,
|
GNUNET_CRYPTO_rsa_private_key_decode(buffer, size)));
|
||||||
size)));
|
|
||||||
GNUNET_free (buffer);
|
GNUNET_free (buffer);
|
||||||
}
|
}
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(copy->denom_pub.rsa_public_key =
|
(copy->denom_pub.rsa_public_key =
|
||||||
GNUNET_CRYPTO_rsa_public_key_dup (coin->denom_pub.rsa_public_key)));
|
GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key)));
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Liberate memory of @a coin
|
* 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 ()
|
||||||
@ -146,14 +153,18 @@ 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 *
|
struct TALER_MINTDB_Reserve *
|
||||||
PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve)
|
PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve)
|
||||||
{
|
{
|
||||||
@ -165,6 +176,7 @@ PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Free memory of a reserve
|
* 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)
|
||||||
@ -177,36 +189,8 @@ PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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 (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
|
PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
|
||||||
@ -275,8 +259,8 @@ PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueIn
|
|||||||
GNUNET_assert(NULL !=
|
GNUNET_assert(NULL !=
|
||||||
(eddsa_prv = GNUNET_CRYPTO_eddsa_key_create ()));
|
(eddsa_prv = GNUNET_CRYPTO_eddsa_key_create ()));
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (
|
GNUNET_CRYPTO_eddsa_key_get_public (
|
||||||
eddsa_prv,
|
eddsa_prv,
|
||||||
&merchant_pub.eddsa_pub);
|
&merchant_pub.eddsa_pub);
|
||||||
GNUNET_free (eddsa_prv);
|
GNUNET_free (eddsa_prv);
|
||||||
}
|
}
|
||||||
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
@ -305,6 +289,11 @@ PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies the given deposit
|
||||||
|
* @param reserve the deposit copy
|
||||||
|
* @return a copy of @a deposit; NULL if error
|
||||||
|
*/
|
||||||
struct TALER_MINTDB_Deposit *
|
struct TALER_MINTDB_Deposit *
|
||||||
PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit)
|
PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit)
|
||||||
{
|
{
|
||||||
@ -334,6 +323,7 @@ PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Free memory of a deposit
|
* 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)
|
||||||
@ -350,71 +340,30 @@ 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 !=
|
||||||
|
(coin = GNUNET_new (struct TALER_MINTDB_CollectableBlindcoin)));
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)));
|
(reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ()));
|
||||||
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);
|
|
||||||
|
|
||||||
return dki;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
char *buffer = NULL;
|
||||||
int size;
|
int size;
|
||||||
@ -423,29 +372,118 @@ PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIs
|
|||||||
dki->denom_priv.rsa_private_key,
|
dki->denom_priv.rsa_private_key,
|
||||||
&buffer)));
|
&buffer)));
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(copy->denom_priv.rsa_private_key =
|
(denomination_key =
|
||||||
GNUNET_CRYPTO_rsa_private_key_decode(buffer, size)));
|
GNUNET_CRYPTO_rsa_private_key_decode (buffer, size)));
|
||||||
GNUNET_free (buffer);
|
GNUNET_free (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(copy->denom_pub.rsa_public_key =
|
(coin->denom_pub.rsa_public_key =
|
||||||
GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key)));
|
GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key)));
|
||||||
return copy;
|
coin->reserve_pub.eddsa_pub = 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,70 +27,72 @@
|
|||||||
#define CURRENCY "EUR"
|
#define CURRENCY "EUR"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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 (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
|
PERF_TALER_MINTDB_denomination_init (void);
|
||||||
const struct TALER_MINTDB_Reserve *reserve);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns a copy of @a coin
|
* Copies the given denomination
|
||||||
|
* @param reserve the deposit copy
|
||||||
|
* @return a copy of @a deposit; NULL if error
|
||||||
*/
|
*/
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *
|
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
||||||
PERF_TALER_MINTDB_collectable_blindcoin_copy (const struct TALER_MINTDB_CollectableBlindcoin *coin);
|
PERF_TALER_MINTDB_denomination_copy (
|
||||||
|
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Liberate memory of @a coin
|
* Free memory of a DenominationKeyIssueInformation
|
||||||
|
* @param dki pointer to the struct to free
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin);
|
PERF_TALER_MINTDB_denomination_free (
|
||||||
|
struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a randomly generated reserve
|
* Generate a dummy reserve for testing
|
||||||
|
* @return a reserve with 1000 EUR in it
|
||||||
*/
|
*/
|
||||||
struct TALER_MINTDB_Reserve *
|
struct TALER_MINTDB_Reserve *
|
||||||
PERF_TALER_MINTDB_reserve_init (void);
|
PERF_TALER_MINTDB_reserve_init (void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a copy of @reserve
|
* Copies the given reserve
|
||||||
|
* @param reserve the reserve to copy
|
||||||
|
* @return a copy of @a reserve; NULL if error
|
||||||
*/
|
*/
|
||||||
struct TALER_MINTDB_Reserve *
|
struct TALER_MINTDB_Reserve *
|
||||||
PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve);
|
PERF_TALER_MINTDB_reserve_copy (const struct TALER_MINTDB_Reserve *reserve);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees memory allocated to @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);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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 (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 *
|
struct TALER_MINTDB_Deposit *
|
||||||
PERF_TALER_MINTDB_deposit_init (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
PERF_TALER_MINTDB_deposit_init (
|
||||||
|
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns a copy of @a deposit
|
* Copies the given deposit
|
||||||
|
* @param reserve the deposit copy
|
||||||
|
* @return a copy of @a deposit; NULL if error
|
||||||
*/
|
*/
|
||||||
struct TALER_MINTDB_Deposit *
|
struct TALER_MINTDB_Deposit *
|
||||||
PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit);
|
PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit);
|
||||||
@ -98,29 +100,41 @@ PERF_TALER_MINTDB_deposit_copy (const struct TALER_MINTDB_Deposit *deposit);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Free memory of a deposit
|
* 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);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 (void);
|
PERF_TALER_MINTDB_collectable_blindcoin_init (
|
||||||
|
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki,
|
||||||
|
const struct TALER_MINTDB_Reserve *reserve);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns a copy of @a dki
|
* Copies the given coin
|
||||||
|
* @param coin the coin to copy
|
||||||
|
* @return a copy of coin; NULL if error
|
||||||
*/
|
*/
|
||||||
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
struct TALER_MINTDB_CollectableBlindcoin *
|
||||||
PERF_TALER_MINTDB_denomination_copy (const struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
PERF_TALER_MINTDB_collectable_blindcoin_copy (
|
||||||
|
const struct TALER_MINTDB_CollectableBlindcoin *coin);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free memory for a DenominationKeyIssueInformation
|
* Liberate memory of @a coin
|
||||||
|
* @param coin pointer to the structure to free
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
PERF_TALER_MINTDB_collectable_blindcoin_free (
|
||||||
|
struct TALER_MINTDB_CollectableBlindcoin *coin);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,4 +149,19 @@ PERF_TALER_MINTDB_coin_public_info_init (void);
|
|||||||
*/
|
*/
|
||||||
int PERF_TALER_MINTDB_coin_public_info_free (struct TALER_CoinPublicInfo *cpi);
|
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
|
||||||
|
@ -202,7 +202,7 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
union PERF_TALER_MINTDB_Data zero = {0};
|
union PERF_TALER_MINTDB_Data zero = {0};
|
||||||
unsigned int jump;
|
int jump;
|
||||||
GNUNET_assert (GNUNET_SYSERR !=
|
GNUNET_assert (GNUNET_SYSERR !=
|
||||||
(jump = cmd_find (state->cmd,
|
(jump = cmd_find (state->cmd,
|
||||||
state->cmd[state->i]
|
state->cmd[state->i]
|
||||||
@ -235,7 +235,7 @@ 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)
|
||||||
{
|
{
|
||||||
unsigned int loop_index, save_index;
|
int loop_index, save_index;
|
||||||
unsigned int selection_chance;
|
unsigned int selection_chance;
|
||||||
|
|
||||||
// Array initialization on first loop iteration
|
// Array initialization on first loop iteration
|
||||||
@ -314,7 +314,8 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
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_index, save_index, loop_iter, permut_index;
|
unsigned int loop_iter;
|
||||||
|
int loop_index, save_index;
|
||||||
union PERF_TALER_MINTDB_Data zero = {0};
|
union PERF_TALER_MINTDB_Data zero = {0};
|
||||||
union PERF_TALER_MINTDB_Data *loaded_data;
|
union PERF_TALER_MINTDB_Data *loaded_data;
|
||||||
|
|
||||||
@ -327,11 +328,18 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
state->cmd[state->i]
|
state->cmd[state->i]
|
||||||
.details.load_array.label_save)));
|
.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;
|
||||||
permut_index = state->cmd[state->i].details.load_array.permutation[loop_iter];
|
{
|
||||||
|
int i, quotient;
|
||||||
|
quotient = loop_iter / state->cmd[save_index].details.save_array.nb_saved;
|
||||||
|
loop_iter = loop_iter % state->cmd[save_index].details.save_array.nb_saved;
|
||||||
|
for (i=0; i<=quotient; i++){
|
||||||
|
loop_iter = state->cmd[state->i].details.load_array.permutation[loop_iter];
|
||||||
|
}
|
||||||
|
}
|
||||||
/* Extracting the data from the loop_indexth indice in save_index
|
/* Extracting the data from the loop_indexth indice in save_index
|
||||||
* array.
|
* array.
|
||||||
*/
|
*/
|
||||||
loaded_data = &state->cmd[save_index].details.save_array.data_saved[permut_index];
|
loaded_data = &state->cmd[save_index].details.save_array.data_saved[loop_index];
|
||||||
switch (state->cmd[state->i].exposed_type)
|
switch (state->cmd[state->i].exposed_type)
|
||||||
{
|
{
|
||||||
case PERF_TALER_MINTDB_TIME:
|
case PERF_TALER_MINTDB_TIME:
|
||||||
@ -393,7 +401,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GAUGER:
|
case PERF_TALER_MINTDB_CMD_GAUGER:
|
||||||
{
|
{
|
||||||
unsigned int start_index, stop_index;
|
int start_index, stop_index;
|
||||||
struct timespec start, stop;
|
struct timespec start, stop;
|
||||||
unsigned long elapsed_ms;
|
unsigned long elapsed_ms;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Prints @ _label to stdout
|
||||||
*/
|
*/
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_DEBUG(_label) \
|
#define PERF_TALER_MINTDB_INIT_CMD_DEBUG(_label) \
|
||||||
{ \
|
{ \
|
||||||
@ -86,6 +86,10 @@
|
|||||||
/**
|
/**
|
||||||
* 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, _label_start, _label_stop, _description, _divide) \
|
#define PERF_TALER_MINTDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, _description, _divide) \
|
||||||
{ \
|
{ \
|
||||||
@ -151,27 +155,26 @@
|
|||||||
.label_save = _label_save \
|
.label_save = _label_save \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a deposit into the database
|
* Inserts informations about a denomination key in the database
|
||||||
*/
|
*/
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_dki) \
|
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \
|
||||||
{ \
|
{ \
|
||||||
.command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\
|
.command = PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION, \
|
||||||
.label = _label, \
|
.label = _label, \
|
||||||
.exposed_type = PERF_TALER_MINTDB_DEPOSIT, \
|
.exposed_type = PERF_TALER_MINTDB_DENOMINATION_INFO, \
|
||||||
.details.insert_deposit.label_dki = _label_dki, \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a deposit is in the database
|
* Polls the database about informations regarding a specific denomination key
|
||||||
* @param _label_deposit Label of the deposit to use
|
|
||||||
*/
|
*/
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \
|
#define PERF_TALER_MINTDB_INIT_CMD_GET_DENOMINATION(_label, _label_source) \
|
||||||
{ \
|
{ \
|
||||||
.command = PERF_TALER_MINTDB_CMD_GET_DEPOSIT, \
|
.command = PERF_TALER_MINTDB_CMD_GET_DENOMINATION, \
|
||||||
.label = _label, \
|
.label = _label, \
|
||||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||||
.details.get_deposit.label_source = _label_deposit \
|
.details.get_denomination.label_source = _label_source, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,8 +201,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* 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) \
|
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_dki, _label_reserve) \
|
||||||
{ \
|
{ \
|
||||||
@ -208,9 +239,9 @@
|
|||||||
.exposed_type = PERF_TALER_MINTDB_BLINDCOIN, \
|
.exposed_type = PERF_TALER_MINTDB_BLINDCOIN, \
|
||||||
.details.insert_withdraw = {\
|
.details.insert_withdraw = {\
|
||||||
.label_dki = _label_dki, \
|
.label_dki = _label_dki, \
|
||||||
.label.reserve = _label_reserve, \
|
.label_reserve = _label_reserve, \
|
||||||
} \
|
} \
|
||||||
}\
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -224,27 +255,6 @@
|
|||||||
.details.get_withdraw.label_source = _label_source, \
|
.details.get_withdraw.label_source = _label_source, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Inserts informations about a denomination key in the database
|
|
||||||
*/
|
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \
|
|
||||||
{ \
|
|
||||||
.command = PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION, \
|
|
||||||
.label = _label, \
|
|
||||||
.exposed_type = PERF_TALER_MINTDB_DENOMINATION_INFO, \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Polls the database about informations regarding a specific denomination key
|
|
||||||
*/
|
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_DENOMINATION(_label, _label_source) \
|
|
||||||
{ \
|
|
||||||
.command = PERF_TALER_MINTDB_CMD_GET_DENOMINATION, \
|
|
||||||
.label = _label, \
|
|
||||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
|
||||||
.details.get_denomination.label_source = _label_source, \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of data stored
|
* The type of data stored
|
||||||
|
@ -22,10 +22,17 @@
|
|||||||
#define __PERF_TALER_MINTDB__VALUES_H__
|
#define __PERF_TALER_MINTDB__VALUES_H__
|
||||||
|
|
||||||
|
|
||||||
|
#define PERF_TALER_MINTDB_NB_DENOMINATION_INIT 100
|
||||||
|
#define PERF_TALER_MINTDB_NB_DENOMINATION_SAVE 100
|
||||||
|
|
||||||
#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100
|
#define PERF_TALER_MINTDB_NB_RESERVE_INIT 10000
|
||||||
#define PERF_TALER_MINTDB_NB_DEPOSIT_GET 1
|
#define PERF_TALER_MINTDB_NB_RESERVE_SAVE 1000
|
||||||
|
|
||||||
|
|
||||||
|
#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100000
|
||||||
|
#define PERF_TALER_MINTDB_NB_DEPOSIT_SAVE 1000
|
||||||
|
|
||||||
|
|
||||||
|
#define PERF_TALER_MINTDB_NB_WITHDRAW_INIT 100000
|
||||||
|
#define PERF_TALER_MINTDB_NB_WITHDRAW_SAVE 1000
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user