summaryrefslogtreecommitdiff
path: root/src/reducer/anastasis_api_recovery_redux.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-30 13:55:51 +0100
committerChristian Grothoff <christian@grothoff.org>2022-01-30 13:55:51 +0100
commit697ea51cbbe8a32b8484630433c51a5c5ddb595a (patch)
tree343f89ed7f5ba24705d96fbe1deea12acf694711 /src/reducer/anastasis_api_recovery_redux.c
parentb7b7cf83d3c1098beeff09ca3f35e6082ed9bffb (diff)
downloadanastasis-697ea51cbbe8a32b8484630433c51a5c5ddb595a.tar.gz
anastasis-697ea51cbbe8a32b8484630433c51a5c5ddb595a.tar.bz2
anastasis-697ea51cbbe8a32b8484630433c51a5c5ddb595a.zip
-more work towards nicer policy discovery logic
Diffstat (limited to 'src/reducer/anastasis_api_recovery_redux.c')
-rw-r--r--src/reducer/anastasis_api_recovery_redux.c83
1 files changed, 80 insertions, 3 deletions
diff --git a/src/reducer/anastasis_api_recovery_redux.c b/src/reducer/anastasis_api_recovery_redux.c
index 5f087f3..2be963f 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -2076,9 +2076,9 @@ sync_providers (json_t *state,
return NULL;
}
if (GNUNET_OK ==
- ANASTASIS_reducer_lookup_salt_ (state,
- provider_url,
- &salt))
+ ANASTASIS_reducer_lookup_salt (state,
+ provider_url,
+ &salt))
continue; /* provider already ready */
se = GNUNET_new (struct SyncEntry);
se->ms = ms;
@@ -2108,6 +2108,78 @@ sync_providers (json_t *state,
/**
+ * Try to obtain configuration information on all configured
+ * providers. Upon success, call @a cb with the updated provider
+ * status data.
+ *
+ * @param[in] state we are in
+ * @param arguments our arguments with the solution
+ * @param cb functiont o call with the new state
+ * @param cb_cls closure for @a cb
+ * @return handle to cancel challenge selection step
+ */
+static struct ANASTASIS_ReduxAction *
+poll_providers (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
+{
+ json_t *ap;
+ const char *url;
+ json_t *obj;
+ struct MasterSync *ms;
+
+ ap = json_object_get (state,
+ "authentication_providers");
+ if (NULL == ap)
+ {
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'authentication_providers' missing");
+ return NULL;
+ }
+ ms = GNUNET_new (struct MasterSync);
+ ms->cb = cb;
+ ms->cb_cls = cb_cls;
+ json_object_foreach (ap, url, obj)
+ {
+ struct ANASTASIS_CRYPTO_ProviderSaltP salt;
+ struct SyncEntry *se;
+
+ if (GNUNET_OK ==
+ ANASTASIS_reducer_lookup_salt (state,
+ url,
+ &salt))
+ continue;
+ se = GNUNET_new (struct SyncEntry);
+ se->ms = ms;
+ GNUNET_CONTAINER_DLL_insert (ms->se_head,
+ ms->se_tail,
+ se);
+ se->ra = ANASTASIS_REDUX_add_provider_to_state_ (url,
+ state,
+ &sync_progress,
+ se);
+ }
+ if (NULL == ms->se_head)
+ {
+ /* everything already synced */
+ clean_sync (ms);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_ACTION_INVALID,
+ "already in sync");
+ return NULL;
+ }
+ ms->ra.cleanup = &clean_sync;
+ ms->ra.cleanup_cls = ms;
+ return &ms->ra;
+}
+
+
+/**
* The user pressed "back" during challenge solving.
* Transition back to selecting another challenge.
*
@@ -2594,6 +2666,11 @@ ANASTASIS_recovery_action_ (json_t *state,
},
{
ANASTASIS_RECOVERY_STATE_SECRET_SELECTING,
+ "poll_providers",
+ &poll_providers
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_SECRET_SELECTING,
"next",
&done_secret_selecting
},