run in thread

This commit is contained in:
Jack Robison 2022-04-05 15:40:51 -04:00
parent 4cfc1b4765
commit 8a2517aa36
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 9 additions and 6 deletions

View file

@ -850,6 +850,14 @@ class HubDB:
self.prefix_db.close() self.prefix_db.close()
self.prefix_db = None self.prefix_db = None
def get_hashX_status(self, hashX: bytes):
mempool_status = self.prefix_db.hashX_mempool_status.get(hashX)
if mempool_status:
return mempool_status.status.hex()
status = self.prefix_db.hashX_status.get(hashX)
if status:
return status.status.hex()
def get_tx_hash(self, tx_num: int) -> bytes: def get_tx_hash(self, tx_num: int) -> bytes:
if self._cache_all_tx_hashes: if self._cache_all_tx_hashes:
return self.total_transactions[tx_num] return self.total_transactions[tx_num]

View file

@ -1101,12 +1101,7 @@ class LBRYElectrumX(asyncio.Protocol):
return len(self.hashX_subs) return len(self.hashX_subs)
async def get_hashX_status(self, hashX: bytes): async def get_hashX_status(self, hashX: bytes):
mempool_status = self.db.prefix_db.hashX_mempool_status.get(hashX) return await self.loop.run_in_executor(self.db._executor, self.db.get_hashX_status, hashX)
if mempool_status:
return mempool_status.status.hex()
status = self.db.prefix_db.hashX_status.get(hashX)
if status:
return status.status.hex()
async def send_history_notifications(self, *hashXes: typing.Iterable[bytes]): async def send_history_notifications(self, *hashXes: typing.Iterable[bytes]):
notifications = [] notifications = []