1515// limitations under the License. 
1616
1717use  crate :: { 
18- 	cli:: AuthoringPolicy , 
18+ 	cli:: { AuthoringPolicy ,   DevSealMode } , 
1919	common:: { 
2020		aura:: { AuraIdT ,  AuraRuntimeApi } , 
2121		rpc:: { BuildParachainRpcExtensions ,  BuildRpcExtensions } , 
@@ -211,9 +211,9 @@ where
211211	type  StartConsensus  = StartConsensus ; 
212212	const  SYBIL_RESISTANCE :  CollatorSybilResistance  = CollatorSybilResistance :: Resistant ; 
213213
214- 	fn  start_manual_seal_node ( 
214+ 	fn  start_dev_node ( 
215215		mut  config :  Configuration , 
216- 		block_time :   u64 , 
216+ 		mode :   DevSealMode , 
217217	)  -> sc_service:: error:: Result < TaskManager >  { 
218218		let  PartialComponents  { 
219219			client, 
@@ -277,24 +277,6 @@ where
277277			None , 
278278		) ; 
279279
280- 		let  ( manual_seal_sink,  manual_seal_stream)  = futures:: channel:: mpsc:: channel ( 1024 ) ; 
281- 		let  mut  manual_seal_sink_clone = manual_seal_sink. clone ( ) ; 
282- 		task_manager
283- 			. spawn_essential_handle ( ) 
284- 			. spawn ( "block_authoring" ,  None ,  async  move  { 
285- 				loop  { 
286- 					futures_timer:: Delay :: new ( std:: time:: Duration :: from_millis ( block_time) ) . await ; 
287- 					manual_seal_sink_clone
288- 						. try_send ( sc_consensus_manual_seal:: EngineCommand :: SealNewBlock  { 
289- 							create_empty :  true , 
290- 							finalize :  true , 
291- 							parent_hash :  None , 
292- 							sender :  None , 
293- 						} ) 
294- 						. unwrap ( ) ; 
295- 				} 
296- 			} ) ; 
297- 
298280		// Note: Changing slot durations are currently not supported 
299281		let  slot_duration = sc_consensus_aura:: slot_duration ( & * client) 
300282			. expect ( "slot_duration is always present; qed." ) ; 
@@ -305,29 +287,67 @@ where
305287
306288		let  para_id =
307289			Self :: parachain_id ( & client,  & config) . ok_or ( "Failed to retrieve the parachain id" ) ?; 
308- 		let  create_inherent_data_providers = Self :: create_manual_seal_inherent_data_providers ( 
309- 			client. clone ( ) , 
310- 			para_id, 
311- 			slot_duration, 
312- 		) ; 
313- 
314- 		let  params = sc_consensus_manual_seal:: ManualSealParams  { 
315- 			block_import :  client. clone ( ) , 
316- 			env :  proposer, 
317- 			client :  client. clone ( ) , 
318- 			pool :  transaction_pool. clone ( ) , 
319- 			select_chain :  LongestChain :: new ( backend. clone ( ) ) , 
320- 			commands_stream :  Box :: pin ( manual_seal_stream) , 
321- 			consensus_data_provider :  Some ( Box :: new ( aura_digest_provider) ) , 
322- 			create_inherent_data_providers, 
323- 		} ; 
324- 
325- 		let  authorship_future = sc_consensus_manual_seal:: run_manual_seal ( params) ; 
326- 		task_manager. spawn_essential_handle ( ) . spawn_blocking ( 
327- 			"manual-seal" , 
328- 			None , 
329- 			authorship_future, 
330- 		) ; 
290+ 		let  create_inherent_data_providers =
291+ 			Self :: create_dev_node_inherent_data_providers ( client. clone ( ) ,  para_id,  slot_duration) ; 
292+ 
293+ 		match  mode { 
294+ 			DevSealMode :: InstantSeal  => { 
295+ 				let  params = sc_consensus_manual_seal:: InstantSealParams  { 
296+ 					block_import :  client. clone ( ) , 
297+ 					env :  proposer, 
298+ 					client :  client. clone ( ) , 
299+ 					pool :  transaction_pool. clone ( ) , 
300+ 					select_chain :  LongestChain :: new ( backend. clone ( ) ) , 
301+ 					consensus_data_provider :  Some ( Box :: new ( aura_digest_provider) ) , 
302+ 					create_inherent_data_providers, 
303+ 				} ; 
304+ 
305+ 				let  authorship_future = sc_consensus_manual_seal:: run_instant_seal ( params) ; 
306+ 				task_manager. spawn_essential_handle ( ) . spawn_blocking ( 
307+ 					"instant-seal" , 
308+ 					None , 
309+ 					authorship_future, 
310+ 				) ; 
311+ 			} , 
312+ 			DevSealMode :: ManualSeal ( block_time)  => { 
313+ 				let  ( manual_seal_sink,  manual_seal_stream)  = futures:: channel:: mpsc:: channel ( 1024 ) ; 
314+ 				let  mut  manual_seal_sink_clone = manual_seal_sink. clone ( ) ; 
315+ 				task_manager
316+ 					. spawn_essential_handle ( ) 
317+ 					. spawn ( "block_authoring" ,  None ,  async  move  { 
318+ 						loop  { 
319+ 							futures_timer:: Delay :: new ( std:: time:: Duration :: from_millis ( block_time) ) 
320+ 								. await ; 
321+ 							manual_seal_sink_clone
322+ 								. try_send ( sc_consensus_manual_seal:: EngineCommand :: SealNewBlock  { 
323+ 									create_empty :  true , 
324+ 									finalize :  true , 
325+ 									parent_hash :  None , 
326+ 									sender :  None , 
327+ 								} ) 
328+ 								. unwrap ( ) ; 
329+ 						} 
330+ 					} ) ; 
331+ 
332+ 				let  params = sc_consensus_manual_seal:: ManualSealParams  { 
333+ 					block_import :  client. clone ( ) , 
334+ 					env :  proposer, 
335+ 					client :  client. clone ( ) , 
336+ 					pool :  transaction_pool. clone ( ) , 
337+ 					select_chain :  LongestChain :: new ( backend. clone ( ) ) , 
338+ 					commands_stream :  Box :: pin ( manual_seal_stream) , 
339+ 					consensus_data_provider :  Some ( Box :: new ( aura_digest_provider) ) , 
340+ 					create_inherent_data_providers, 
341+ 				} ; 
342+ 
343+ 				let  authorship_future = sc_consensus_manual_seal:: run_manual_seal ( params) ; 
344+ 				task_manager. spawn_essential_handle ( ) . spawn_blocking ( 
345+ 					"manual-seal" , 
346+ 					None , 
347+ 					authorship_future, 
348+ 				) ; 
349+ 			} , 
350+ 		} 
331351
332352		let  rpc_extensions_builder = { 
333353			let  client = client. clone ( ) ; 
@@ -373,11 +393,11 @@ where
373393	RuntimeApi :: RuntimeApi :  AuraRuntimeApi < Block ,  AuraId > , 
374394	AuraId :  AuraIdT  + Sync , 
375395{ 
376- 	/// Creates the inherent data providers for manual seal consensus. 
396+ 	/// Creates the inherent data providers for manual and instant  seal consensus. 
377397 	/// 
378398 	/// This function sets up the timestamp and parachain validation data providers 
379-  	/// required for manual  seal block production in a parachain environment. 
380-  	fn  create_manual_seal_inherent_data_providers ( 
399+  	/// required for dev  seal block production in a parachain environment. 
400+  	fn  create_dev_node_inherent_data_providers ( 
381401		client :  Arc < ParachainClient < Block ,  RuntimeApi > > , 
382402		para_id :  ParaId , 
383403		slot_duration :  sp_consensus_aura:: SlotDuration , 
0 commit comments