Skip to content

Commit

Permalink
update _peak_height after committing the block to the DB (#13157)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Aug 25, 2022
1 parent b3b56a6 commit 2d551dd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chia/consensus/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ async def receive_block(
fetched_block_record.header_hash,
fetched_block_record.sub_epoch_summary_included,
)
if state_change_summary is not None:
self._peak_height = block_record.height
except BaseException as e:
self.block_store.rollback_cache_block(header_hash)
log.error(
Expand All @@ -293,6 +291,11 @@ async def receive_block(
)
raise

# make sure to update _peak_height after the transaction is committed,
# otherwise other tasks may go look for this block before it's available
if state_change_summary is not None:
self._peak_height = block_record.height

# This is done outside the try-except in case it fails, since we do not want to revert anything if it does
await self.__height_map.maybe_flush()

Expand Down

0 comments on commit 2d551dd

Please sign in to comment.