From 6bd7d2fc851fa9731279d2b4881e0ce8f263a743 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Sat, 11 Jun 2016 17:35:15 +0200 Subject: defining struct for refreshed coins --- src/benchmark/taler-exchange-benchmark.c | 76 +++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 17 deletions(-) diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 0b2a4043c..5dffe8a1a 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -120,7 +120,9 @@ struct TALER_DenominationBlindingKeyP blinding_key; struct Coin { /** * Index in the reserve's global array indicating which - * reserve this coin is to be retrieved + * reserve this coin is to be retrieved. If the coin comes + * from a refresh, then this value is set to the melted coin's + * reserve index */ unsigned int reserve_index; @@ -142,11 +144,6 @@ struct Coin { */ struct TALER_CoinSpendPrivateKeyP coin_priv; - /** - * Blinding key used for the operation. - */ - struct TALER_DenominationBlindingKeyP blinding_key; - /** * Withdraw handle (while operation is running). */ @@ -211,8 +208,7 @@ static struct Reserve *reserves; static struct Coin *coins; /** - * Indices of spent coins (the first element always indicates - * the total number of elements, including itself) + * Indices of spent coins */ static unsigned int *spent_coins; @@ -275,6 +271,21 @@ static char *currency; */ static unsigned int refreshed_once = GNUNET_NO; +/** + * List of coins to get in return to a melt operation. Just a + * static list for now as every melt operation is carried out + * on a 8 KUDOS coin whose only 1 KUDOS has been spent, thus + * 7 KUDOS melted. This structure must be changed with one holding + * TALER_Amount structs, as every time it's needed it requires + * too many operations before getting the desired TALER_Amount. + */ +static char *refresh_denoms[] = { + "4", + "2", + "1", + NULL +}; + static unsigned int eval_probability (float probability) { @@ -380,7 +391,44 @@ reveal_cb (void *cls, const struct TALER_DenominationSignature *sigs, const json_t *full_response) { - /* TODO */ + /* FIXME to be freed */ + struct RefreshRevealCls *rrcls = cls; + unsigned int i; + const struct TALER_EXCHANGE_Keys *keys; + + coins[rrcls->coin_index].rrh = NULL; + if (MHD_HTTP_OK != http_status) + { + fail ("Not all coins correctly revealed\n"); + return; + } + else + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Coin revealed!\n"); + /** + * 1 Stuff a Coin structure + * 2 Place it in global array + */ + keys = TALER_EXCHANGE_get_keys (exchange); + for (i=0; icoin_index].reserve_index; + TALER_string_to_amount (refresh_denom, &amount); + GNUNET_free (refresh_denom); + fresh_coin.pk = find_pk (keys, &amount); + fresh_coin.sig = sigs[i]; + } + + + } /** @@ -404,6 +452,7 @@ melt_cb (void *cls, struct RefreshRevealCls *rrcls = cls; /* FIXME to be freed */ + coins[rrcls->coin_index].rmh = NULL; if (MHD_HTTP_OK != http_status) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -418,7 +467,7 @@ melt_cb (void *cls, rrcls->blob, noreveal_index, reveal_cb, - NULL); + rrcls); } /** @@ -818,13 +867,6 @@ cert_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Using currency: %s\n", currency); - char *refresh_denoms[] = { - "4", - "2", - "1", - NULL - }; - if (GNUNET_SYSERR == build_refresh (refresh_denoms)) { fail(NULL); -- cgit v1.2.3 From 4f4bad310bc3c34029e7c7d51184c3a163882555 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Sat, 11 Jun 2016 18:01:57 +0200 Subject: placing refreshed coins where all coins are --- src/benchmark/taler-exchange-benchmark.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 5dffe8a1a..761cc03bd 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -50,6 +50,14 @@ struct GNUNET_CONFIGURATION_Handle *cfg; */ static unsigned int nreserves; +/** + * How many coins are in `coins` array. This is needed + * as the number of coins is not always nreserves * COINS_PER_RESERVE + * due to refresh operations + */ +unsigned int ncoins; + + /** * Bank details of who creates reserves */ @@ -425,10 +433,12 @@ reveal_cb (void *cls, GNUNET_free (refresh_denom); fresh_coin.pk = find_pk (keys, &amount); fresh_coin.sig = sigs[i]; + GNUNET_array_append (coins, ncoins, fresh_coin); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "# of coins after refresh: %d\n", + ncoins); } - - - + GNUNET_free (rrcls); } /** @@ -768,7 +778,8 @@ benchmark_run (void *cls) reserves = GNUNET_new_array (nreserves, struct Reserve); - coins = GNUNET_new_array (COINS_PER_RESERVE * nreserves, + ncoins = COINS_PER_RESERVE * nreserves; + coins = GNUNET_new_array (ncoins, struct Coin); for (i=0;i < nreserves && 0 < nreserves;i++) -- cgit v1.2.3