[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 04/05: worked on re-upload after payment
From: |
gnunet |
Subject: |
[taler-anastasis] 04/05: worked on re-upload after payment |
Date: |
Mon, 21 Dec 2020 11:42:12 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit e111fa6ea44bafa615fdf84b48efae027e9c8467
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Mon Dec 21 11:40:56 2020 +0100
worked on re-upload after payment
---
src/cli/test_anastasis_reducer_enter_secret.sh | 4 ++--
src/include/anastasis.h | 13 ++++++++++
src/lib/anastasis.c | 33 +++++++++++++++++++++++++-
src/lib/anastasis_api_backup_redux.c | 24 +++++++------------
4 files changed, 55 insertions(+), 19 deletions(-)
diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh
b/src/cli/test_anastasis_reducer_enter_secret.sh
index 7f50c25..88b5c98 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -280,7 +280,7 @@ echo " "
echo -e $COLOR$BOLD"Test enter secret in a backup state"$NORM$NOCOLOR
mkdir -p resources
touch $TFILE
-./anastasis-reducer -a \
+valgrind .libs/anastasis-reducer -a \
'{"secret": "veryhardtoguesssecret",
"type": "password"}' \
enter_secret $SFILE $TFILE
@@ -341,7 +341,7 @@ echo " "
echo " "
echo -e $COLOR$BOLD"Try to upload again"$NORM$NOCOLOR
touch $UFILE
-./anastasis-reducer -a \
+valgrind .libs/anastasis-reducer -a \
'{}' \
pay $TFILE $UFILE
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index f65d52b..028f9fd 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -376,6 +376,19 @@ ANASTASIS_truth_upload_cancel (struct
ANASTASIS_TruthUpload *tu);
void
ANASTASIS_truth_free (struct ANASTASIS_Truth *t);
+/**
+* Converts a truth object from string format.
+* @param t object to return size of
+*/
+struct ANASTASIS_Truth *
+ANASTASIS_truth_from_string (const char*t_str);
+
+/**
+* Returns the string format of a truth object.
+* @param t object to return string of
+*/
+char *
+ANASTASIS_truth_to_string (struct ANASTASIS_Truth *t);
/**
* Policy object to upload
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 2cb7703..2458aa1 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -1320,6 +1320,36 @@ ANASTASIS_truth_free (struct ANASTASIS_Truth *t)
}
+/**
+* Returns the size of a truth object.
+* @param t object to return size of
+*/
+char *
+ANASTASIS_truth_to_string (struct ANASTASIS_Truth *t)
+{
+ return GNUNET_STRINGS_data_to_string_alloc (t,
+ sizeof (*t));
+}
+
+
+/**
+* Converts a truth object from string format.
+* @param t object to return size of
+*/
+struct ANASTASIS_Truth *
+ANASTASIS_truth_from_string (const char*t_str)
+{
+ struct ANASTASIS_Truth *t = GNUNET_new (struct ANASTASIS_Truth);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_STRINGS_string_to_data (
+ t_str,
+ strlen (t_str),
+ t,
+ sizeof (struct ANASTASIS_Truth)));
+ return t;
+}
+
+
/**
* Policy object to upload
*/
@@ -1794,7 +1824,6 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy
*policies[],
* strlen (
policies[l]->truths[j]->
url) + 1);
- // provider[unique_urls_len] = policies[l]->truths[j]->url;
strcpy (provider[unique_urls_len], policies[l]->truths[j]->url);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d unique provider url is %s\n", __FILE__,
@@ -1834,6 +1863,8 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
size_t core_secret_size)
{
struct ANASTASIS_SecretShare *ss;
+
+ GNUNET_assert (policies_len > 0);
unsigned int pss_length = ANASTASIS_get_num_urls (policies,
policies_len);
struct PolicyStoreState *pss[pss_length];
diff --git a/src/lib/anastasis_api_backup_redux.c
b/src/lib/anastasis_api_backup_redux.c
index ea0a363..a3e1bd9 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -1299,6 +1299,7 @@ initialize_policies (json_t *state)
json_t *rec_doc_uploads = json_array ();
GNUNET_assert (json_is_array (rec_doc_uploads));
+
json_array_foreach (json_policies, p_index, json_policy)
{
size_t index;
@@ -1327,17 +1328,10 @@ initialize_policies (json_t *state)
json_object_get (json_truth, "auth_method_index"))
== auth_method_index)
{
- struct TruthUploadState *tus = GNUNET_new (struct TruthUploadState);
- const char *tus_str = json_string_value (
+ const char *t_str = json_string_value (
json_object_get (tu,
- "tus_string"));
- GNUNET_assert (GNUNET_OK ==
- GNUNET_STRINGS_string_to_data (
- tus_str,
- strlen (tus_str),
- tus,
- sizeof (struct TruthUploadState)));
- truths[truth_index] = tus->truth;
+ "truth_string"));
+ truths[truth_index] = ANASTASIS_truth_from_string (t_str);
truth_index++;
break;
}
@@ -1715,14 +1709,12 @@ truth_upload_cb (void *cls,
"status",
json_integer ((json_int_t) 204)));
tus->truth = t;
- char *tus_string =
- GNUNET_STRINGS_data_to_string_alloc (tus,
- sizeof (struct TruthUploadState));
+ char *truth_string = ANASTASIS_truth_to_string (tus->truth);
GNUNET_assert (0 ==
json_object_set (truth_upload,
- "tus_string",
- json_string (tus_string)));
- GNUNET_free (tus_string);
+ "truth_string",
+ json_string (truth_string)));
+ GNUNET_free (truth_string);
if (check_uploads (truth_uploads, true) &&
(json_array_size (
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.