Repository: paritytech/substrate
File: client/consensus/manual-seal/src/lib.rs (Rust)

Code before:
{
	// Creates and finalizes blocks as soon as transactions are imported
	// into the transaction pool.
	let commands_stream = pool.import_notification_stream().map(|_| EngineCommand::SealNewBlock {
		create_empty: false,
		finalize: true,
		parent_hash: None,
		sender: None,
	});

	run_manual_seal(ManualSealParams {
		block_import,
		env,
		client,
		pool,
		commands_stream,
		select_chain,
		consensus_data_provider,
		create_inherent_data_providers,
	})
	.await
}

/// Creates a future for delayed finalization of manual sealed blocks.
///
/// The future needs to be spawned in the background alongside the
/// [`run_manual_seal`]/[`run_instant_seal`] future. It is required that
/// [`EngineCommand::SealNewBlock`] is send with `finalize = false` to not finalize blocks directly
/// after building them. This also means that delayed finality can not be used with
/// [`run_instant_seal_and_finalize`].
pub async fn run_delayed_finalize<B, CB, C, S>(
	DelayedFinalizeParams { client, spawn_handle, delay_sec }: DelayedFinalizeParams<C, S>,
) where
	B: BlockT + 'static,
	CB: ClientBackend<B> + 'static,
	C: HeaderBackend<B> + Finalizer<B, CB> + ProvideRuntimeApi<B> + BlockchainEvents<B> + 'static,
	S: SpawnNamed,
{
	let mut block_import_stream = client.import_notification_stream();

	while let Some(notification) = block_import_stream.next().await {
		let delay = Delay::new(Duration::from_secs(delay_sec));
		let cloned_client = client.clone();
		spawn_handle.spawn(
			"delayed-finalize",
			None,
			Box::pin(async move {
				delay.await;
				finalize_block(FinalizeBlockParams {
					hash: notification.hash,
					sender: None,

Review comment (suggestion):
```suggestion
/// Creates a future for delayed finalization of manually sealed blocks.
```

Code after:
	CIDP: CreateInherentDataProviders<B, ()>,
	P: Send + Sync + 'static,
{
	// Creates and finalizes blocks as soon as transactions are imported
	// into the transaction pool.
	let commands_stream = pool.import_notification_stream().map(|_| EngineCommand::SealNewBlock {
		create_empty: false,
		finalize: true,
		parent_hash: None,
		sender: None,
	});

	run_manual_seal(ManualSealParams {
		block_import,
		env,
		client,
		pool,
		commands_stream,
		select_chain,
		consensus_data_provider,
		create_inherent_data_providers,
	})
	.await
}

/// Creates a future for delayed finalization of manual sealed blocks.
///
/// The future needs to be spawned in the background alongside the
/// [`run_manual_seal`]/[`run_instant_seal`] future. It is required that
/// [`EngineCommand::SealNewBlock`] is send with `finalize = false` to not finalize blocks directly
/// after building them. This also means that delayed finality can not be used with
/// [`run_instant_seal_and_finalize`].
pub async fn run_delayed_finalize<B, CB, C, S>(
	DelayedFinalizeParams { client, spawn_handle, delay_sec }: DelayedFinalizeParams<C, S>,
) where
	B: BlockT + 'static,
	CB: ClientBackend<B> + 'static,
	C: HeaderBackend<B> + Finalizer<B, CB> + ProvideRuntimeApi<B> + BlockchainEvents<B> + 'static,
	S: SpawnNamed,
{
	let mut block_import_stream = client.import_notification_stream();

	while let Some(notification) = block_import_stream.next().await {
		let delay = Delay::new(Duration::from_secs(delay_sec));
		let cloned_client = client.clone();
		spawn_handle.spawn(
			"delayed-finalize",
			None,
			Box::pin(async move {
				delay.await;
				finalize_block(FinalizeBlockParams {