From 37cad4c26b8c37ce12843965fcc9334e998923ab Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 14 Apr 2022 18:59:31 +0200 Subject: -remove currency-based provider selection --- src/reducer/anastasis_api_redux.c | 77 ++++++++++++--------------------------- 1 file changed, 23 insertions(+), 54 deletions(-) (limited to 'src/reducer/anastasis_api_redux.c') diff --git a/src/reducer/anastasis_api_redux.c b/src/reducer/anastasis_api_redux.c index b9d18ab..5dde4c6 100644 --- a/src/reducer/anastasis_api_redux.c +++ b/src/reducer/anastasis_api_redux.c @@ -151,11 +151,6 @@ struct ConfigRequest */ char *business_name; - /** - * currency used by the anastasis backend. - */ - char *currency; - /** * Array of authorization methods supported by the server. */ @@ -366,7 +361,6 @@ free_config_request (struct ConfigRequest *cr) ANASTASIS_config_cancel (cr->co); if (NULL != cr->tt) GNUNET_SCHEDULER_cancel (cr->tt); - GNUNET_free (cr->currency); GNUNET_free (cr->url); GNUNET_free (cr->business_name); for (unsigned int i = 0; imethods_length; i++) @@ -533,8 +527,6 @@ notify_waiting (struct ConfigRequest *cr) &cr->truth_upload_fee), TALER_JSON_pack_amount ("liability_limit", &cr->liability_limit), - GNUNET_JSON_pack_string ("currency", - cr->currency), GNUNET_JSON_pack_string ("business_name", cr->business_name), GNUNET_JSON_pack_uint64 ("storage_limit_in_megabytes", @@ -598,8 +590,6 @@ config_cb (void *cls, else { cr->ec = TALER_EC_NONE; - GNUNET_free (cr->currency); - cr->currency = GNUNET_strdup (acfg->currency); GNUNET_free (cr->business_name); cr->business_name = GNUNET_strdup (acfg->business_name); for (unsigned int i = 0; imethods_length; i++) @@ -693,12 +683,12 @@ check_config (const char *url) /** * Begin asynchronous check for provider configurations. * - * @param currencies the currencies to initiate the provider checks for + * @param cc country code that was selected * @param[in,out] state to set provider list for * @return #TALER_EC_NONE on success */ static enum TALER_ErrorCode -begin_provider_config_check (const json_t *currencies, +begin_provider_config_check (const char *cc, json_t *state) { if (NULL == provider_list) @@ -746,12 +736,14 @@ begin_provider_config_check (const json_t *currencies, json_array_foreach (provider_arr, index, provider) { const char *url; - const char *cur; + const char *restricted = NULL; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("url", &url), - GNUNET_JSON_spec_string ("currency", - &cur), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("restricted", + &restricted), + NULL), GNUNET_JSON_spec_end () }; json_t *prov; @@ -765,27 +757,21 @@ begin_provider_config_check (const json_t *currencies, json_decref (pl); return TALER_EC_ANASTASIS_REDUCER_RESOURCE_MALFORMED; } - + if ( (NULL != restricted) && + (0 != strcmp (restricted, + cc)) ) { - bool found = false; - json_t *cu; - size_t off; - - json_array_foreach (currencies, off, cu) - { - const char *currency; - - currency = json_string_value (cu); - if (NULL == currency) - { - json_decref (pl); - return TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID; - } - found = (0 == strcasecmp (currency, - cur)); - } - if (! found) - continue; + /* skip */ + continue; + } + if ( (NULL == restricted) && + (0 == strcmp (cc, + "xx")) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Running in demo mode, skipping unrestricted providers\n"); + /* demo mode, skipping regular providers */ + continue; } prov = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("status", @@ -1023,7 +1009,6 @@ select_country (json_t *state, { const json_t *required_attrs; const json_t *country_code; - const json_t *currencies; const json_t *redux_id_attr; if (NULL == arguments) @@ -1073,23 +1058,11 @@ select_country (json_t *state, } } - currencies = json_object_get (arguments, - "currencies"); - if ( (NULL == currencies) || - (! json_is_array (currencies)) ) - { - ANASTASIS_redux_fail_ (cb, - cb_cls, - TALER_EC_ANASTASIS_REDUCER_STATE_INVALID, - "'currencies' missing"); - return NULL; - } - /* We now have an idea of the currency, begin fetching - provider /configs (we likely need them later) */ + /* Begin fetching provider /configs (we likely need them later) */ { enum TALER_ErrorCode ec; - ec = begin_provider_config_check (currencies, + ec = begin_provider_config_check (json_string_value (country_code), state); if (TALER_EC_NONE != ec) { @@ -1127,10 +1100,6 @@ select_country (json_t *state, json_object_set (state, "selected_country", (json_t *) country_code)); - GNUNET_assert (0 == - json_object_set (state, - "currencies", - (json_t *) currencies)); GNUNET_assert (0 == json_object_set (state, "required_attributes", -- cgit v1.2.3