Skip to content

Commit

Permalink
CHIA-1716 Speedup get_header_blocks_in_range w.r.t. blocks with no tr…
Browse files Browse the repository at this point in the history
…ansactions (#18829)

Speedup get_header_blocks_in_range w.r.t. blocks with no transactions.
  • Loading branch information
AmineKhaldi authored Nov 6, 2024
1 parent 15079c6 commit 816462d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chia/consensus/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,10 @@ async def get_header_blocks_in_range(
raise ValueError(f"Block at {block.header_hash} is no longer in the blockchain (it's in a fork)")
if tx_filter is False:
header = get_block_header(block, [], [])
elif block.transactions_generator is None:
# There is no point in getting additions and removals for
# blocks that do not have transactions.
header = get_block_header(block, [], [])
else:
tx_additions: list[CoinRecord] = [
c for c in (await self.coin_store.get_coins_added_at_height(block.height)) if not c.coinbase
Expand Down

0 comments on commit 816462d

Please sign in to comment.