From 87376e02eba3f5c2cf83a493446dee0c300565a4 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 25 Dec 2021 13:56:33 +0100 Subject: protocol v12 changes (/recoup split, signature changes) plus database sharding plus O(n^2)=>O(n) worst-case complexity reduction on coin balance checks --- src/lib/exchange_api_recoup.c | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) (limited to 'src/lib/exchange_api_recoup.c') diff --git a/src/lib/exchange_api_recoup.c b/src/lib/exchange_api_recoup.c index 05012926f..63e6480cd 100644 --- a/src/lib/exchange_api_recoup.c +++ b/src/lib/exchange_api_recoup.c @@ -79,11 +79,6 @@ struct TALER_EXCHANGE_RecoupHandle */ struct TALER_CoinSpendPublicKeyP coin_pub; - /** - * #GNUNET_YES if the coin was refreshed - */ - int was_refreshed; - }; @@ -99,17 +94,10 @@ static enum GNUNET_GenericReturnValue process_recoup_response (const struct TALER_EXCHANGE_RecoupHandle *ph, const json_t *json) { - int refreshed; struct TALER_ReservePublicKeyP reserve_pub; - struct TALER_CoinSpendPublicKeyP old_coin_pub; struct GNUNET_JSON_Specification spec_withdraw[] = { - GNUNET_JSON_spec_boolean ("refreshed", &refreshed), - GNUNET_JSON_spec_fixed_auto ("reserve_pub", &reserve_pub), - GNUNET_JSON_spec_end () - }; - struct GNUNET_JSON_Specification spec_refresh[] = { - GNUNET_JSON_spec_boolean ("refreshed", &refreshed), - GNUNET_JSON_spec_fixed_auto ("old_coin_pub", &old_coin_pub), + GNUNET_JSON_spec_fixed_auto ("reserve_pub", + &reserve_pub), GNUNET_JSON_spec_end () }; struct TALER_EXCHANGE_HttpResponse hr = { @@ -119,21 +107,15 @@ process_recoup_response (const struct TALER_EXCHANGE_RecoupHandle *ph, if (GNUNET_OK != GNUNET_JSON_parse (json, - ph->was_refreshed ? spec_refresh : spec_withdraw, + spec_withdraw, NULL, NULL)) { GNUNET_break_op (0); return GNUNET_SYSERR; } - if (ph->was_refreshed != refreshed) - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } ph->cb (ph->cb_cls, &hr, - ph->was_refreshed ? NULL : &reserve_pub, - ph->was_refreshed ? &old_coin_pub : NULL); + &reserve_pub); return GNUNET_OK; } @@ -214,7 +196,7 @@ handle_recoup_finished (void *cls, ec = TALER_JSON_get_error_code (j); switch (ec) { - case TALER_EC_EXCHANGE_RECOUP_COIN_BALANCE_ZERO: + case TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS: if (0 > TALER_amount_cmp (&total, &dki->value)) { @@ -251,7 +233,6 @@ handle_recoup_finished (void *cls, } ph->cb (ph->cb_cls, &hr, - NULL, NULL); TALER_EXCHANGE_recoup_cancel (ph); return; @@ -294,7 +275,6 @@ handle_recoup_finished (void *cls, } ph->cb (ph->cb_cls, &hr, - NULL, NULL); TALER_EXCHANGE_recoup_cancel (ph); } @@ -306,7 +286,6 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, const struct TALER_DenominationSignature *denom_sig, const struct TALER_PlanchetSecretsP *ps, const struct TALER_Amount *amount, - bool was_refreshed, TALER_EXCHANGE_RecoupResultCallback recoup_cb, void *recoup_cb_cls) { @@ -340,9 +319,8 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, GNUNET_JSON_pack_data_auto ("coin_sig", &coin_sig), GNUNET_JSON_pack_data_auto ("coin_blind_key_secret", - &ps->blinding_key), - GNUNET_JSON_pack_bool ("refreshed", - was_refreshed)); + &ps->blinding_key)); + { char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; char *end; @@ -376,7 +354,6 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, GNUNET_free (ph); return NULL; } - ph->was_refreshed = was_refreshed; eh = TALER_EXCHANGE_curl_easy_get_ (ph->url); if ( (NULL == eh) || (GNUNET_OK != -- cgit v1.2.3