summaryrefslogtreecommitdiff
path: root/src/json/json.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-07-16 14:30:14 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-16 14:35:47 +0200
commitc326a5bd9d74a599c967a2ad49536110d054a846 (patch)
treee87e823de9fbb856fdc7beba8791ee7b90a269d0 /src/json/json.c
parent5658c4c52b01a39d9302d3407cd53e96f545237c (diff)
downloadexchange-c326a5bd9d74a599c967a2ad49536110d054a846.tar.gz
exchange-c326a5bd9d74a599c967a2ad49536110d054a846.tar.bz2
exchange-c326a5bd9d74a599c967a2ad49536110d054a846.zip
implement forgettable contract terms core logic (#6365)
Diffstat (limited to 'src/json/json.c')
-rw-r--r--src/json/json.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/json/json.c b/src/json/json.c
index 4874f0c21..9ee1628e9 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -41,8 +41,11 @@ dump_and_hash (const json_t *json,
char *wire_enc;
size_t len;
+ GNUNET_break (NULL != json);
if (NULL == (wire_enc = json_dumps (json,
- JSON_COMPACT | JSON_SORT_KEYS)))
+ JSON_ENCODE_ANY
+ | JSON_COMPACT
+ | JSON_SORT_KEYS)))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -116,7 +119,7 @@ forget (const json_t *in)
}
return ret;
}
- if (! json_is_object (in))
+ if (json_is_object (in))
{
json_t *ret;
const char *key;
@@ -147,6 +150,23 @@ forget (const json_t *in)
continue; /* skip! */
if (rx == value)
continue; /* skip! */
+ if ( (NULL != rx) &&
+ (NULL !=
+ json_object_get (rx,
+ key)) )
+ {
+ if (0 !=
+ json_object_set_new (ret,
+ key,
+ json_null ()))
+ {
+ GNUNET_break (0);
+ json_decref (ret);
+ json_decref (rx);
+ return NULL;
+ }
+ continue; /* already forgotten earlier */
+ }
t = forget (value);
if (NULL == t)
{
@@ -208,7 +228,6 @@ forget (const json_t *in)
json_decref (rx);
return NULL;
}
-
}
else
{
@@ -225,10 +244,11 @@ forget (const json_t *in)
}
}
} /* json_object_foreach */
- if (0 !=
- json_object_set_new (ret,
- "_forgotten",
- rx))
+ if ( (NULL != rx) &&
+ (0 !=
+ json_object_set_new (ret,
+ "_forgotten",
+ rx)) )
{
GNUNET_break (0);
json_decref (ret);