Skip to content

Commit 967415e

Browse files
committed
more minimize diffs
1 parent 952e147 commit 967415e

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

chia/consensus/blockchain.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -510,18 +510,8 @@ async def _reconsider_peak(
510510
and the new chain, or returns None if there was no update to the heaviest chain.
511511
"""
512512

513-
if genesis and self.get_peak() is not None:
514-
return [], None
515-
516513
async with self.consensus_store.writer() as writer:
517-
records_to_add, state_summary = await self._perform_db_operations_for_peak(
518-
writer, block_record, genesis, fork_info
519-
)
520-
521-
# Changes the peak to be the new peak
522-
await writer.set_peak(block_record.header_hash)
523-
524-
return records_to_add, state_summary
514+
return await self._perform_db_operations_for_peak(writer, block_record, genesis, fork_info)
525515

526516
async def _perform_db_operations_for_peak(
527517
self,
@@ -537,6 +527,9 @@ async def _perform_db_operations_for_peak(
537527
peak = self.get_peak()
538528
rolled_back_state: dict[bytes32, CoinRecord] = {}
539529

530+
if genesis and peak is not None:
531+
return [], None
532+
540533
if peak is not None:
541534
if block_record.weight < peak.weight:
542535
# This is not a heavier block than the heaviest we have seen, so we don't change the coin set
@@ -637,8 +630,10 @@ async def _perform_db_operations_for_peak(
637630
await writer.rollback(fork_info.fork_height)
638631
await writer.set_in_chain([(br.header_hash,) for br in records_to_add])
639632

640-
# Create and return the complete StateChangeSummary
641-
state_summary = StateChangeSummary(
633+
# Changes the peak to be the new peak
634+
await writer.set_peak(block_record.header_hash)
635+
636+
return records_to_add, StateChangeSummary(
642637
block_record,
643638
uint32(max(fork_info.fork_height, 0)),
644639
list(rolled_back_state.values()),
@@ -651,8 +646,6 @@ async def _perform_db_operations_for_peak(
651646
[fork_add.coin for fork_add in fork_info.additions_since_fork.values() if fork_add.is_coinbase],
652647
)
653648

654-
return records_to_add, state_summary
655-
656649
def get_next_sub_slot_iters_and_difficulty(self, header_hash: bytes32, new_slot: bool) -> tuple[uint64, uint64]:
657650
curr = self.try_block_record(header_hash)
658651
assert curr is not None

0 commit comments

Comments
 (0)