@@ -510,18 +510,8 @@ async def _reconsider_peak(
510
510
and the new chain, or returns None if there was no update to the heaviest chain.
511
511
"""
512
512
513
- if genesis and self .get_peak () is not None :
514
- return [], None
515
-
516
513
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 )
525
515
526
516
async def _perform_db_operations_for_peak (
527
517
self ,
@@ -537,6 +527,9 @@ async def _perform_db_operations_for_peak(
537
527
peak = self .get_peak ()
538
528
rolled_back_state : dict [bytes32 , CoinRecord ] = {}
539
529
530
+ if genesis and peak is not None :
531
+ return [], None
532
+
540
533
if peak is not None :
541
534
if block_record .weight < peak .weight :
542
535
# 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(
637
630
await writer .rollback (fork_info .fork_height )
638
631
await writer .set_in_chain ([(br .header_hash ,) for br in records_to_add ])
639
632
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 (
642
637
block_record ,
643
638
uint32 (max (fork_info .fork_height , 0 )),
644
639
list (rolled_back_state .values ()),
@@ -651,8 +646,6 @@ async def _perform_db_operations_for_peak(
651
646
[fork_add .coin for fork_add in fork_info .additions_since_fork .values () if fork_add .is_coinbase ],
652
647
)
653
648
654
- return records_to_add , state_summary
655
-
656
649
def get_next_sub_slot_iters_and_difficulty (self , header_hash : bytes32 , new_slot : bool ) -> tuple [uint64 , uint64 ]:
657
650
curr = self .try_block_record (header_hash )
658
651
assert curr is not None
0 commit comments