From 0d90b82287356388309fed223d39245d4a65df67 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 22 Jan 2019 20:55:35 -0300 Subject: [PATCH] clear releaseTime when not set --- lbrynet/schema/encoding.py | 4 ++++ lbrynet/schema/schema/metadata.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lbrynet/schema/encoding.py b/lbrynet/schema/encoding.py index 33c3eb30d..c1d12660a 100644 --- a/lbrynet/schema/encoding.py +++ b/lbrynet/schema/encoding.py @@ -14,6 +14,10 @@ def encode_fields(claim_dictionary, detached_signature: Signature): claim_value = claim_dictionary[claim_type] if claim_type == CLAIM_TYPES[STREAM_TYPE]: claim_value['source']['source'] = binascii.hexlify(claim_value['source']['source']).decode() + if 'releaseTime' in claim_value['metadata']: + release_time = int(claim_value['metadata'].pop('releaseTime')) + if release_time != 0: + claim_value['metadata']['releaseTime'] = release_time if 'fee' in claim_value['metadata']: try: address = encode_address(claim_value['metadata']['fee']['address']) diff --git a/lbrynet/schema/schema/metadata.py b/lbrynet/schema/schema/metadata.py index edbf298a9..c6d8dd9bd 100644 --- a/lbrynet/schema/schema/metadata.py +++ b/lbrynet/schema/schema/metadata.py @@ -14,4 +14,8 @@ class Metadata(Schema): if 'fee' in _metadata: fee_pb = Fee.load(_metadata.pop('fee')) _message_pb.fee.CopyFrom(fee_pb) - return cls._load(_metadata, _message_pb) + _message_pb.releaseTime = int(_metadata.get('releaseTime', 0)) + built_message = cls._load(_metadata, _message_pb) + if built_message.releaseTime == 0: + built_message.ClearField('releaseTime') + return built_message