Skip to content

Commit

Permalink
run in thread
Browse files Browse the repository at this point in the history
  • Loading branch information
jackrobison committed Apr 5, 2022
1 parent 4cfc1b4 commit 8a2517a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 8 additions & 0 deletions scribe/db/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,14 @@ def close(self):
self.prefix_db.close()
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:
if self._cache_all_tx_hashes:
return self.total_transactions[tx_num]
Expand Down
7 changes: 1 addition & 6 deletions scribe/hub/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,12 +1101,7 @@ def sub_count(self):
return len(self.hashX_subs)

async def get_hashX_status(self, hashX: bytes):
mempool_status = self.db.prefix_db.hashX_mempool_status.get(hashX)
if mempool_status:
return mempool_status.status.hex()
status = self.db.prefix_db.hashX_status.get(hashX)
if status:
return status.status.hex()
return await self.loop.run_in_executor(self.db._executor, self.db.get_hashX_status, hashX)

async def send_history_notifications(self, *hashXes: typing.Iterable[bytes]):
notifications = []
Expand Down

0 comments on commit 8a2517a

Please sign in to comment.