use base64 for protobuf response

This commit is contained in:
Lex Berezhny 2020-08-04 11:47:03 -04:00
parent ee3db31541
commit 0b245aab31
3 changed files with 4 additions and 4 deletions

View file

@ -279,7 +279,7 @@ class Database:
async def resolve(self, urls, **kwargs) -> Dict[str, Output]: async def resolve(self, urls, **kwargs) -> Dict[str, Output]:
return await self.run(q.resolve, urls, **kwargs) 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) return await self.run(q.protobuf_resolve, urls, **kwargs)
async def get_txo_sum(self, **constraints) -> int: async def get_txo_sum(self, **constraints) -> int:

View file

@ -36,8 +36,8 @@ def _get_referenced_rows(txo_rows: List[dict], censor_channels: List[bytes]):
return channel_txos + reposted_txos return channel_txos + reposted_txos
def protobuf_resolve(urls, **kwargs) -> bytes: def protobuf_resolve(urls, **kwargs) -> str:
return ResultOutput.to_bytes([resolve_url(raw_url) for raw_url in urls], []) return ResultOutput.to_base64([resolve_url(raw_url) for raw_url in urls], [])
def resolve(urls, **kwargs) -> Dict[str, Output]: def resolve(urls, **kwargs) -> Dict[str, Output]:

View file

@ -187,7 +187,7 @@ class JSONResponseEncoder(JSONEncoder):
if isinstance(obj, Decimal): if isinstance(obj, Decimal):
return float(obj) return float(obj)
if isinstance(obj, bytes): if isinstance(obj, bytes):
return hexlify(obj).decode() return obj.decode()
return super().default(obj) return super().default(obj)
def encode_transaction(self, tx): def encode_transaction(self, tx):