[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: work on backup redux
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: work on backup redux |
Date: |
Thu, 18 Feb 2021 22:44:40 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new d7161e1 work on backup redux
d7161e1 is described below
commit d7161e1bae964b52493b83d0f71648238b3f77d9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Feb 18 22:44:38 2021 +0100
work on backup redux
---
src/include/anastasis_crypto_lib.h | 8 +-
src/lib/anastasis_backup.c | 33 ++
src/reducer/anastasis_api_backup_redux.c | 729 +++++++++++++++++++++++++------
src/reducer/anastasis_api_redux.h | 2 +-
4 files changed, 630 insertions(+), 142 deletions(-)
diff --git a/src/include/anastasis_crypto_lib.h
b/src/include/anastasis_crypto_lib.h
index 4b2c146..539bab7 100644
--- a/src/include/anastasis_crypto_lib.h
+++ b/src/include/anastasis_crypto_lib.h
@@ -272,7 +272,7 @@ GNUNET_NETWORK_STRUCT_END
* other numbers submitted for challenges.
*
* @param code the numeric value to hash
- * @param hashed_code the resulting hash value to submit to the Anastasis
server
+ * @param[out] hashed_code the resulting hash value to submit to the Anastasis
server
*/
void
ANASTASIS_hash_answer (uint64_t code,
@@ -280,8 +280,10 @@ ANASTASIS_hash_answer (uint64_t code,
/**
- * Creates the UserIdentifier, it is used as entropy source for the encryption
keys and
- * for the public and private key for signing the data.
+ * Creates the UserIdentifier, it is used as entropy source for the
+ * encryption keys and for the public and private key for signing the
+ * data.
+ *
* @param id_data JSON encoded data, which contains the raw user secret
* @param server_salt salt from the server (escrow provider)
* @param[out] id reference to the id which was created
diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index 9cde710..d22e938 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -70,6 +70,39 @@ struct ANASTASIS_Truth
};
+/**
+ * Extracts truth data from JSON.
+ *
+ * @param json JSON encoding to decode; truth returned ONLY valid as long
+ * as the JSON remains valid (do not decref until the truth
+ * is truly finished)
+ * @return decoded truth object, NULL on error
+ */
+struct ANASTASIS_Truth *
+ANASTASIS_truth_from_json (const json_t *json)
+{
+ GNUNET_break (0); // FIXME: implement!
+ return NULL;
+}
+
+
+/**
+ * Returns JSON-encoded truth data.
+ * Creates a policy with a set of truth's. Creates the policy key
+ * with the different key shares from the @a truths. The policy key
+ * will then be used to encrypt/decrypt the escrow master key.
+ *
+ * @param t object to return JSON encoding for
+ * @return JSON encoding of @a t
+ */
+json_t *
+ANASTASIS_truth_to_json (const struct ANASTASIS_Truth *t)
+{
+ GNUNET_break (0); // FIXME: implement!
+ return NULL;
+}
+
+
struct ANASTASIS_TruthUpload
{
diff --git a/src/reducer/anastasis_api_backup_redux.c
b/src/reducer/anastasis_api_backup_redux.c
index 713b153..a0edab0 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -220,33 +220,6 @@ struct SecretShareState
};
-// FIXME: all of these globals must die!
-/**
- * Generic container for an action with asynchronous activities.
- */
-static struct ANASTASIS_ReduxAction *ra;
-
-/**
- * Array of truth upload states.
- */
-static struct TruthUploadState **tus_arr;
-
-/**
- * The length of the #tus_arr array.
- */
-static unsigned int tus_arr_length;
-
-/**
- * Array of policies.
- */
-const static struct ANASTASIS_Policy **policy_arr;
-
-/**
- * The length of the #tus_arr array.
- */
-static unsigned int policy_arr_length = 0;
-
-
/**
* Callback function FIXME: Description.
*
@@ -402,7 +375,6 @@ add_authentication (json_t *state,
auth_providers = json_object_get (state,
"authentication_providers");
-
if (NULL == auth_providers)
{
ANASTASIS_redux_fail_ (cb,
@@ -433,12 +405,12 @@ add_authentication (json_t *state,
return NULL;
}
if (! json_object_get (method,
- "data"))
+ "challenge"))
{
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
- "'data' field missing for authorization method");
+ "'challenge' field missing for authorization
method");
return NULL;
}
/* Check we know at least one provider that supports this method */
@@ -1225,7 +1197,6 @@ add_policy (json_t *state,
{
struct TALER_Amount method_cost;
const char *name;
-
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("name",
&name),
@@ -1370,6 +1341,34 @@ del_policy (json_t *state,
}
+/* ********************** done_policy_review ***************** */
+
+
+/**
+ * DispatchHandler/Callback function which is called for a
+ * "done_policy_review" action.
+ *
+ * @param state state to operate on
+ * @param arguments arguments to use for operation on state
+ * @param cb callback (#DispatchHandler) to call during/after operation
+ * @param cb_cls callback closure
+ * @return NULL
+ */
+static struct ANASTASIS_ReduxAction *
+done_policy_review (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
+{
+ set_state (state,
+ ANASTASIS_BACKUP_STATE_SECRET_EDITING);
+ cb (cb_cls,
+ TALER_EC_NONE,
+ state);
+ return NULL;
+}
+
+
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
@@ -1377,6 +1376,35 @@ del_policy (json_t *state,
///////////////////////////////////////////////////////////
+#if GRAVEYARD
+
+// FIXME: all of these globals must die!
+/**
+ * Generic container for an action with asynchronous activities.
+ */
+static struct ANASTASIS_ReduxAction *ra;
+
+/**
+ * Array of truth upload states.
+ */
+static struct TruthUploadState **tus_arr;
+
+/**
+ * The length of the #tus_arr array.
+ */
+static unsigned int tus_arr_length;
+
+/**
+ * Array of policies.
+ */
+const static struct ANASTASIS_Policy **policy_arr;
+
+/**
+ * The length of the #tus_arr array.
+ */
+static unsigned int policy_arr_length = 0;
+
+
/**
* Initialize data for #ANASTASIS_truth_upload.
*
@@ -1527,35 +1555,6 @@ initialize_truths (json_t *state)
}
-/**
- * DispatchHandler/Callback function which is called for a
- * "done_policy_review" action.
- *
- * @param state state to operate on
- * @param arguments arguments to use for operation on state
- * @param cb callback (#DispatchHandler) to call during/after operation
- * @param cb_cls callback closure
- * @return NULL
- */
-static struct ANASTASIS_ReduxAction *
-done_policy_review (json_t *state,
- const json_t *arguments,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
-{
- set_state (state,
- ANASTASIS_BACKUP_STATE_SECRET_EDITING);
- GNUNET_assert (0 ==
- json_object_set (state,
- "truths",
- initialize_truths (state)));
- cb (cb_cls,
- TALER_EC_NONE,
- state);
- return NULL;
-}
-
-
/**
* Check if all uploads have response code 204 or 402.
*
@@ -2178,18 +2177,17 @@ truth_upload_cb (void *cls,
/**
- * Function to upload truths.
+ * Function to upload truths and recovery document policies.
*
* @param state state to operate on
* @param truth_indices indices of truths to upload explicitly
* @param cb callback (#ANASTASIS_ActionCallback) to call after upload
* @param cb_cls callback closure
*/
-static void
-upload_truths (json_t *state,
- json_t *truth_indices,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
+static struct ANASTASIS_ReduxAction *
+upload (json_t *state,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
{
size_t truth_index;
size_t truth_indices_size;
@@ -2362,16 +2360,491 @@ upload_truths (json_t *state,
}
+#endif
+// GRAVEYARD
+
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+
+
+/**
+ * Information we keep for an upload() operation.
+ */
+struct UploadContext;
+
+
+/**
+ * Entry we keep per truth upload.
+ */
+struct TruthUpload
+{
+ /**
+ * Handle to the actual upload operation.
+ */
+ struct ANASTASIS_TruthUpload *tu;
+
+ /**
+ * Upload context this operation is part of.
+ */
+ struct UploadContext *uc;
+
+ /**
+ * Truth resulting from the upload, if any.
+ */
+ struct ANASTASIS_Truth *t;
+
+ /**
+ * A taler://pay/-URI with a request to pay the annual fee for
+ * the service. Set if payment is required.
+ */
+ char *payment_request;
+
+ /**
+ * The payment secret (aka order ID) extracted from the @e payment_request.
+ * Set if @e payment_request is non-NULL.
+ */
+ struct ANASTASIS_PaymentSecretP ps;
+
+ /**
+ * Taler error code of the upload.
+ */
+ enum TALER_ErrorCode ec;
+
+};
+
+
+/**
+ * Information we keep for an upload() operation.
+ */
+struct UploadContext
+{
+ /**
+ * Recovery action returned to caller for aborting the operation.
+ */
+ struct ANASTASIS_ReduxAction ra;
+
+ /**
+ * Function to call upon completion.
+ */
+ ANASTASIS_ActionCallback cb;
+
+ /**
+ * Closure for @e cb.
+ */
+ void *cb_cls;
+
+ /**
+ * Our state.
+ */
+ json_t *state;
+
+ /**
+ * Master secret sharing operation, NULL if not yet running.
+ */
+ struct ANASTASIS_SecretShare *ss;
+
+ /**
+ * Array of truth uploads of length @e tues_length. Some entries may be NULL.
+ */
+ struct TruthUpload *tues;
+
+ /**
+ * Length of the @e truth_uploads array.
+ */
+ unsigned int tues_length;
+
+};
+
+
+/**
+ * Function called when the #upload transition is being aborted.
+ *
+ * @param cls a `struct UploadContext`
+ */
+static void
+upload_cancel_cb (void *cls)
+{
+ struct UploadContext *uc = cls;
+
+ for (unsigned int i = 0; i<uc->tues_length; i++)
+ {
+ struct TruthUpload *tue = &uc->tues[i];
+
+ if (NULL != tue->tu)
+ {
+ ANASTASIS_truth_upload_cancel (tue->tu);
+ tue->tu = NULL;
+ }
+ if (NULL != tue->t)
+ {
+ ANASTASIS_truth_free (tue->t);
+ tue->t = NULL;
+ }
+ GNUNET_free (tue->payment_request);
+ }
+ GNUNET_free (uc->tues);
+ if (NULL != uc->ss)
+ {
+ ANASTASIS_secret_share_cancel (uc->ss);
+ uc->ss = NULL;
+ }
+ GNUNET_free (uc);
+}
+
+
+/**
+ * All truth uploads are done, begin with uploading the policy.
+ *
+ * @param[in,out] uc context for the operation
+ */
+static void
+share_secret (struct UploadContext *uc)
+{
+ GNUNET_break (0); // FIXME: not implemented
+ uc->cb (uc->cb_cls,
+ TALER_EC_INVALID,
+ NULL);
+ upload_cancel_cb (uc);
+}
+
+
+/**
+ * Some truth uploads require payment, serialize state and
+ * request payment to be executed by the application.
+ *
+ * @param[in,out] uc context for the operation
+ */
+static void
+request_truth_payment (struct UploadContext *uc)
+{
+ json_t *payments;
+ json_t *auth_methods;
+
+ auth_methods = json_object_get (uc->state,
+ "authentication_methods");
+ GNUNET_assert (json_is_array (auth_methods));
+ payments = json_array ();
+ GNUNET_assert (NULL != payments);
+ for (unsigned int i = 0; i<uc->tues_length; i++)
+ {
+ struct TruthUpload *tue = &uc->tues[i];
+
+ if (NULL != tue->payment_request)
+ {
+ GNUNET_assert (
+ 0 ==
+ json_array_append_new (payments,
+ json_string (
+ tue->payment_request)));
+ }
+ if (NULL != tue->t)
+ {
+ json_t *auth_method = json_array_get (auth_methods,
+ i);
+ json_t *truth = ANASTASIS_truth_to_json (tue->t);
+
+ GNUNET_assert (NULL != auth_method);
+ GNUNET_assert (NULL != truth);
+ GNUNET_assert (0 ==
+ json_object_set_new (auth_method,
+ "truth",
+ truth));
+ }
+ }
+ GNUNET_assert (0 ==
+ json_object_set_new (uc->state,
+ "payments",
+ payments));
+ set_state (uc->state,
+ ANASTASIS_BACKUP_STATE_TRUTHS_PAYING);
+ uc->cb (uc->cb_cls,
+ TALER_EC_NONE,
+ uc->state);
+ upload_cancel_cb (uc);
+}
+
+
+/**
+ * We may be finished with all (active) asynchronous operations.
+ * Check if any are pending and continue accordingly.
+ *
+ * @param[in,out] uc context for the operation
+ */
+static void
+check_upload_finished (struct UploadContext *uc)
+{
+ bool pay = false;
+ enum TALER_ErrorCode failed = TALER_EC_NONE;
+ bool active = false;
+
+ for (unsigned int i = 0; i<uc->tues_length; i++)
+ {
+ struct TruthUpload *tue = &uc->tues[i];
+
+ if (TALER_EC_NONE != tue->ec)
+ {
+ uc->cb (uc->cb_cls,
+ failed,
+ uc->state);
+ upload_cancel_cb (uc);
+ return;
+ }
+ if (NULL != tue->tu)
+ active = true;
+ if (NULL != tue->payment_request)
+ pay = true;
+ }
+ if (active)
+ return;
+ if (pay)
+ {
+ request_truth_payment (uc);
+ return;
+ }
+ share_secret (uc);
+}
+
+
+/**
+ * Lookup @a salt of @a provider_url in @a state.
+ *
+ * @param state the state to inspect
+ * @param provider_url provider to look into
+ * @param[out] salt value to extract
+ * @return #GNUNET_OK on success
+ */
+static int
+lookup_salt (const json_t *state,
+ const char *provider_url,
+ struct ANASTASIS_CRYPTO_PowSalt *salt)
+{
+ GNUNET_break (0); // FIXME: not implemented
+ return GNUNET_SYSERR;
+}
+
+
+/**
+ * Upload result information. The resulting truth object can be used
+ * to create policies. If payment is required, the @a taler_pay_url
+ * is returned and the operation must be retried after payment.
+ * Callee MUST free @a t using ANASTASIS_truth_free().
+ *
+ * @param cls closure with a `struct TruthUpload`
+ * @param ec status code of the request (success, failure, payment required)
+ * @param t truth object to create policies, NULL on failure
+ * @param ud upload details, useful to continue in case of errors, NULL on
success
+ */
+static void
+truth_upload_cb (void *cls,
+ enum TALER_ErrorCode ec,
+ struct ANASTASIS_Truth *t,
+ const struct ANASTASIS_UploadDetails *ud)
+{
+ struct TruthUpload *tue = cls;
+
+ tue->tu = NULL;
+ tue->t = t;
+ tue->ec = ud->ec;
+ if (ANASTASIS_US_PAYMENT_REQUIRED == ud->us)
+ {
+ tue->payment_request = GNUNET_strdup (ud->details.payment.payment_request);
+ tue->ps = ud->details.payment.ps;
+ }
+ check_upload_finished (tue->uc);
+}
+
+
+/**
+ * Function to upload truths and recovery document policies.
+ * Ultimately transitions to failed state (allowing user to go back
+ * and change providers/policies), or payment, or finished.
+ *
+ * @param state state to operate on
+ * @param truth_indices indices of truths to upload explicitly
+ * @param cb callback (#ANASTASIS_ActionCallback) to call after upload
+ * @param cb_cls callback closure
+ */
+static struct ANASTASIS_ReduxAction *
+upload (json_t *state,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
+{
+ struct UploadContext *uc;
+ json_t *auth_methods;
+ json_t *user_id;
+
+ auth_methods = json_object_get (state,
+ "authentication_methods");
+ if ( (! json_is_array (auth_methods)) ||
+ (0 == json_array_size (auth_methods)) )
+ {
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'authentication_methods' must be an array");
+ return NULL;
+ }
+ user_id = json_object_get (state,
+ "identity_attributes");
+ if (! json_is_object (user_id))
+ {
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'identity_attributes' must be an object");
+ return NULL;
+ }
+
+ uc = GNUNET_new (struct UploadContext);
+ uc->ra.cleanup = &upload_cancel_cb;
+ uc->ra.cleanup_cls = uc;
+ uc->cb = cb;
+ uc->cb_cls = cb_cls;
+ uc->state = json_incref (state);
+ uc->tues_length = json_array_size (auth_methods);
+ uc->tues = GNUNET_new_array (uc->tues_length,
+ struct TruthUpload);
+ {
+ json_t *auth_method;
+ size_t index;
+ bool async_truth = false;
+
+ json_array_foreach (auth_methods, index, auth_method)
+ {
+ struct TruthUpload *tue = &uc->tues[index];
+ const char *method;
+ const char *provider_url;
+ const char *payment_request = NULL;
+ const char *mime_type = NULL;
+ const char *instructions = NULL;
+ void *truth_data;
+ size_t truth_data_size;
+ json_t *truth = NULL;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("method",
+ &method),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("mime_type",
+ &mime_type)),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("instructions",
+ &instructions)),
+ GNUNET_JSON_spec_string ("provider_url",
+ &provider_url), // FIXME: spec suggests this
is with policy, not auth_method! => check computation above, ensure provider
URL is fixed per truth? OR stay with current spec and allow same truth to be
used with multiple providers!?
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("payment_request",
+ &payment_request)),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_fixed_auto ("payment_secret",
+ &tue->ps)),
+ GNUNET_JSON_spec_varsize ("challenge",
+ &truth_data,
+ &truth_data_size),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_json ("truth",
+ &truth)),
+ GNUNET_JSON_spec_end ()
+ };
+ struct ANASTASIS_CRYPTO_PowSalt salt;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (auth_method,
+ spec,
+ NULL, NULL))
+ {
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'authentication_method' data malformed");
+ return NULL;
+ }
+ if (NULL == truth)
+ {
+ struct ANASTASIS_CRYPTO_UserIdentifierP id;
+
+ if (GNUNET_OK !=
+ lookup_salt (state,
+ provider_url,
+ &salt))
+ {
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "provider salt required");
+ GNUNET_JSON_parse_free (spec);
+ upload_cancel_cb (uc);
+ return NULL;
+ }
+ ANASTASIS_CRYPTO_user_identifier_derive (user_id,
+ &salt,
+ &id);
+ tue->tu = ANASTASIS_truth_upload (ANASTASIS_REDUX_ctx_,
+ &id,
+ provider_url,
+ method,
+ instructions,
+ mime_type,
+ &salt,
+ truth_data,
+ truth_data_size,
+ false, /* FIXME: support forced
payments */
+ (NULL != payment_request)
+ ? &tue->ps
+ : NULL,
+ &truth_upload_cb,
+ tue);
+ if (NULL == tue->tu)
+ {
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_INVALID, // FIXME: needs new EC!
+ "failure attempting truth upload");
+ GNUNET_JSON_parse_free (spec);
+ upload_cancel_cb (uc);
+ return NULL;
+ }
+ async_truth = true;
+ }
+ else
+ {
+ tue->t = ANASTASIS_truth_from_json (truth);
+ if (NULL == tue->t)
+ {
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'truth' malformed");
+ GNUNET_JSON_parse_free (spec);
+ upload_cancel_cb (uc);
+ return NULL;
+ }
+ }
+ GNUNET_JSON_parse_free (spec);
+ }
+ if (async_truth)
+ return &uc->ra;
+ }
+ share_secret (uc);
+ if (NULL == uc->ss)
+ return NULL;
+ return &uc->ra;
+}
+
+
/**
* DispatchHandler/Callback function which is called for a
* "enter_secret" action.
- * Returns an #ANASTASIS_ReduxAction if operation is async.
+ * Returns an #ANASTASIS_ReduxAction as operation is async.
*
* @param state state to operate on
* @param arguments arguments to use for operation on state
* @param cb callback (#DispatchHandler) to call during/after operation
* @param cb_cls callback closure
- * @return NULL
*/
static struct ANASTASIS_ReduxAction *
enter_secret (json_t *state,
@@ -2379,8 +2852,15 @@ enter_secret (json_t *state,
ANASTASIS_ActionCallback cb,
void *cb_cls)
{
- if (NULL != ra)
- GNUNET_free (ra);
+ const char *secret;
+ const char *type;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("secret",
+ &secret),
+ GNUNET_JSON_spec_string ("type",
+ &type),
+ GNUNET_JSON_spec_end ()
+ };
if (NULL == arguments)
{
@@ -2390,101 +2870,69 @@ enter_secret (json_t *state,
"arguments missing");
return NULL;
}
- GNUNET_assert (NULL != state);
-
- if ((NULL == json_object_get (arguments,"secret"))
- || (NULL == json_object_get (arguments, "type")))
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (arguments,
+ spec,
+ NULL, NULL))
{
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
- "'secret' malformed");
+ "'secret' and 'type' arguments required");
return NULL;
}
GNUNET_assert (0 ==
json_object_set (state,
"core_secret",
- json_deep_copy (arguments)));
- GNUNET_assert (0 ==
- json_object_set_new (state,
- "truth_uploads",
- json_object ()));
- upload_truths (state,
- json_object_get (state,
- "truths"),
+ json_incref ((json_t *) arguments)));
+ return upload (state,
cb,
cb_cls);
- return ra;
}
/**
* DispatchHandler/Callback function which is called for a
* "pay" action.
- * Returns an #ANASTASIS_ReduxAction if operation is async.
+ * Returns an #ANASTASIS_ReduxAction as operation is async.
*
* @param state state to operate on
* @param arguments arguments to use for operation on state
* @param cb callback (#DispatchHandler) to call during/after operation
* @param cb_cls callback closure
- * @return NULL
*/
static struct ANASTASIS_ReduxAction *
-pay_backup (json_t *state,
- const json_t *arguments,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
+pay_truths_backup (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
{
- if (NULL != ra)
- GNUNET_free (ra);
-
- if (NULL != json_object_get (arguments,
- "provider_id"))
- {
- upload_rec_documents (state,
- json_object_get (arguments,
- "provider_id"),
- cb,
- cb_cls);
- }
- else if (NULL != json_object_get (arguments,
- "truth_index"))
- {
- upload_truths (state,
- json_object_get (arguments,
- "truth_index"),
- cb,
- cb_cls);
- }
- else
- {
- // try uploading all truths (if not paid) and policies again
- json_t *truth_uploads = json_object_get (state,
- "truth_uploads");
-
- GNUNET_assert (json_is_object (truth_uploads));
- if (check_uploads (truth_uploads, true))
- upload_rec_documents (state,
- NULL,
- cb,
- cb_cls);
- else
- upload_truths (state,
- NULL,
- cb,
- cb_cls);
- }
- return ra;
+ return upload (state,
+ cb,
+ cb_cls);
}
-///////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////
+/**
+ * DispatchHandler/Callback function which is called for a
+ * "pay" action.
+ * Returns an #ANASTASIS_ReduxAction as operation is async.
+ *
+ * @param state state to operate on
+ * @param arguments arguments to use for operation on state
+ * @param cb callback (#DispatchHandler) to call during/after operation
+ * @param cb_cls callback closure
+ */
+static struct ANASTASIS_ReduxAction *
+pay_policies_backup (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
+{
+ return upload (state,
+ cb,
+ cb_cls);
+}
/**
@@ -2592,10 +3040,15 @@ ANASTASIS_backup_action_ (json_t *state,
"back",
&ANASTASIS_back_generic_decrement_
},
+ {
+ ANASTASIS_BACKUP_STATE_TRUTHS_PAYING,
+ "pay",
+ &pay_truths_backup
+ },
{
ANASTASIS_BACKUP_STATE_POLICIES_PAYING,
"pay",
- &pay_backup
+ &pay_policies_backup
},
{
ANASTASIS_BACKUP_STATE_BACKUP_FINISHED,
diff --git a/src/reducer/anastasis_api_redux.h
b/src/reducer/anastasis_api_redux.h
index c914e8f..5487eb6 100644
--- a/src/reducer/anastasis_api_redux.h
+++ b/src/reducer/anastasis_api_redux.h
@@ -20,7 +20,6 @@
* @author Dominik Meister
* @author Dennis Neufeld
*/
-
#ifndef ANASTASIS_API_REDUX_H
#define ANASTASIS_API_REDUX_H
@@ -45,6 +44,7 @@ enum ANASTASIS_GenericState
REDUX_STATE (AUTHENTICATIONS_EDITING) \
REDUX_STATE (POLICIES_REVIEWING) \
REDUX_STATE (SECRET_EDITING) \
+ REDUX_STATE (TRUTHS_PAYING) \
REDUX_STATE (POLICIES_PAYING) \
REDUX_STATE (BACKUP_FINISHED)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: work on backup redux,
gnunet <=