File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed
common/src/service/block_producer Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ impl node::service::BlockProducerService for crate::NodeService {
103103 . expect ( "provers shouldn't be needed if block producer isn't initialized" )
104104 . provers
105105 . clone ( )
106- . unwrap_or_else ( || BlockProver :: get_once_made ( ) )
106+ . unwrap_or_else ( BlockProver :: get_once_made)
107107 }
108108
109109 fn prove ( & mut self , block_hash : StateHash , input : Box < ProverExtendBlockchainInputStableV2 > ) {
Original file line number Diff line number Diff line change @@ -290,12 +290,12 @@ impl State {
290290 }
291291
292292 fn cur_slot ( & self , initial_slot : impl FnOnce ( & ArcBlockWithHash ) -> u32 ) -> Option < u32 > {
293- let best_tip = self . transition_frontier . best_tip ( ) ?;
294- let best_tip_ms = u64:: from ( best_tip . timestamp ( ) ) / 1_000_000 ;
293+ let genesis = self . genesis_block ( ) ?;
294+ let initial_ms = u64:: from ( genesis . timestamp ( ) ) / 1_000_000 ;
295295 let now_ms = u64:: from ( self . time ( ) ) / 1_000_000 ;
296- let ms = now_ms. saturating_sub ( best_tip_ms ) ;
296+ let ms = now_ms. saturating_sub ( initial_ms ) ;
297297 let slots = ms / constraint_constants ( ) . block_window_duration_ms ;
298- Some ( initial_slot ( best_tip ) + slots as u32 )
298+ Some ( initial_slot ( & genesis ) + slots as u32 )
299299 }
300300
301301 /// Current global slot based on constants and current time.
@@ -306,7 +306,8 @@ impl State {
306306 }
307307
308308 pub fn current_slot ( & self ) -> Option < u32 > {
309- self . cur_slot ( |b| b. global_slot ( ) % b. constants ( ) . slots_per_epoch . as_u32 ( ) )
309+ let slots_per_epoch = self . genesis_block ( ) ?. constants ( ) . slots_per_epoch . as_u32 ( ) ;
310+ Some ( self . cur_global_slot ( ) ? % slots_per_epoch)
310311 }
311312
312313 pub fn cur_global_slot_since_genesis ( & self ) -> Option < u32 > {
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ impl Cluster {
321321
322322 if let Some ( keypair) = block_producer_sec_key {
323323 let provers = BlockProver :: make ( None , None ) ;
324- service_builder. block_producer_init ( keypair, provers) ;
324+ service_builder. block_producer_init ( keypair, Some ( provers) ) ;
325325 }
326326
327327 let real_service = service_builder
You can’t perform that action at this time.
0 commit comments