From 7cf245a0e9d2aa2978c272e1f8cbad553997c890 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 29 Apr 2019 00:37:18 -0300 Subject: [PATCH] encode timestamp and confirmations into file list --- lbrynet/extras/daemon/json_response_encoder.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lbrynet/extras/daemon/json_response_encoder.py b/lbrynet/extras/daemon/json_response_encoder.py index ccd5c681d..859a2f915 100644 --- a/lbrynet/extras/daemon/json_response_encoder.py +++ b/lbrynet/extras/daemon/json_response_encoder.py @@ -206,9 +206,16 @@ class JSONResponseEncoder(JSONEncoder): result['is_default'] = self.ledger.accounts[0] == account return result - @staticmethod - def encode_file(managed_stream): - return managed_stream.as_dict() + def encode_file(self, managed_stream): + file = managed_stream.as_dict() + tx_height = managed_stream.stream_claim_info.height + best_height = self.ledger.headers.height + file.update({ + 'height': tx_height, + 'confirmations': (best_height+1) - tx_height if tx_height > 0 else tx_height, + 'timestamp': self.ledger.headers[tx_height]['timestamp'] if tx_height > 0 else None + }) + return file @staticmethod def encode_claim(claim):