diff --git a/lbry/wallet/server/block_processor.py b/lbry/wallet/server/block_processor.py index 437b24f18..e2ecb69ce 100644 --- a/lbry/wallet/server/block_processor.py +++ b/lbry/wallet/server/block_processor.py @@ -251,7 +251,7 @@ class BlockProcessor: async def get_raw_blocks(last_height, hex_hashes): heights = range(last_height, last_height - len(hex_hashes), -1) try: - blocks = [self.db.read_raw_block(height) for height in heights] + blocks = [await self.db.read_raw_block(height) for height in heights] self.logger.info(f'read {len(blocks)} blocks from disk') return blocks except FileNotFoundError: diff --git a/lbry/wallet/server/leveldb.py b/lbry/wallet/server/leveldb.py index cdcbbe50a..fe048c9b4 100644 --- a/lbry/wallet/server/leveldb.py +++ b/lbry/wallet/server/leveldb.py @@ -479,11 +479,15 @@ class LevelDB: def raw_block_path(self, height): return os.path.join(self.env.db_dir, f'{self.raw_block_prefix()}{height:d}') - def read_raw_block(self, height): + async def read_raw_block(self, height): """Returns a raw block read from disk. Raises FileNotFoundError if the block isn't on-disk.""" - with util.open_file(self.raw_block_path(height)) as f: - return f.read(-1) + + def read(): + with util.open_file(self.raw_block_path(height)) as f: + return f.read(-1) + + return await asyncio.get_event_loop().run_in_executor(self.executor, read) def write_raw_block(self, block, height): """Write a raw block to disk."""