From 0b245aab31b380e47fcc9e6e8a8a28c894054193 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 4 Aug 2020 11:47:03 -0400 Subject: [PATCH] use base64 for protobuf response --- lbry/db/database.py | 2 +- lbry/db/queries/resolve.py | 4 ++-- lbry/service/json_encoder.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lbry/db/database.py b/lbry/db/database.py index 2ce8ea96f..e42b50e3d 100644 --- a/lbry/db/database.py +++ b/lbry/db/database.py @@ -279,7 +279,7 @@ class Database: async def resolve(self, urls, **kwargs) -> Dict[str, Output]: return await self.run(q.resolve, urls, **kwargs) - async def protobuf_resolve(self, urls, **kwargs) -> bytes: + async def protobuf_resolve(self, urls, **kwargs) -> str: return await self.run(q.protobuf_resolve, urls, **kwargs) async def get_txo_sum(self, **constraints) -> int: diff --git a/lbry/db/queries/resolve.py b/lbry/db/queries/resolve.py index 73e402998..5139f18ea 100644 --- a/lbry/db/queries/resolve.py +++ b/lbry/db/queries/resolve.py @@ -36,8 +36,8 @@ def _get_referenced_rows(txo_rows: List[dict], censor_channels: List[bytes]): return channel_txos + reposted_txos -def protobuf_resolve(urls, **kwargs) -> bytes: - return ResultOutput.to_bytes([resolve_url(raw_url) for raw_url in urls], []) +def protobuf_resolve(urls, **kwargs) -> str: + return ResultOutput.to_base64([resolve_url(raw_url) for raw_url in urls], []) def resolve(urls, **kwargs) -> Dict[str, Output]: diff --git a/lbry/service/json_encoder.py b/lbry/service/json_encoder.py index e30ae75b5..cbef04fb9 100644 --- a/lbry/service/json_encoder.py +++ b/lbry/service/json_encoder.py @@ -187,7 +187,7 @@ class JSONResponseEncoder(JSONEncoder): if isinstance(obj, Decimal): return float(obj) if isinstance(obj, bytes): - return hexlify(obj).decode() + return obj.decode() return super().default(obj) def encode_transaction(self, tx):