Make re-encoding of homomorphic hash conditional.
This commit is contained in:
parent
4e49931c19
commit
2399abe0ee
1 changed files with 11 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3.9
|
||||||
|
|
||||||
"""
|
"""
|
||||||
When doing requests to NeoFS, we get JSON output as an automatically decoded
|
When doing requests to NeoFS, we get JSON output as an automatically decoded
|
||||||
|
@ -144,13 +144,15 @@ def decode_common_fields(data: dict):
|
||||||
header contains several common fields.
|
header contains several common fields.
|
||||||
This function rearranges these fields.
|
This function rearranges these fields.
|
||||||
"""
|
"""
|
||||||
# reencoding binary IDs
|
|
||||||
data["objectID"] = json_reencode(data["objectID"]["value"])
|
data["objectID"] = json_reencode(data["objectID"]["value"])
|
||||||
data["header"]["containerID"] = json_reencode(data["header"]["containerID"]["value"])
|
|
||||||
data["header"]["ownerID"] = json_reencode(data["header"]["ownerID"]["value"])
|
header = data["header"]
|
||||||
# data["header"]["homomorphicHash"] = json_reencode(data["header"]["homomorphicHash"]["sum"])
|
header["containerID"] = json_reencode(header["containerID"]["value"])
|
||||||
data["header"]["payloadHash"] = json_reencode(data["header"]["payloadHash"]["sum"])
|
header["ownerID"] = json_reencode(header["ownerID"]["value"])
|
||||||
data["header"]["version"] = (
|
header["payloadHash"] = json_reencode(header["payloadHash"]["sum"])
|
||||||
f"{data['header']['version']['major']}{data['header']['version']['minor']}"
|
header["version"] = f"{header['version']['major']}{header['version']['minor']}"
|
||||||
)
|
# Homomorphic hash is optional and its calculation might be disabled in trusted network
|
||||||
|
if "homomorphicHash" in header:
|
||||||
|
header["homomorphicHash"] = json_reencode(header["homomorphicHash"]["sum"])
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
Loading…
Reference in a new issue