@@ -338,13 +338,6 @@ impl BlockProducerEnabled {
338338 }
339339 ) ) ,
340340 } ) ;
341-
342- #[ cfg( feature = "p2p-libp2p" ) ]
343- {
344- use mina_p2p_messages:: gossip:: GossipNetMessageV2 ;
345- let message = Box :: new ( GossipNetMessageV2 :: NewState ( best_tip. block . clone ( ) ) ) ;
346- dispatcher. push ( P2pNetworkPubsubAction :: Broadcast { message } ) ;
347- }
348341 }
349342 BlockProducerAction :: BlockInjected => {
350343 if let BlockProducerCurrentState :: Produced {
@@ -365,7 +358,10 @@ impl BlockProducerEnabled {
365358 bug_condition ! ( "Invalid state for `BlockProducerAction::BlockInjected` expected: `BlockProducerCurrentState::Produced`, found: {:?}" , state. current) ;
366359 }
367360
368- let dispatcher = state_context. into_dispatcher ( ) ;
361+ let ( dispatcher, global_state) = state_context. into_dispatcher_and_state ( ) ;
362+
363+ #[ cfg( feature = "p2p-libp2p" ) ]
364+ broadcast_injected_block ( global_state, dispatcher) ;
369365
370366 dispatcher. push ( BlockProducerAction :: WonSlotSearch ) ;
371367 }
@@ -757,6 +753,24 @@ impl BlockProducerEnabled {
757753 }
758754}
759755
756+ #[ cfg( feature = "p2p-libp2p" ) ]
757+ fn broadcast_injected_block ( global_state : & State , dispatcher : & mut Dispatcher < Action , State > ) {
758+ use mina_p2p_messages:: gossip:: GossipNetMessageV2 ;
759+
760+ let Some ( block) = global_state
761+ . block_producer
762+ . as_ref ( )
763+ . and_then ( |bp| bp. current . injected_block ( ) )
764+ . map ( |pb| pb. block . clone ( ) )
765+ else {
766+ // Should be impossible, we call this immediately after having injected the block.
767+ return ;
768+ } ;
769+
770+ let message = Box :: new ( GossipNetMessageV2 :: NewState ( block) ) ;
771+ dispatcher. push ( P2pNetworkPubsubAction :: Broadcast { message } ) ;
772+ }
773+
760774fn can_apply_supercharged_coinbase (
761775 block_stake_winner : & v2:: NonZeroCurvePoint ,
762776 stake_proof_sparse_ledger : & v2:: MinaBaseSparseLedgerBaseStableV2 ,
0 commit comments