diff options
Diffstat (limited to 'src/benchmark/taler-exchange-benchmark.c')
-rw-r--r-- | src/benchmark/taler-exchange-benchmark.c | 76 |
1 files 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; @@ -143,11 +145,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). */ struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh; @@ -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; i<num_coins; i++) + { + struct Coin fresh_coin; + struct TALER_Amount amount; + char *refresh_denom; + + GNUNET_asprintf (&refresh_denom, + "%s:%s", + currency, + refresh_denoms[i]); + fresh_coin.reserve_index = coins[rrcls->coin_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); |