[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 04/07: work on backup redux
From: |
gnunet |
Subject: |
[taler-anastasis] 04/07: work on backup redux |
Date: |
Sat, 12 Sep 2020 11:01:51 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit 74ca69cf00170de2ac1fb41da00c3610fa2ada9d
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Fri Sep 11 18:19:56 2020 +0200
work on backup redux
---
src/lib/anastasis_api_backup_redux.c | 87 +++++++++++++++++++++++-------------
1 file changed, 56 insertions(+), 31 deletions(-)
diff --git a/src/lib/anastasis_api_backup_redux.c
b/src/lib/anastasis_api_backup_redux.c
index 533b199..b310b25 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -59,36 +59,34 @@ json_t *
ANASTASIS_backup_start (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
json_t *initial_state;
- const char *temp_key;
- json_t *temp_value;
+ json_t *temp_country;
+ size_t index;
json_t *root = json_object_get (redux_countries, "countries");
json_t *continents = json_array ();
- json_object_foreach (root, temp_key, temp_value)
+ json_array_foreach (root, index, temp_country)
{
- size_t index;
- json_t *inner_temp_value;
- bool contains = false;
-
- if (temp_key == "continent")
- json_array_foreach (continents,
- index,
- inner_temp_value)
+ size_t inner_index;
+ json_t *inner_continent;
+ json_t *continent = json_object_get (json_array_get (root, index),
+ "continent");
+
+ bool existing = false;
+ json_array_foreach (continents, inner_index, inner_continent)
+ {
+ if (1 == json_equal (continent, inner_continent))
{
- if (inner_temp_value == temp_value)
- {
- contains = true;
- break;
- }
+ existing = true;
+ break;
}
-
- if (contains)
- json_array_append_new (continents, temp_value);
+ }
+ if (! existing)
+ json_array_append_new (continents, continent);
}
- initial_state = json_object_pack ("{s:s, s:o}",
- "backup-state", "ReduxInitialBackupState",
- "continents", continents);
+ initial_state = json_pack ("{s:s, s:o}",
+ "backup-state", "ReduxInitialBackupState",
+ "continents", continents);
return initial_state;
}
@@ -100,15 +98,20 @@ select_continent (const json_t *state,
void *cb_cls)
{
json_t *new_state;
- const char *continent = json_string_value (json_object_get (arguments,
- "continent"));
- if (NULL == s)
+ size_t index;
+ json_t *country;
+ json_t *continent = json_object_get (arguments, "continent");
+ json_t *root = json_object_get (redux_countries, "countries");
+ json_t *countries = json_array ();
+
+ if (NULL == state)
{
GNUNET_break (0);
cb (cb_cls,
- error);
+ ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+ NULL);
}
- if (continent - not - in - array)
+ if (NULL == continent)
{
GNUNET_break (0);
cb (cb_cls,
@@ -116,14 +119,34 @@ select_continent (const json_t *state,
NULL);
}
new_state = json_deep_copy (state);
- // FIXME: get list of countries for 'continent'
+
+ json_array_foreach (root, index, country)
+ {
+ size_t inner_index;
+ json_t *inner_country;
+ json_t *temp_continent = json_object_get (json_array_get (root, index),
+ "continent");
+
+ bool existing = false;
+ json_array_foreach (countries, inner_index, inner_country)
+ {
+ if (1 == json_equal (continent, temp_continent))
+ {
+ existing = true;
+ break;
+ }
+ }
+ if (! existing)
+ json_array_append_new (countries, country);
+ }
+
json_object_set_new (new_state,
"countries",
countries);
// optional:
json_object_set_new (new_state,
"continent",
- json_string (continent));
+ continent);
cb (cb_cls,
ANASTASIS_EC_NONE,
new_state);
@@ -170,7 +193,8 @@ ANASTASIS_backup_action (const json_t *state,
{
GNUNET_break (0);
cb (cb_cls,
- error);
+ ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+ NULL);
}
for (unsigned int i = 0; NULL != dispatchers[i].fun; i++)
{
@@ -183,6 +207,7 @@ ANASTASIS_backup_action (const json_t *state,
}
GNUNET_break (0);
cb (cb_cls,
- error);
+ ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+ NULL);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-anastasis] branch master updated (3e1fd2b -> a7d37bf), gnunet, 2020/09/12
- [taler-anastasis] 01/07: work on reducer, gnunet, 2020/09/12
- [taler-anastasis] 02/07: options for reducer cli, gnunet, 2020/09/12
- [taler-anastasis] 04/07: work on backup redux,
gnunet <=
- [taler-anastasis] 03/07: work on reducer cli, gnunet, 2020/09/12
- [taler-anastasis] 06/07: fixed anastasis-reducer to return init state, gnunet, 2020/09/12
- [taler-anastasis] 05/07: work on backup redux, gnunet, 2020/09/12
- [taler-anastasis] 07/07: merge, gnunet, 2020/09/12