Fix includes and more indentation
This commit is contained in:
parent
006c55b3de
commit
ec56e47809
@ -18,8 +18,8 @@
|
|||||||
* @brief Mint database performance analysis
|
* @brief Mint database performance analysis
|
||||||
* @author Nicolas Fournier
|
* @author Nicolas Fournier
|
||||||
*/
|
*/
|
||||||
|
#include "platform.h"
|
||||||
#include "perf_taler_mintdb_interpreter.h"
|
#include "perf_taler_mintdb_interpreter.h"
|
||||||
#include "./perf_taler_mintdb_init.h"
|
|
||||||
#include "perf_taler_mintdb_values.h"
|
#include "perf_taler_mintdb_values.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,18 +29,8 @@
|
|||||||
int
|
int
|
||||||
main (int argc, char ** argv)
|
main (int argc, char ** argv)
|
||||||
{
|
{
|
||||||
struct GNUNET_CONFIGURATION_Handle *config =
|
struct TALER_MINTDB_Plugin *plugin;
|
||||||
GNUNET_CONFIGURATION_create();
|
struct GNUNET_CONFIGURATION_Handle *config;
|
||||||
|
|
||||||
GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf");
|
|
||||||
|
|
||||||
struct TALER_MINTDB_Plugin *plugin = TALER_MINTDB_plugin_load (config);
|
|
||||||
GNUNET_CONFIGURATION_destroy(config);
|
|
||||||
|
|
||||||
// creation of temporary tables
|
|
||||||
plugin->create_tables (plugin->cls, GNUNET_YES);
|
|
||||||
|
|
||||||
|
|
||||||
struct PERF_TALER_MINTDB_Cmd test[] =
|
struct PERF_TALER_MINTDB_Cmd test[] =
|
||||||
{
|
{
|
||||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit",100000),
|
PERF_TALER_MINTDB_INIT_CMD_LOOP ("loop_db_init_deposit",100000),
|
||||||
@ -48,14 +38,23 @@ main (int argc, char ** argv)
|
|||||||
PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("init_deposit_insert"),
|
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_COMMIT_TRANSACTION ("commit_transaction_init"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit","loop_db_init_deposit"),
|
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("endloop_init_deposit","loop_db_init_deposit"),
|
||||||
|
|
||||||
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_END("end")
|
PERF_TALER_MINTDB_INIT_CMD_END("end")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
config = GNUNET_CONFIGURATION_create();
|
||||||
|
GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf");
|
||||||
|
GNUNET_assert (NULL !=
|
||||||
|
(plugin = TALER_MINTDB_plugin_load (config)));
|
||||||
|
plugin->create_tables (plugin->cls, GNUNET_YES);
|
||||||
PERF_TALER_MINTDB_interpret(plugin, test);
|
PERF_TALER_MINTDB_interpret(plugin, test);
|
||||||
|
{
|
||||||
|
struct TALER_MINTDB_Session *session;
|
||||||
|
|
||||||
|
session = plugin->get_session (plugin->cls, GNUNET_YES);
|
||||||
|
plugin->drop_temporary (plugin->cls, session);
|
||||||
|
}
|
||||||
|
|
||||||
TALER_MINTDB_plugin_unload(plugin);
|
TALER_MINTDB_plugin_unload(plugin);
|
||||||
|
GNUNET_CONFIGURATION_destroy(config);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
@ -34,66 +34,49 @@
|
|||||||
struct TALER_MINTDB_CollectableBlindcoin *
|
struct TALER_MINTDB_CollectableBlindcoin *
|
||||||
collectable_blindcoin_init ()
|
collectable_blindcoin_init ()
|
||||||
{
|
{
|
||||||
|
uint32_t random_int;
|
||||||
struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key;
|
struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key;
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key;
|
||||||
// indent by 2 spaces
|
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *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));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t 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);
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
uint32_t data;
|
uint32_t data;
|
||||||
} unsigned_data;
|
} unsigned_data;
|
||||||
|
struct TALER_MINTDB_CollectableBlindcoin *coin;
|
||||||
|
|
||||||
unsigned_data.purpose.size = sizeof (unsigned_data);
|
|
||||||
unsigned_data.purpose.purpose = GNUNET_SIGNATURE_PURPOSE_TEST;
|
|
||||||
unsigned_data.data = random_int;
|
|
||||||
|
|
||||||
|
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 ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
GNUNET_CRYPTO_eddsa_sign (reserve_sig_key,
|
TALER_string_to_amount (CURRENCY ":1.1",
|
||||||
(struct GNUNET_CRYPTO_EccSignaturePurpose *) &unsigned_data,
|
&coin->amount_with_fee));
|
||||||
&coin->reserve_sig.eddsa_signature)
|
GNUNET_assert (GNUNET_OK ==
|
||||||
);
|
TALER_string_to_amount (CURRENCY ":1.1",
|
||||||
|
&coin->withdraw_fee));
|
||||||
|
random_int =
|
||||||
GNUNET_CRYPTO_eddsa_key_clear (reserve_sig_key);
|
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);
|
GNUNET_CRYPTO_rsa_private_key_free (denomination_key);
|
||||||
return coin;
|
return coin;
|
||||||
}
|
}
|
||||||
@ -106,11 +89,10 @@ collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin)
|
|||||||
{
|
{
|
||||||
if (NULL == coin)
|
if (NULL == coin)
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
|
|
||||||
GNUNET_CRYPTO_rsa_signature_free (coin->sig.rsa_signature);
|
GNUNET_CRYPTO_rsa_signature_free (coin->sig.rsa_signature);
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (coin->denom_pub.rsa_public_key);
|
GNUNET_CRYPTO_rsa_public_key_free (coin->denom_pub.rsa_public_key);
|
||||||
|
|
||||||
GNUNET_free (coin);
|
GNUNET_free (coin);
|
||||||
|
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,28 +103,19 @@ collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *coin)
|
|||||||
struct TALER_MINTDB_Reserve *
|
struct TALER_MINTDB_Reserve *
|
||||||
reserve_init ()
|
reserve_init ()
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Reserve *reserve ;
|
struct TALER_MINTDB_Reserve *reserve;
|
||||||
|
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_priv;
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(reserve = GNUNET_new (struct TALER_MINTDB_Reserve)
|
(reserve = GNUNET_new (struct TALER_MINTDB_Reserve)));
|
||||||
));
|
|
||||||
|
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_priv ;
|
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(reserve_priv = GNUNET_CRYPTO_eddsa_key_create ()
|
(reserve_priv = GNUNET_CRYPTO_eddsa_key_create ()));
|
||||||
));
|
|
||||||
|
|
||||||
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 ":1.1", &reserve->balance));
|
||||||
);
|
|
||||||
|
|
||||||
reserve->expiry = GNUNET_TIME_absolute_get_forever_ ();
|
reserve->expiry = GNUNET_TIME_absolute_get_forever_ ();
|
||||||
|
GNUNET_free (reserve_priv);
|
||||||
GNUNET_CRYPTO_eddsa_key_clear (reserve_priv);
|
|
||||||
return reserve;
|
return reserve;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,10 +138,9 @@ struct TALER_MINTDB_RefreshSession *
|
|||||||
refresh_session_init ()
|
refresh_session_init ()
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_RefreshSession *refresh_session;
|
struct TALER_MINTDB_RefreshSession *refresh_session;
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(refresh_session = GNUNET_new (struct TALER_MINTDB_RefreshSession)
|
|
||||||
));
|
|
||||||
|
|
||||||
|
GNUNET_assert (NULL !=
|
||||||
|
(refresh_session = GNUNET_new (struct TALER_MINTDB_RefreshSession)));
|
||||||
refresh_session->noreveal_index = 1;
|
refresh_session->noreveal_index = 1;
|
||||||
refresh_session->num_oldcoins = 1;
|
refresh_session->num_oldcoins = 1;
|
||||||
refresh_session->num_newcoins = 1;
|
refresh_session->num_newcoins = 1;
|
||||||
@ -198,26 +170,20 @@ deposit_init ()
|
|||||||
struct TALER_MINTDB_Deposit *deposit;
|
struct TALER_MINTDB_Deposit *deposit;
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(deposit = GNUNET_new (struct TALER_MINTDB_Deposit)
|
(deposit = GNUNET_new (struct TALER_MINTDB_Deposit)));
|
||||||
));
|
|
||||||
deposit-> transaction_id = transaction_id;
|
deposit-> transaction_id = transaction_id;
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_string_to_amount (CURRENCY ":1.1", &deposit->amount_with_fee)
|
TALER_string_to_amount (CURRENCY ":1.1",
|
||||||
);
|
&deposit->amount_with_fee));
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_string_to_amount (CURRENCY ":0.1", &deposit->deposit_fee)
|
TALER_string_to_amount (CURRENCY ":0.1",
|
||||||
);
|
&deposit->deposit_fee));
|
||||||
|
|
||||||
|
|
||||||
deposit->timestamp = GNUNET_TIME_absolute_get ();
|
deposit->timestamp = GNUNET_TIME_absolute_get ();
|
||||||
deposit->refund_deadline = GNUNET_TIME_absolute_get ();
|
deposit->refund_deadline = GNUNET_TIME_absolute_get ();
|
||||||
|
|
||||||
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
&deposit->h_contract);
|
&deposit->h_contract);
|
||||||
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
&deposit->h_wire);
|
&deposit->h_wire);
|
||||||
|
|
||||||
// Coin Spend Signature
|
// Coin Spend Signature
|
||||||
{
|
{
|
||||||
struct u32_presign
|
struct u32_presign
|
||||||
@ -225,81 +191,61 @@ deposit_init ()
|
|||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
uint32_t data;
|
uint32_t data;
|
||||||
} unsigned_data;
|
} unsigned_data;
|
||||||
|
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt;
|
||||||
|
uint32_t random_int;
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ()
|
(eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ()));
|
||||||
));
|
|
||||||
|
|
||||||
uint32_t random_int =
|
|
||||||
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
|
|
||||||
|
|
||||||
|
|
||||||
|
random_int = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
|
UINT32_MAX);
|
||||||
unsigned_data.purpose.size = htonl (sizeof (struct u32_presign));
|
unsigned_data.purpose.size = htonl (sizeof (struct u32_presign));
|
||||||
unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
|
unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
|
||||||
unsigned_data.data = random_int;
|
unsigned_data.data = random_int;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
GNUNET_CRYPTO_eddsa_sign (eddsa_prvt,
|
GNUNET_CRYPTO_eddsa_sign (eddsa_prvt,
|
||||||
&unsigned_data.purpose,
|
&unsigned_data.purpose,
|
||||||
&deposit->csig.eddsa_signature));
|
&deposit->csig.eddsa_signature));
|
||||||
|
// No need to clear as this is a dummy key
|
||||||
GNUNET_CRYPTO_eddsa_key_clear (eddsa_prvt);
|
GNUNET_free (eddsa_prvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("coin signed");
|
|
||||||
// Merchant Key
|
// Merchant Key
|
||||||
{
|
{
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv;
|
||||||
|
|
||||||
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,
|
||||||
&deposit->merchant_pub.eddsa_pub);
|
&deposit->merchant_pub.eddsa_pub);
|
||||||
|
GNUNET_free (eddsa_prv);
|
||||||
|
|
||||||
GNUNET_CRYPTO_eddsa_key_clear (eddsa_prv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("merchant ok");
|
|
||||||
// Coin
|
// Coin
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prvt;
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ()
|
(eddsa_prvt = GNUNET_CRYPTO_eddsa_key_create ()));
|
||||||
));
|
|
||||||
|
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (
|
GNUNET_CRYPTO_eddsa_key_get_public (
|
||||||
eddsa_prvt,
|
eddsa_prvt,
|
||||||
&deposit->coin.coin_pub.eddsa_pub
|
&deposit->coin.coin_pub.eddsa_pub);
|
||||||
);
|
GNUNET_free (eddsa_prvt);
|
||||||
|
|
||||||
|
|
||||||
GNUNET_CRYPTO_eddsa_key_clear (eddsa_prvt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
struct GNUNET_CRYPTO_rsa_PrivateKey *rsa_prv;
|
struct GNUNET_CRYPTO_rsa_PrivateKey *rsa_prv;
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(rsa_prv = GNUNET_CRYPTO_rsa_private_key_create (128)
|
|
||||||
));
|
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(deposit->coin.denom_pub.rsa_public_key =
|
(rsa_prv = GNUNET_CRYPTO_rsa_private_key_create (128)));
|
||||||
GNUNET_CRYPTO_rsa_private_key_get_public (rsa_prv)
|
|
||||||
));
|
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(deposit->coin.denom_sig.rsa_signature =
|
(deposit->coin.denom_pub.rsa_public_key =
|
||||||
GNUNET_CRYPTO_rsa_sign (rsa_prv,
|
GNUNET_CRYPTO_rsa_private_key_get_public (rsa_prv)));
|
||||||
(void *) &deposit->coin.coin_pub.eddsa_pub,
|
GNUNET_assert (NULL !=
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)
|
(deposit->coin.denom_sig.rsa_signature =
|
||||||
)
|
GNUNET_CRYPTO_rsa_sign (rsa_prv,
|
||||||
));
|
&deposit->coin.coin_pub.eddsa_pub,
|
||||||
|
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))));
|
||||||
GNUNET_CRYPTO_rsa_private_key_free (rsa_prv);
|
GNUNET_CRYPTO_rsa_private_key_free (rsa_prv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,7 +263,6 @@ deposit_free (struct TALER_MINTDB_Deposit *deposit)
|
|||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (deposit->coin.denom_pub.rsa_public_key);
|
GNUNET_CRYPTO_rsa_public_key_free (deposit->coin.denom_pub.rsa_public_key);
|
||||||
GNUNET_CRYPTO_rsa_signature_free (deposit->coin.denom_sig.rsa_signature);
|
GNUNET_CRYPTO_rsa_signature_free (deposit->coin.denom_sig.rsa_signature);
|
||||||
|
|
||||||
GNUNET_free (deposit);
|
GNUNET_free (deposit);
|
||||||
|
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
@ -336,46 +281,32 @@ denomination_init ()
|
|||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)
|
(dki = GNUNET_new (struct TALER_MINTDB_DenominationKeyIssueInformation)));
|
||||||
));
|
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(dki->denom_priv.rsa_private_key
|
(dki->denom_priv.rsa_private_key
|
||||||
= GNUNET_CRYPTO_rsa_private_key_create (128)
|
= GNUNET_CRYPTO_rsa_private_key_create (128)));
|
||||||
));
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(dki->denom_pub.rsa_public_key =
|
(dki->denom_pub.rsa_public_key =
|
||||||
GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_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,
|
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
|
||||||
&dki->issue.denom_hash);
|
&dki->issue.denom_hash);
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
GNUNET_assert (NULL !=
|
||||||
(master_prvt = GNUNET_CRYPTO_eddsa_key_create ()
|
(master_prvt = GNUNET_CRYPTO_eddsa_key_create ()));
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (master_prvt,
|
GNUNET_CRYPTO_eddsa_key_get_public (master_prvt,
|
||||||
&dki->issue.master.eddsa_pub);
|
&dki->issue.master.eddsa_pub);
|
||||||
|
|
||||||
anchor = GNUNET_TIME_absolute_get ();
|
anchor = GNUNET_TIME_absolute_get ();
|
||||||
|
|
||||||
dki->issue.start = GNUNET_TIME_absolute_hton (anchor);
|
dki->issue.start = GNUNET_TIME_absolute_hton (anchor);
|
||||||
dki->issue.expire_withdraw =
|
dki->issue.expire_withdraw =
|
||||||
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
|
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
|
||||||
GNUNET_TIME_relative_get_hour_ ()));
|
GNUNET_TIME_relative_get_hour_ ()));
|
||||||
dki->issue.expire_spend =
|
dki->issue.expire_spend =
|
||||||
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
|
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
|
||||||
GNUNET_TIME_relative_get_hour_ ()));
|
GNUNET_TIME_relative_get_hour_ ()));
|
||||||
dki->issue.expire_legal =
|
dki->issue.expire_legal =
|
||||||
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
|
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor,
|
||||||
GNUNET_TIME_relative_get_hour_ ()));
|
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", &amount));
|
||||||
);
|
|
||||||
|
|
||||||
TALER_amount_hton (&dki->issue.value, &amount);
|
TALER_amount_hton (&dki->issue.value, &amount);
|
||||||
TALER_amount_hton (&dki->issue.fee_withdraw, &amount);
|
TALER_amount_hton (&dki->issue.fee_withdraw, &amount);
|
||||||
TALER_amount_hton (&dki->issue.fee_deposit, &amount);
|
TALER_amount_hton (&dki->issue.fee_deposit, &amount);
|
||||||
@ -383,14 +314,13 @@ denomination_init ()
|
|||||||
dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
|
dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
|
||||||
dki->issue.purpose.size =
|
dki->issue.purpose.size =
|
||||||
htonl (sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation) -
|
htonl (sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation) -
|
||||||
offsetof (struct TALER_MINTDB_DenominationKeyIssueInformation,
|
offsetof (struct TALER_MINTDB_DenominationKeyIssueInformation,
|
||||||
issue.purpose));
|
issue.purpose));
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
GNUNET_CRYPTO_eddsa_sign (master_prvt,
|
GNUNET_CRYPTO_eddsa_sign (master_prvt,
|
||||||
&dki->issue.purpose,
|
&dki->issue.purpose,
|
||||||
&dki->issue.signature.eddsa_signature));
|
&dki->issue.signature.eddsa_signature));
|
||||||
|
GNUNET_free (master_prvt);
|
||||||
GNUNET_CRYPTO_eddsa_key_clear (master_prvt);
|
|
||||||
|
|
||||||
return dki;
|
return dki;
|
||||||
}
|
}
|
||||||
@ -406,7 +336,6 @@ denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
|
|||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key);
|
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_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key);
|
||||||
|
|
||||||
GNUNET_free (dki);
|
GNUNET_free (dki);
|
||||||
|
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
|
@ -40,7 +40,7 @@ reserve_init (void);
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
reserve_free (struct TALER_MINTDB_Reserve);
|
reserve_free (struct TALER_MINTDB_Reserve *reserve);
|
||||||
|
|
||||||
|
|
||||||
struct TALER_MINTDB_RefreshSession *
|
struct TALER_MINTDB_RefreshSession *
|
||||||
@ -48,20 +48,19 @@ refresh_session_init (void);
|
|||||||
|
|
||||||
|
|
||||||
struct TALER_MINTDB_Deposit *
|
struct TALER_MINTDB_Deposit *
|
||||||
deposit_init (int transaction_id);
|
deposit_init ();
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
deposit_free (struct TALER_MINTDB_Deposit *deposit);
|
||||||
|
|
||||||
|
|
||||||
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
||||||
init_denomination(void);
|
init_denomination(void);
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
deposit_free (struct TALER_MINTDB_Deposit *deposit);
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
* @brief Interpreter library for mint database performance analysis
|
* @brief Interpreter library for mint database performance analysis
|
||||||
* @author Nicolas Fournier
|
* @author Nicolas Fournier
|
||||||
*/
|
*/
|
||||||
|
#include "platform.h"
|
||||||
#include "perf_taler_mintdb_interpreter.h"
|
#include "perf_taler_mintdb_interpreter.h"
|
||||||
#include "perf_taler_mintdb_init.h"
|
#include "perf_taler_mintdb_init.h"
|
||||||
#include "../include/gauger.h"
|
#include "gauger.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,13 +109,15 @@ cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[])
|
|||||||
// Creating the permutation array to randomize the data order
|
// Creating the permutation array to randomize the data order
|
||||||
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[i].details.load_array.label_save)].details.save_array.nb_saved);
|
cmd[cmd_find (cmd,
|
||||||
|
cmd[i].details.load_array.label_save)]
|
||||||
|
.details.save_array.nb_saved);
|
||||||
|
|
||||||
// Initializing the type based on the type of the saved array
|
// Initializing the type based on the type of the saved array
|
||||||
cmd[i].exposed_type = cmd[
|
cmd[i].exposed_type = cmd[cmd_find (cmd,
|
||||||
cmd_find (cmd, cmd[i].details.load_array.label_save)
|
cmd[i].details.load_array.label_save)]
|
||||||
].details.save_array.type_saved;
|
.details.save_array.type_saved;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -142,7 +145,7 @@ cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[])
|
|||||||
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],
|
||||||
cmd[i].details.save_array.type_saved);
|
cmd[i].details.save_array.type_saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_free (cmd[i].details.save_array.data_saved);
|
GNUNET_free (cmd[i].details.save_array.data_saved);
|
||||||
@ -173,9 +176,11 @@ 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 jump = cmd_find (state->cmd, state->cmd[state->i].details.end_loop.label_loop);
|
int jump = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.end_loop.label_loop);
|
||||||
// If the loop is not finished
|
// If the loop is not finished
|
||||||
if (state->cmd[jump].details.loop.max_iterations > state->cmd[jump].details.loop.curr_iteration)
|
if (state->cmd[jump].details.loop.max_iterations >
|
||||||
|
state->cmd[jump].details.loop.curr_iteration)
|
||||||
{
|
{
|
||||||
// jump back to the start
|
// jump back to the start
|
||||||
state->i = jump -1;
|
state->i = jump -1;
|
||||||
@ -187,20 +192,18 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
int j;
|
int j;
|
||||||
for (j = jump; j < state->i; j++)
|
for (j = jump; j < state->i; j++)
|
||||||
{
|
{
|
||||||
// If the exposed variable has not been copied
|
// If the exposed variable has not been copied it is freed
|
||||||
if ( 0 == state->cmd[j].exposed_saved)
|
if ( GNUNET_NO == state->cmd[j].exposed_saved)
|
||||||
{
|
|
||||||
// It is freed
|
|
||||||
data_free (&state->cmd[j].exposed, state->cmd[j].exposed_type);
|
data_free (&state->cmd[j].exposed, state->cmd[j].exposed_type);
|
||||||
}
|
state->cmd[j].exposed_saved = GNUNET_NO;
|
||||||
state->cmd[j].exposed_saved = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* /TODO cut it into pieces
|
* Main interpreter loop.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||||
@ -227,12 +230,16 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GAUGER:
|
case PERF_TALER_MINTDB_CMD_GAUGER:
|
||||||
{
|
{
|
||||||
int start_index = cmd_find (state->cmd, state->cmd[state->i].details.gauger.label_start);
|
int start_index, stop_index;
|
||||||
int stop_index = cmd_find (state->cmd, state->cmd[state->i].details.gauger.label_stop);
|
struct timespec start, stop;
|
||||||
struct timespec start = state->cmd [start_index].exposed.time;
|
unsigned long elapsed_ms;
|
||||||
struct timespec stop = state->cmd [stop_index].exposed.time;
|
start_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.gauger.label_start);
|
||||||
unsigned long elapsed_ms = (start.tv_sec - stop.tv_sec) * 1000 + (start.tv_nsec - stop.tv_nsec) / 1000000;
|
stop_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.gauger.label_stop);
|
||||||
|
start = state->cmd [start_index].exposed.time;
|
||||||
|
stop = state->cmd [stop_index].exposed.time;
|
||||||
|
elapsed_ms = (start.tv_sec - stop.tv_sec) * 1000 + (start.tv_nsec - stop.tv_nsec) / 1000000;
|
||||||
|
|
||||||
GAUGER ("MINTDB", state->cmd[state->i].details.gauger.description, elapsed_ms, "milliseconds");
|
GAUGER ("MINTDB", state->cmd[state->i].details.gauger.description, elapsed_ms, "milliseconds");
|
||||||
}
|
}
|
||||||
@ -240,7 +247,6 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_NEW_SESSION:
|
case PERF_TALER_MINTDB_CMD_NEW_SESSION:
|
||||||
state->session = state->plugin->get_session (state->plugin->cls, GNUNET_YES);
|
state->session = state->plugin->get_session (state->plugin->cls, GNUNET_YES);
|
||||||
// TODO what about the old session ?
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_START_TRANSACTION:
|
case PERF_TALER_MINTDB_CMD_START_TRANSACTION:
|
||||||
@ -256,37 +262,42 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
||||||
{
|
{
|
||||||
|
int loop_index;
|
||||||
|
int proba;
|
||||||
|
int rnd;
|
||||||
// Array initialization on first loop iteration
|
// Array initialization on first loop iteration
|
||||||
// Alows for nested loops
|
// Alows for nested loops
|
||||||
if (state->cmd[cmd_find (state->cmd, state->cmd[state->i].details.save_array.label_loop)].details.loop.curr_iteration == 0)
|
if (0 == state->cmd[cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.save_array.label_loop)]
|
||||||
|
.details.loop.curr_iteration)
|
||||||
{
|
{
|
||||||
state->cmd[state->i].details.save_array.index = 0;
|
state->cmd[state->i].details.save_array.index = 0;
|
||||||
}
|
}
|
||||||
|
loop_index = cmd_find (state->cmd,
|
||||||
// TODO check the logic here. It probably can be improved
|
state->cmd[state->i].details.save_array.label_loop);
|
||||||
|
// The probobility distribution of the saved items will be a little biased
|
||||||
int loop_index = cmd_find (state->cmd, state->cmd[state->i].details.save_array.label_loop);
|
// against the few last items but it should not be a big problem.
|
||||||
int proba = state->cmd[loop_index].details.loop.max_iterations / state->cmd[state->i].details.save_array.nb_saved;
|
proba = state->cmd[loop_index].details.loop.max_iterations /
|
||||||
int rnd = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, proba);
|
state->cmd[state->i].details.save_array.nb_saved;
|
||||||
|
rnd = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, proba);
|
||||||
|
/*
|
||||||
/**
|
* If the remaining sapce is equal to the remaining number of
|
||||||
* If the room available 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 rdn is 0
|
||||||
*/
|
*/
|
||||||
if ((state->cmd[loop_index].details.loop.max_iterations - state->cmd[loop_index].details.loop.curr_iteration ==
|
if ((state->cmd[loop_index].details.loop.max_iterations - state->cmd[loop_index].details.loop.curr_iteration ==
|
||||||
state->cmd[state->i].details.save_array.nb_saved - state->cmd[state->i].details.save_array.index) ||
|
state->cmd[state->i].details.save_array.nb_saved - state->cmd[state->i].details.save_array.index) ||
|
||||||
(rnd == 0))
|
(rnd == 0))
|
||||||
{
|
{
|
||||||
|
union PERF_TALER_MINTDB_Data *save_location;
|
||||||
|
union PERF_TALER_MINTDB_Data *item_saved;
|
||||||
|
|
||||||
union PERF_TALER_MINTDB_Data *save_location =
|
save_location = &state->cmd[state->i].details.save_array.data_saved[
|
||||||
&state->cmd[state->i].details.save_array.data_saved[state->cmd[state->i].details.save_array.index];
|
state->cmd[state->i].details.save_array.index];
|
||||||
union PERF_TALER_MINTDB_Data *item_saved =
|
item_saved = &state->cmd[cmd_find (state->cmd,
|
||||||
&state->cmd[cmd_find (state->cmd, state->cmd[state->i].details.save_array.label_save)].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_DEPOSIT:
|
case PERF_TALER_MINTDB_DEPOSIT:
|
||||||
@ -300,6 +311,9 @@ interpret (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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,18 +321,18 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
|
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
|
||||||
{
|
{
|
||||||
int loop_index = cmd_find (state->cmd, state->cmd[state->i].details.load_array.label_loop);
|
int loop_index, save_index;
|
||||||
int save_index = cmd_find (state->cmd, state->cmd[state->i].details.load_array.label_save);
|
union PERF_TALER_MINTDB_Data loaded_data;
|
||||||
|
loop_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.load_array.label_loop);
|
||||||
|
save_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.load_array.label_save);
|
||||||
/* Extracting the data from the loop_indexth indice in save_index
|
/* Extracting the data from the loop_indexth indice in save_index
|
||||||
* array.
|
* array.
|
||||||
*/
|
*/
|
||||||
union PERF_TALER_MINTDB_Data loaded_data =
|
loaded_data = state->cmd[save_index].details.save_array.data_saved[
|
||||||
state->cmd[save_index].details.save_array.data_saved[
|
|
||||||
state->cmd[state->i].details.load_array.permutation[
|
state->cmd[state->i].details.load_array.permutation[
|
||||||
state->cmd[loop_index].details.loop.curr_iteration
|
state->cmd[loop_index].details.loop.curr_iteration]];
|
||||||
]];
|
|
||||||
|
|
||||||
|
|
||||||
switch (state->cmd[state->i].exposed_type)
|
switch (state->cmd[state->i].exposed_type)
|
||||||
{
|
{
|
||||||
@ -339,16 +353,18 @@ 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 = deposit_init (-1);
|
struct TALER_MINTDB_Deposit *deposit = deposit_init (-1);
|
||||||
state->plugin->insert_deposit (state->plugin->cls, state->session, deposit);
|
|
||||||
|
|
||||||
|
state->plugin->insert_deposit (state->plugin->cls, state->session, deposit);
|
||||||
state->cmd[state->i].exposed.deposit = deposit;
|
state->cmd[state->i].exposed.deposit = deposit;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_MINTDB_CMD_GET_DEPOSIT:
|
case PERF_TALER_MINTDB_CMD_GET_DEPOSIT:
|
||||||
{
|
{
|
||||||
int source_index = cmd_find (state->cmd, state->cmd[state->i].details.get_deposit.label_source); // Find the source location
|
struct TALER_MINTDB_Deposit *deposit =
|
||||||
struct TALER_MINTDB_Deposit *deposit = state->cmd[source_index].exposed.deposit; // Get the deposit from the source
|
state->cmd[cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.get_deposit.label_source)]
|
||||||
|
.exposed.deposit; // Get the deposit from the source
|
||||||
state->plugin->have_deposit (state->plugin->cls, state->session, deposit);
|
state->plugin->have_deposit (state->plugin->cls, state->session, deposit);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -367,20 +383,16 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PERF_TALER_MINTDB_interpret (struct TALER_MINTDB_Plugin *db_plugin,
|
PERF_TALER_MINTDB_interpret (struct TALER_MINTDB_Plugin *db_plugin,
|
||||||
struct PERF_TALER_MINTDB_Cmd cmd[])
|
struct PERF_TALER_MINTDB_Cmd cmd[])
|
||||||
{
|
{
|
||||||
|
struct PERF_TALER_MINTDB_interpreter_state state = {.i = 0, .cmd = cmd, .plugin = db_plugin};
|
||||||
|
|
||||||
// Initializing commands
|
// Initializing commands
|
||||||
cmd_init (cmd);
|
cmd_init (state.cmd);
|
||||||
|
|
||||||
// Running the interpreter
|
// Running the interpreter
|
||||||
struct PERF_TALER_MINTDB_interpreter_state state =
|
|
||||||
{.i = 0, .cmd = cmd, .plugin = db_plugin};
|
|
||||||
state.session = db_plugin->get_session (db_plugin->cls, GNUNET_YES);
|
state.session = db_plugin->get_session (db_plugin->cls, GNUNET_YES);
|
||||||
|
|
||||||
interpret (&state);
|
interpret (&state);
|
||||||
|
|
||||||
// Cleaning the memory
|
// Cleaning the memory
|
||||||
cmd_clean (cmd);
|
cmd_clean (cmd);
|
||||||
|
|
||||||
return GNUNET_YES;
|
return GNUNET_YES;
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#define __PERF_TALER_MINTDB_INTERPRETER_H__
|
#define __PERF_TALER_MINTDB_INTERPRETER_H__
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "../include/platform.h"
|
#include "taler_mintdb_plugin.h"
|
||||||
#include "../include/taler_mintdb_lib.h"
|
|
||||||
#include "../include/taler_mintdb_plugin.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the end of the command chain
|
* Marks the end of the command chain
|
||||||
@ -389,10 +387,18 @@ struct PERF_TALER_MINTDB_Cmd
|
|||||||
*/
|
*/
|
||||||
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;
|
int exposed_saved;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the command array @a cmd
|
||||||
|
* using @a db_plugin to connect to the database
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
PERF_TALER_MINTDB_interpret(
|
PERF_TALER_MINTDB_interpret(
|
||||||
struct TALER_MINTDB_Plugin *db_plugin,
|
struct TALER_MINTDB_Plugin *db_plugin,
|
||||||
|
Loading…
Reference in New Issue
Block a user