|
|
@ -402,7 +402,7 @@ class DB(object): |
|
|
|
return await run_in_thread(read_headers) |
|
|
|
|
|
|
|
def fs_tx_hash(self, tx_num): |
|
|
|
'''Return a par (tx_hash, tx_height) for the given tx number. |
|
|
|
'''Return a pair (tx_hash, tx_height) for the given tx number. |
|
|
|
|
|
|
|
If the tx_height is not on disk, returns (None, tx_height).''' |
|
|
|
tx_height = bisect_right(self.tx_counts, tx_num) |
|
|
@ -412,6 +412,25 @@ class DB(object): |
|
|
|
tx_hash = self.hashes_file.read(tx_num * 32, 32) |
|
|
|
return tx_hash, tx_height |
|
|
|
|
|
|
|
def fs_tx_hashes_at_blockheight(self, block_height): |
|
|
|
'''Return a list of tx_hashes at given block height, |
|
|
|
in the same order as in the block. |
|
|
|
''' |
|
|
|
if block_height > self.db_height: |
|
|
|
raise self.DBError(f'block {block_height:,d} not on disk (>{self.db_height:,d})') |
|
|
|
assert block_height >= 0 |
|
|
|
if block_height > 0: |
|
|
|
first_tx_num = self.tx_counts[block_height - 1] |
|
|
|
else: |
|
|
|
first_tx_num = 0 |
|
|
|
num_txs_in_block = self.tx_counts[block_height] - first_tx_num |
|
|
|
tx_hashes = self.hashes_file.read(first_tx_num * 32, num_txs_in_block * 32) |
|
|
|
assert num_txs_in_block == len(tx_hashes) // 32 |
|
|
|
return [tx_hashes[idx * 32: (idx+1) * 32] for idx in range(num_txs_in_block)] |
|
|
|
|
|
|
|
async def tx_hashes_at_blockheight(self, block_height): |
|
|
|
return await run_in_thread(self.fs_tx_hashes_at_blockheight, block_height) |
|
|
|
|
|
|
|
async def fs_block_hashes(self, height, count): |
|
|
|
headers_concat, headers_count = await self.read_headers(height, count) |
|
|
|
if headers_count != count: |
|
|
|