restructure benchmark logic so that we can schedule each operation independently

This commit is contained in:
Christian Grothoff 2016-06-15 16:36:17 +02:00
parent b31c62039d
commit e4b9a151a6

View File

@ -29,49 +29,6 @@
#include <microhttpd.h> #include <microhttpd.h>
#include <jansson.h> #include <jansson.h>
/**
* Should we initialize and start the exchange, if #GNUNET_NO,
* we expect one to be already up and running.
*/
static int run_exchange;
/**
* How many coins the benchmark should operate on
*/
static unsigned int pool_size = 100;
/**
* Configuration file path
*/
static char *config_file;
/**
* Configuation object (used to get BANK_URI)
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* How many reserves ought to be created given the pool size
*/
static unsigned int nreserves;
/**
* How many coins are in the #coins array. This is needed
* as the number of coins is not always #nreserves * #COINS_PER_RESERVE
* due to refresh operations
*/
static unsigned int ncoins;
/**
* Bank details of who creates reserves
*/
static json_t *bank_details;
/**
* Bank details of who deposits coins
*/
static json_t *merchant_details;
/** /**
* Information needed by the /refresh/melt's callback * Information needed by the /refresh/melt's callback
@ -125,21 +82,6 @@ struct Reserve
}; };
/**
* Array of denomination keys needed to perform the refresh operation
*/
static struct TALER_EXCHANGE_DenomPublicKey *refresh_pk;
/**
* Size of #refresh_pk
*/
static unsigned int refresh_pk_len;
/**
* Same blinding key for all coins
*/
static struct TALER_DenominationBlindingKeyP blinding_key;
/** /**
* Information regarding a coin * Information regarding a coin
*/ */
@ -208,6 +150,65 @@ struct Coin
}; };
/**
* Should we initialize and start the exchange, if #GNUNET_NO,
* we expect one to be already up and running.
*/
static int run_exchange;
/**
* How many coins the benchmark should operate on
*/
static unsigned int pool_size = 100;
/**
* Configuration file path
*/
static char *config_file;
/**
* Configuation object (used to get BANK_URI)
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* How many reserves ought to be created given the pool size
*/
static unsigned int nreserves;
/**
* How many coins are in the #coins array. This is needed
* as the number of coins is not always #nreserves * #COINS_PER_RESERVE
* due to refresh operations
*/
static unsigned int ncoins;
/**
* Bank details of who creates reserves
*/
static json_t *bank_details;
/**
* Bank details of who deposits coins
*/
static json_t *merchant_details;
/**
* Array of denomination keys needed to perform the refresh operation
*/
static struct TALER_EXCHANGE_DenomPublicKey *refresh_pk;
/**
* Size of #refresh_pk
*/
static unsigned int refresh_pk_len;
/**
* Same blinding key for all coins
*/
static struct TALER_DenominationBlindingKeyP blinding_key;
/** /**
* Handle to the exchange's process * Handle to the exchange's process
*/ */
@ -302,11 +303,6 @@ static char *currency;
*/ */
#define REFRESH_PROBABILITY 0.4 #define REFRESH_PROBABILITY 0.4
/**
* Refreshed once. For each batch of deposits, only one
* coin will be refreshed, according to #REFRESH_PROBABILITY
*/
static unsigned int refreshed_once;
/** /**
* List of coins to get in return to a melt operation. Just a * List of coins to get in return to a melt operation. Just a
@ -358,6 +354,26 @@ fail (const char *msg)
} }
/**
* Main task for the benchmark.
*
* @param cls NULL
*/
static void
benchmark_run (void *cls);
/**
* Run the main task for the benchmark.
*/
static void
continue_master_task ()
{
benchmark_task = GNUNET_SCHEDULER_add_now (&benchmark_run,
NULL);
}
/** /**
* Find denomination key matching the given amount. * Find denomination key matching the given amount.
* *
@ -461,8 +477,7 @@ reveal_cb (void *cls,
revealed_str = TALER_amount_to_string (&rrcls->denoms[i]); revealed_str = TALER_amount_to_string (&rrcls->denoms[i]);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"revealing %s " "revealing %s # of coins after refresh: %d\n",
"# of coins after refresh: %d\n",
revealed_str, revealed_str,
ncoins); ncoins);
GNUNET_free (revealed_str); GNUNET_free (revealed_str);
@ -475,6 +490,7 @@ reveal_cb (void *cls,
fresh_coin); fresh_coin);
} }
GNUNET_free (rrcls); GNUNET_free (rrcls);
continue_master_task ();
} }
@ -536,6 +552,81 @@ reserve_withdraw_cb (void *cls,
const json_t *full_response); const json_t *full_response);
/**
* Refresh the given @a coin
*
* @param coin coin to refresh
*/
static void
refresh_coin (struct Coin *coin)
{
struct RefreshRevealCls *rrcls;
char *blob;
size_t blob_size;
const struct TALER_EXCHANGE_Keys *keys;
struct TALER_Amount *denoms = NULL;
struct TALER_EXCHANGE_DenomPublicKey *dpks = NULL;
const struct TALER_EXCHANGE_DenomPublicKey *curr_dpk;
struct TALER_Amount curr;
unsigned int ndenoms = 0;
unsigned int ndenoms2 = 0;
unsigned long long acc_value;
TALER_amount_get_zero (currency, &curr);
acc_value = 0;
keys = TALER_EXCHANGE_get_keys (exchange);
for (curr.value = COIN_VALUE >> 1; curr.value > 0; curr.value = curr.value >> 1)
{
if (acc_value + curr.value <= coin->left.value)
{
GNUNET_array_append (denoms,
ndenoms,
curr);
GNUNET_assert (NULL != (curr_dpk = find_pk (keys, &curr)));
GNUNET_array_append (dpks,
ndenoms2,
*curr_dpk);
acc_value += curr.value;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"# of coins to get in melt: %d\n",
ndenoms2);
blob = TALER_EXCHANGE_refresh_prepare (&coin->coin_priv,
&coin->left,
&coin->sig,
coin->pk,
GNUNET_YES,
ndenoms2,
dpks,
&blob_size);
if (NULL == blob)
{
fail ("Failed to prepare refresh");
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Prepared blob of size %d for refresh\n",
(unsigned int) blob_size);
rrcls = GNUNET_new (struct RefreshRevealCls);
rrcls->blob = blob;
rrcls->blob_size = blob_size;
rrcls->coin_index = coin->coin_index;
rrcls->denoms = denoms;
coin->rmh = TALER_EXCHANGE_refresh_melt (exchange,
blob_size,
blob,
&melt_cb,
rrcls);
if (NULL == coin->rmh)
{
fail ("Impossible to issue a melt request to the exchange");
return;
}
}
/** /**
* Function called with the result of a /deposit operation. * Function called with the result of a /deposit operation.
* *
@ -565,122 +656,22 @@ deposit_cb (void *cls,
"Coin #%d correctly spent!\n", "Coin #%d correctly spent!\n",
coin->coin_index); coin->coin_index);
if (GNUNET_YES == coin->refresh) if (GNUNET_YES == coin->refresh)
{ refresh_coin (coin);
struct RefreshRevealCls *rrcls;
char *blob;
size_t blob_size;
const struct TALER_EXCHANGE_Keys *keys;
struct TALER_Amount *denoms = NULL;
struct TALER_EXCHANGE_DenomPublicKey *dpks = NULL;
const struct TALER_EXCHANGE_DenomPublicKey *curr_dpk;
struct TALER_Amount curr;
unsigned int ndenoms = 0;
unsigned int ndenoms2 = 0;
unsigned long long acc_value;
TALER_amount_get_zero (currency, &curr);
acc_value = 0;
keys = TALER_EXCHANGE_get_keys (exchange);
for (curr.value = COIN_VALUE >> 1; curr.value > 0; curr.value = curr.value >> 1)
{
if (acc_value + curr.value <= coin->left.value)
{
GNUNET_array_append (denoms,
ndenoms,
curr);
GNUNET_assert (NULL != (curr_dpk = find_pk (keys, &curr)));
GNUNET_array_append (dpks, ndenoms2, *curr_dpk);
acc_value += curr.value;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"# of coins to get in melt: %d\n",
ndenoms2);
blob = TALER_EXCHANGE_refresh_prepare (&coin->coin_priv,
&coin->left,
&coin->sig,
coin->pk,
GNUNET_YES,
ndenoms2,
dpks,
&blob_size);
if (NULL == blob)
{
fail ("Failed to prepare refresh");
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"prepared blob %d\n",
(unsigned int) blob_size);
refreshed_once = GNUNET_YES;
rrcls = GNUNET_new (struct RefreshRevealCls);
rrcls->blob = blob;
rrcls->blob_size = blob_size;
rrcls->coin_index = coin->coin_index;
rrcls->denoms = denoms;
coin->rmh = TALER_EXCHANGE_refresh_melt (exchange,
blob_size,
blob,
&melt_cb,
rrcls);
if (NULL == coin->rmh)
{
fail ("Impossible to issue a melt request to the exchange");
return;
}
}
else else
{ /* re-withdraw */ continue_master_task ();
struct GNUNET_CRYPTO_EddsaPrivateKey *coin_priv;
coin_priv = GNUNET_CRYPTO_eddsa_key_create ();
coin->coin_priv.eddsa_priv = *coin_priv;
GNUNET_free (coin_priv);
coin->wsh =
TALER_EXCHANGE_reserve_withdraw (exchange,
coin->pk,
&reserves[coin->reserve_index].reserve_priv,
&coin->coin_priv,
&blinding_key,
&reserve_withdraw_cb,
coin);
}
} }
/** /**
* Function called upon completion of our /reserve/withdraw request. * Spend the given coin. Also triggers refresh
* This is merely the function which spends withdrawn coins. For each * with a certain probability.
* spent coin, ti either refresh it or re-withdraw it.
* *
* @param cls closure with our `struct Coin` * @param coin coin to spend
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request * @param do_refresh should we also do the refresh?
* 0 if the exchange's reply is bogus (fails to follow the protocol)
* @param sig signature over the coin, NULL on error
* @param full_response full response from the exchange (for logging, in case of errors)
*/ */
static void static void
reserve_withdraw_cb (void *cls, spend_coin (struct Coin *coin,
unsigned int http_status, int do_refresh)
const struct TALER_DenominationSignature *sig,
const json_t *full_response)
{
struct Coin *coin = cls;
coin->wsh = NULL;
if (MHD_HTTP_OK != http_status)
{
json_dumpf (full_response, stderr, 0);
fail ("At least one coin has not correctly been withdrawn");
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%d-th coin withdrawn\n",
coin->coin_index);
coin->sig.rsa_signature =
GNUNET_CRYPTO_rsa_signature_dup (sig->rsa_signature);
if (GNUNET_OK == eval_probability (SPEND_PROBABILITY))
{ {
struct TALER_Amount amount; struct TALER_Amount amount;
struct GNUNET_TIME_Absolute wire_deadline; struct GNUNET_TIME_Absolute wire_deadline;
@ -709,8 +700,7 @@ reserve_withdraw_cb (void *cls,
"Spending %d-th coin\n", "Spending %d-th coin\n",
coin->coin_index); coin->coin_index);
if ( (GNUNET_YES == eval_probability (REFRESH_PROBABILITY)) && if (do_refresh)
(GNUNET_NO == refreshed_once) )
{ {
/** /**
* Always spending 1 out of 8 KUDOS. To be improved by randomly * Always spending 1 out of 8 KUDOS. To be improved by randomly
@ -728,7 +718,6 @@ reserve_withdraw_cb (void *cls,
&coin->pk->value, &coin->pk->value,
&one); &one);
coin->refresh = GNUNET_YES; coin->refresh = GNUNET_YES;
refreshed_once = GNUNET_YES;
} }
else else
{ {
@ -770,7 +759,7 @@ reserve_withdraw_cb (void *cls,
&coin->sig, &coin->sig,
&coin->pk->key, &coin->pk->key,
timestamp, timestamp,
transaction_id, transaction_id++,
&merchant_pub, &merchant_pub,
refund_deadline, refund_deadline,
&coin_sig, &coin_sig,
@ -778,12 +767,77 @@ reserve_withdraw_cb (void *cls,
coin); coin);
if (NULL == coin->dh) if (NULL == coin->dh)
{ {
json_decref (merchant_details);
fail ("An error occurred while calling deposit API"); fail ("An error occurred while calling deposit API");
return; return;
} }
transaction_id++;
} }
/**
* Function called upon completion of our /reserve/withdraw request.
* This is merely the function which spends withdrawn coins. For each
* spent coin, ti either refresh it or re-withdraw it.
*
* @param cls closure with our `struct Coin`
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
* @param sig signature over the coin, NULL on error
* @param full_response full response from the exchange (for logging, in case of errors)
*/
static void
reserve_withdraw_cb (void *cls,
unsigned int http_status,
const struct TALER_DenominationSignature *sig,
const json_t *full_response)
{
struct Coin *coin = cls;
coin->wsh = NULL;
if (MHD_HTTP_OK != http_status)
{
json_dumpf (full_response, stderr, 0);
fail ("At least one coin has not correctly been withdrawn");
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%d-th coin withdrawn\n",
coin->coin_index);
coin->sig.rsa_signature =
GNUNET_CRYPTO_rsa_signature_dup (sig->rsa_signature);
continue_master_task ();
}
/**
* Withdraw the given coin from the respective reserve.
*
* @param coin coin to withdraw
*/
static void
withdraw_coin (struct Coin *coin)
{
struct GNUNET_CRYPTO_EddsaPrivateKey *coin_priv;
struct TALER_Amount amount;
const struct TALER_EXCHANGE_Keys *keys;
struct Reserve *r;
keys = TALER_EXCHANGE_get_keys (exchange);
r = &reserves[coin->reserve_index];
coin_priv = GNUNET_CRYPTO_eddsa_key_create ();
coin->coin_priv.eddsa_priv = *coin_priv;
GNUNET_free (coin_priv);
TALER_amount_get_zero (currency,
&amount);
amount.value = COIN_VALUE;
GNUNET_assert (NULL != (coin->pk = find_pk (keys, &amount)));
coin->wsh =
TALER_EXCHANGE_reserve_withdraw (exchange,
coin->pk,
&r->reserve_priv,
&coin->coin_priv,
&blinding_key,
&reserve_withdraw_cb,
coin);
} }
@ -802,11 +856,6 @@ add_incoming_cb (void *cls,
const json_t *full_response) const json_t *full_response)
{ {
struct Reserve *r = cls; struct Reserve *r = cls;
struct GNUNET_CRYPTO_EddsaPrivateKey *coin_priv;
unsigned int i;
unsigned int coin_index;
struct TALER_Amount amount;
const struct TALER_EXCHANGE_Keys *keys;
r->aih = NULL; r->aih = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@ -818,81 +867,33 @@ add_incoming_cb (void *cls,
fail ("At least one reserve failed in being created"); fail ("At least one reserve failed in being created");
return; return;
} }
continue_master_task ();
keys = TALER_EXCHANGE_get_keys (exchange);
for (i=0; i < COINS_PER_RESERVE; i++)
{
struct Coin *coin;
coin_index = r->reserve_index * COINS_PER_RESERVE + i;
coin = &coins[coin_index];
coin->coin_index = coin_index;
coin_priv = GNUNET_CRYPTO_eddsa_key_create ();
coin->coin_priv.eddsa_priv = *coin_priv;
GNUNET_free (coin_priv);
coin->reserve_index = r->reserve_index;
TALER_amount_get_zero (currency,
&amount);
amount.value = COIN_VALUE;
GNUNET_assert (NULL != (coin->pk = find_pk (keys, &amount)));
coin->wsh =
TALER_EXCHANGE_reserve_withdraw (exchange,
coin->pk,
&r->reserve_priv,
&coin->coin_priv,
&blinding_key,
&reserve_withdraw_cb,
coin);
}
} }
/** /**
* Main task for the benchmark. * Fill a reserve using /admin/add/incoming
* *
* @param cls NULL * @param r reserve to fill
*/ */
static void static void
benchmark_run (void *cls) fill_reserve (struct Reserve *r)
{ {
unsigned int i;
struct GNUNET_CRYPTO_EddsaPrivateKey *priv; struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
json_t *transfer_details;
struct TALER_ReservePublicKeyP reserve_pub; struct TALER_ReservePublicKeyP reserve_pub;
struct GNUNET_TIME_Absolute execution_date; struct GNUNET_TIME_Absolute execution_date;
struct TALER_Amount reserve_amount; struct TALER_Amount reserve_amount;
json_t *transfer_details;
benchmark_task = NULL; TALER_amount_get_zero (currency,
priv = GNUNET_CRYPTO_eddsa_key_create (); &reserve_amount);
merchant_priv.eddsa_priv = *priv;
GNUNET_free (priv);
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
&blinding_key,
sizeof (blinding_key));
TALER_amount_get_zero (currency, &reserve_amount);
reserve_amount.value = RESERVE_VALUE; reserve_amount.value = RESERVE_VALUE;
execution_date = GNUNET_TIME_absolute_get (); execution_date = GNUNET_TIME_absolute_get ();
GNUNET_TIME_round_abs (&execution_date); GNUNET_TIME_round_abs (&execution_date);
nreserves = pool_size / COINS_PER_RESERVE;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating %d reserves\n",
nreserves);
reserves = GNUNET_new_array (nreserves,
struct Reserve);
ncoins = COINS_PER_RESERVE * nreserves;
coins = GNUNET_new_array (ncoins,
struct Coin);
for (i=0;i < nreserves;i++)
{
struct Reserve *r = &reserves[i];
priv = GNUNET_CRYPTO_eddsa_key_create (); priv = GNUNET_CRYPTO_eddsa_key_create ();
r->reserve_priv.eddsa_priv = *priv; r->reserve_priv.eddsa_priv = *priv;
GNUNET_free (priv); GNUNET_free (priv);
r->reserve_index = i;
transfer_details = json_pack ("{s:I}", transfer_details = json_pack ("{s:I}",
"uuid", (json_int_t) transfer_uuid++); "uuid", (json_int_t) transfer_uuid++);
GNUNET_assert (NULL != transfer_details); GNUNET_assert (NULL != transfer_details);
@ -910,9 +911,50 @@ benchmark_run (void *cls)
GNUNET_assert (NULL != r->aih); GNUNET_assert (NULL != r->aih);
json_decref (transfer_details); json_decref (transfer_details);
} }
json_decref (bank_details);
bank_details = NULL;
transfer_details = NULL; /**
* Main task for the benchmark.
*
* @param cls NULL
*/
static void
benchmark_run (void *cls)
{
unsigned int i;
benchmark_task = NULL;
/* FIXME: Note that this function cannot work as-is, it's
just a placeholder for the final logic we want here. */
for (i=0;i < nreserves;i++)
{
struct Reserve *r = &reserves[i];
r->reserve_index = i;
fill_reserve (r);
for (i=0; i < COINS_PER_RESERVE; i++)
{
struct Coin *coin;
unsigned int coin_index;
coin_index = r->reserve_index * COINS_PER_RESERVE + i;
coin = &coins[coin_index];
coin->coin_index = coin_index;
coin->reserve_index = r->reserve_index;
withdraw_coin (coin);
}
}
if (GNUNET_OK == eval_probability (SPEND_PROBABILITY))
{
struct Coin *coin;
i = 0; // FIXME...
coin = &coins[i];
spend_coin (coin,
(GNUNET_YES == eval_probability (REFRESH_PROBABILITY))); }
} }
@ -993,7 +1035,7 @@ cert_cb (void *cls,
if (NULL != currency) if (NULL != currency)
return; /* we've been here before... */ return; /* we've been here before... */
currency = GNUNET_strdup (_keys->denom_keys[0].value.currency); currency = GNUNET_strdup (_keys->denom_keys[0].value.currency);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Using currency: %s\n", "Using currency: %s\n",
currency); currency);
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
@ -1002,8 +1044,7 @@ cert_cb (void *cls,
fail ("Initializing denominations failed"); fail ("Initializing denominations failed");
return; return;
} }
benchmark_task = GNUNET_SCHEDULER_add_now (&benchmark_run, continue_master_task ();
NULL);
} }
@ -1020,18 +1061,11 @@ do_shutdown (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Shutting down...\n"); "Shutting down...\n");
if (NULL != benchmark_task) if (NULL != benchmark_task)
{ {
GNUNET_SCHEDULER_cancel (benchmark_task); GNUNET_SCHEDULER_cancel (benchmark_task);
benchmark_task = NULL; benchmark_task = NULL;
} }
/**
* WARNING: all the non NULL handles must correspond to non completed
* calls (AKA calls for which the callback function has not been called).
* If not, it segfaults
*/
for (i=0; i<nreserves; i++) for (i=0; i<nreserves; i++)
{ {
if (NULL != reserves[i].aih) if (NULL != reserves[i].aih)
@ -1045,37 +1079,39 @@ do_shutdown (void *cls)
} }
for (i=0; i<COINS_PER_RESERVE * nreserves; i++) for (i=0; i<COINS_PER_RESERVE * nreserves; i++)
{ {
if (NULL != coins[i].wsh) struct Coin *coin = &coins[i];
if (NULL != coin->wsh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Cancelling %d-th coin withdraw handle\n", "Cancelling %d-th coin withdraw handle\n",
i); i);
TALER_EXCHANGE_reserve_withdraw_cancel(coins[i].wsh); TALER_EXCHANGE_reserve_withdraw_cancel (coin->wsh);
coins[i].wsh = NULL; coin->wsh = NULL;
} }
if (NULL != coins[i].dh) if (NULL != coin->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Cancelling %d-th coin deposit handle\n", "Cancelling %d-th coin deposit handle\n",
i); i);
TALER_EXCHANGE_deposit_cancel(coins[i].dh); TALER_EXCHANGE_deposit_cancel(coin->dh);
coins[i].dh = NULL; coin->dh = NULL;
} }
if (NULL != coins[i].rmh) if (NULL != coin->rmh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Cancelling %d-th coin melt handle\n", "Cancelling %d-th coin melt handle\n",
i); i);
TALER_EXCHANGE_refresh_melt_cancel(coins[i].rmh); TALER_EXCHANGE_refresh_melt_cancel (coin->rmh);
coins[i].rmh = NULL; coin->rmh = NULL;
} }
if (NULL != coins[i].rrh) if (NULL != coin->rrh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Cancelling %d-th coin reveal handle\n", "Cancelling %d-th coin reveal handle\n",
i); i);
TALER_EXCHANGE_refresh_reveal_cancel(coins[i].rrh); TALER_EXCHANGE_refresh_reveal_cancel (coin->rrh);
coins[i].rmh = NULL; coin->rmh = NULL;
} }
} }
if (NULL != bank_details) if (NULL != bank_details)
@ -1089,8 +1125,11 @@ do_shutdown (void *cls)
merchant_details = NULL; merchant_details = NULL;
} }
GNUNET_free_non_null (reserves); GNUNET_free_non_null (reserves);
reserves = NULL;
GNUNET_free_non_null (coins); GNUNET_free_non_null (coins);
coins = NULL;
GNUNET_free_non_null (currency); GNUNET_free_non_null (currency);
currency = NULL;
if (NULL != exchange) if (NULL != exchange)
{ {
@ -1120,6 +1159,7 @@ do_shutdown (void *cls)
/** /**
* Main function that will be run by the scheduler. * Main function that will be run by the scheduler.
* Prepares everything for the benchmark.
* *
* @param cls closure * @param cls closure
*/ */
@ -1128,6 +1168,7 @@ run (void *cls)
{ {
char *bank_details_filename; char *bank_details_filename;
char *merchant_details_filename; char *merchant_details_filename;
struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"running run()\n"); "running run()\n");
@ -1190,8 +1231,22 @@ run (void *cls)
fail ("Failed to parse file with MERCHANT_DETAILS"); fail ("Failed to parse file with MERCHANT_DETAILS");
return; return;
} }
reserves = NULL;
coins = NULL; priv = GNUNET_CRYPTO_eddsa_key_create ();
merchant_priv.eddsa_priv = *priv;
GNUNET_free (priv);
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
&blinding_key,
sizeof (blinding_key));
nreserves = pool_size / COINS_PER_RESERVE;
reserves = GNUNET_new_array (nreserves,
struct Reserve);
ncoins = COINS_PER_RESERVE * nreserves;
coins = GNUNET_new_array (ncoins,
struct Coin);
ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule, ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
&rc); &rc);
GNUNET_assert (NULL != ctx); GNUNET_assert (NULL != ctx);