Skip to content

Commit

Permalink
use try_block_record
Browse files Browse the repository at this point in the history
  • Loading branch information
almogdepaz committed Jan 14, 2025
1 parent 1437e4e commit 4f144a6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions chia/consensus/difficulty_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,10 @@ def _get_next_sub_slot_iters(
if next_height < constants.EPOCH_BLOCKS:
return uint64(constants.SUB_SLOT_ITERS_STARTING)

if not blocks.contains_block(prev_header_hash):
prev_b = blocks.try_block_record(prev_header_hash)
if prev_b is None:
raise ValueError(f"Header hash {prev_header_hash} not in blocks")

prev_b: BlockRecord = blocks.block_record(prev_header_hash)

# If we are in the same epoch, return same ssi
if not skip_epoch_check:
_, can_finish_epoch = can_finish_sub_and_full_epoch(
Expand Down Expand Up @@ -304,11 +303,10 @@ def _get_next_difficulty(
# We are in the first epoch
return uint64(constants.DIFFICULTY_STARTING)

if not blocks.contains_block(prev_header_hash):
prev_b = blocks.try_block_record(prev_header_hash)
if prev_b is None:
raise ValueError(f"Header hash {prev_header_hash} not in blocks")

prev_b: BlockRecord = blocks.block_record(prev_header_hash)

# If we are in the same slot as previous block, return same difficulty
if not skip_epoch_check:
_, can_finish_epoch = can_finish_sub_and_full_epoch(
Expand Down

0 comments on commit 4f144a6

Please sign in to comment.