@@ -102,6 +102,7 @@ class PeakPostProcessingResult:
102
102
fns_peak_result : FullNodeStorePeakResult # The result of calling FullNodeStore.new_peak
103
103
hints : list [tuple [bytes32 , bytes ]] # The hints added to the DB
104
104
lookup_coin_ids : list [bytes32 ] # The coin IDs that we need to look up to notify wallets of changes
105
+ signage_points : list [tuple [RespondSignagePoint , WSChiaConnection , Optional [EndOfSubSlotBundle ]]]
105
106
106
107
107
108
@dataclasses .dataclass (frozen = True )
@@ -837,7 +838,7 @@ async def send_peak_to_timelords(
837
838
peak_block = await self .blockchain .get_full_peak ()
838
839
if peak_block is not None :
839
840
peak = self .blockchain .block_record (peak_block .header_hash )
840
- difficulty = self .blockchain .get_next_difficulty (peak .header_hash , False )
841
+ difficulty = self .blockchain .get_next_sub_slot_iters_and_difficulty (peak .header_hash , False )[ 1 ]
841
842
ses : Optional [SubEpochSummary ] = next_sub_epoch_summary (
842
843
self .constants ,
843
844
self .blockchain ,
@@ -1807,10 +1808,9 @@ async def signage_point_post_processing(
1807
1808
# Makes sure to potentially update the difficulty if we are past the peak (into a new sub-slot)
1808
1809
assert ip_sub_slot is not None
1809
1810
if request .challenge_chain_vdf .challenge != ip_sub_slot .challenge_chain .get_hash ():
1810
- next_difficulty = self .blockchain .get_next_difficulty (peak .header_hash , True )
1811
- next_sub_slot_iters = self .blockchain .get_next_slot_iters (peak .header_hash , True )
1812
- difficulty = next_difficulty
1813
- sub_slot_iters = next_sub_slot_iters
1811
+ sub_slot_iters , difficulty = self .blockchain .get_next_sub_slot_iters_and_difficulty (
1812
+ peak .header_hash , True
1813
+ )
1814
1814
else :
1815
1815
difficulty = self .constants .DIFFICULTY_STARTING
1816
1816
sub_slot_iters = self .constants .SUB_SLOT_ITERS_STARTING
@@ -1845,8 +1845,7 @@ async def peak_post_processing(
1845
1845
"""
1846
1846
1847
1847
record = state_change_summary .peak
1848
- difficulty = self .blockchain .get_next_difficulty (record .header_hash , False )
1849
- sub_slot_iters = self .blockchain .get_next_slot_iters (record .header_hash , False )
1848
+ sub_slot_iters , difficulty = self .blockchain .get_next_sub_slot_iters_and_difficulty (record .header_hash , False )
1850
1849
1851
1850
self .log .info (
1852
1851
f"🌱 Updated peak to height { record .height } , weight { record .weight } , "
@@ -1895,6 +1894,7 @@ async def peak_post_processing(
1895
1894
difficulty ,
1896
1895
)
1897
1896
1897
+ signage_points : list [tuple [RespondSignagePoint , WSChiaConnection , Optional [EndOfSubSlotBundle ]]] = []
1898
1898
if fns_peak_result .new_signage_points is not None and peer is not None :
1899
1899
for index , sp in fns_peak_result .new_signage_points :
1900
1900
assert (
@@ -1903,8 +1903,13 @@ async def peak_post_processing(
1903
1903
and sp .rc_vdf is not None
1904
1904
and sp .rc_proof is not None
1905
1905
)
1906
- await self .signage_point_post_processing (
1907
- RespondSignagePoint (index , sp .cc_vdf , sp .cc_proof , sp .rc_vdf , sp .rc_proof ), peer , sub_slots [1 ]
1906
+ # Collect the data for networking outside the mutex
1907
+ signage_points .append (
1908
+ (
1909
+ RespondSignagePoint (index , sp .cc_vdf , sp .cc_proof , sp .rc_vdf , sp .rc_proof ),
1910
+ peer ,
1911
+ sub_slots [1 ],
1912
+ )
1908
1913
)
1909
1914
1910
1915
if sub_slots [1 ] is None :
@@ -1934,6 +1939,7 @@ async def peak_post_processing(
1934
1939
fns_peak_result ,
1935
1940
hints_to_add ,
1936
1941
lookup_coin_ids ,
1942
+ signage_points = signage_points ,
1937
1943
)
1938
1944
1939
1945
async def peak_post_processing_2 (
@@ -1948,6 +1954,8 @@ async def peak_post_processing_2(
1948
1954
with peers
1949
1955
"""
1950
1956
record = state_change_summary .peak
1957
+ for signage_point in ppp_result .signage_points :
1958
+ await self .signage_point_post_processing (* signage_point )
1951
1959
for new_peak_item in ppp_result .mempool_peak_result :
1952
1960
self .log .debug (f"Added transaction to mempool: { new_peak_item .transaction_id } " )
1953
1961
mempool_item = self .mempool_manager .get_mempool_item (new_peak_item .transaction_id )
@@ -2673,8 +2681,9 @@ async def add_end_of_sub_slot(
2673
2681
2674
2682
peak = self .blockchain .get_peak ()
2675
2683
if peak is not None and peak .height > 2 :
2676
- next_sub_slot_iters = self .blockchain .get_next_slot_iters (peak .header_hash , True )
2677
- next_difficulty = self .blockchain .get_next_difficulty (peak .header_hash , True )
2684
+ next_sub_slot_iters , next_difficulty = self .blockchain .get_next_sub_slot_iters_and_difficulty (
2685
+ peak .header_hash , True
2686
+ )
2678
2687
else :
2679
2688
next_sub_slot_iters = self .constants .SUB_SLOT_ITERS_STARTING
2680
2689
next_difficulty = self .constants .DIFFICULTY_STARTING
0 commit comments