From 0d19439982fe0b7c663de9750d071dc12285cecc Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 9 Sep 2021 17:12:12 -0400 Subject: [PATCH] fix release_time and creation_timestamp --- lbry/wallet/server/leveldb.py | 15 +++++++++++---- .../integration/blockchain/test_claim_commands.py | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lbry/wallet/server/leveldb.py b/lbry/wallet/server/leveldb.py index 51a397c84..f39b5ceda 100644 --- a/lbry/wallet/server/leveldb.py +++ b/lbry/wallet/server/leveldb.py @@ -667,8 +667,8 @@ class LevelDB: 'tx_num': claim.tx_num, 'tx_nout': claim.position, 'amount': claim.amount, - 'timestamp': 0, # TODO: fix - 'creation_timestamp': 0, # TODO: fix + 'timestamp': self.estimate_timestamp(claim.height), + 'creation_timestamp': self.estimate_timestamp(claim.creation_height), 'height': claim.height, 'creation_height': claim.creation_height, 'activation_height': claim.activation_height, @@ -713,8 +713,10 @@ class LevelDB: value['duration'] = reposted_duration elif metadata.is_stream and (metadata.stream.video.duration or metadata.stream.audio.duration): value['duration'] = metadata.stream.video.duration or metadata.stream.audio.duration - if metadata.is_stream and metadata.stream.release_time: - value['release_time'] = metadata.stream.release_time + if metadata.is_stream: + value['release_time'] = metadata.stream.release_time or value['creation_timestamp'] + elif metadata.is_repost or metadata.is_collection: + value['release_time'] = value['creation_timestamp'] return value async def all_claims_producer(self, batch_size=500_000): @@ -871,6 +873,11 @@ class LevelDB: assert len(headers) - 1 == self.db_height, f"{len(headers)} vs {self.db_height}" self.headers = headers + def estimate_timestamp(self, height: int) -> int: + if height < len(self.headers): + return struct.unpack('