summaryrefslogtreecommitdiff
path: root/src/reducer/anastasis_api_recovery_redux.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reducer/anastasis_api_recovery_redux.c')
-rw-r--r--src/reducer/anastasis_api_recovery_redux.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/reducer/anastasis_api_recovery_redux.c b/src/reducer/anastasis_api_recovery_redux.c
index 050a5b1..a26b6ad 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -2385,22 +2385,26 @@ core_early_secret_cb (void *cls,
* @param provider_url the provider to lookup config info from
* @param type the method to lookup the cost of
* @param[out] cost the recovery cost to return
+ * @param[out] ec set to the error code
* @return #GNUNET_OK on success, #GNUNET_NO if not found, #GNUNET_SYSERR on state error
*/
-static int
+static enum GNUNET_GenericReturnValue
lookup_cost (const json_t *state,
const char *provider_url,
const char *type,
- struct TALER_Amount *cost)
+ struct TALER_Amount *cost,
+ enum TALER_ErrorCode *ec)
{
const json_t *providers;
const json_t *provider;
const json_t *methods;
+ *ec = TALER_EC_NONE;
providers = json_object_get (state,
"authentication_providers");
if (NULL == providers)
{
+ *ec = TALER_EC_ANASTASIS_REDUCER_STATE_INVALID;
GNUNET_break (0);
return GNUNET_SYSERR;
}
@@ -2408,14 +2412,24 @@ lookup_cost (const json_t *state,
provider_url);
if (NULL == provider)
{
+ *ec = TALER_EC_ANASTASIS_REDUCER_STATE_INVALID;
GNUNET_break (0);
return GNUNET_SYSERR;
}
+ if (MHD_HTTP_OK !=
+ json_integer_value (json_object_get (provider,
+ "http_status")))
+ {
+ *ec = json_integer_value (json_object_get (provider,
+ "error_code"));
+ return GNUNET_SYSERR;
+ }
methods = json_object_get (provider,
"methods");
if ( (NULL == methods) ||
(! json_is_array (methods)) )
{
+ *ec = TALER_EC_ANASTASIS_REDUCER_STATE_INVALID;
GNUNET_break (0);
return GNUNET_SYSERR;
}
@@ -2439,6 +2453,7 @@ lookup_cost (const json_t *state,
NULL, NULL))
{
GNUNET_break (0);
+ *ec = TALER_EC_ANASTASIS_REDUCER_STATE_INVALID;
continue;
}
if (0 == strcmp (t,
@@ -2565,20 +2580,22 @@ policy_lookup_cb (void *cls,
const struct ANASTASIS_ChallengeDetails *cd;
json_t *cj;
struct TALER_Amount cost;
- int ret;
+ enum GNUNET_GenericReturnValue ret;
+ enum TALER_ErrorCode ec;
cd = ANASTASIS_challenge_get_details (c);
ret = lookup_cost (rss->state,
cd->provider_url,
cd->type,
- &cost);
+ &cost,
+ &ec);
if (GNUNET_SYSERR == ret)
{
json_decref (challenges);
json_decref (policies);
ANASTASIS_redux_fail_ (rss->cb,
rss->cb_cls,
- TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ ec,
"failed to 'lookup_cost'");
free_rss (rss);
return;