pub fn build_offchain_workers<TBl, TBackend, TCl>(
	config: &Configuration,
	backend: Arc<TBackend>,
	spawn_handle: SpawnTaskHandle,
	client: Arc<TCl>,
	network: Arc<NetworkService<TBl, <TBl as BlockT>::Hash>>,
) -> Option<Arc<sc_offchain::OffchainWorkers<TCl, TBackend::OffchainStorage, TBl>>>
	where
		TBl: BlockT, TBackend: sc_client_api::Backend<TBl>,
		<TBackend as sc_client_api::Backend<TBl>>::OffchainStorage: 'static,
		TCl: Send + Sync + ProvideRuntimeApi<TBl> + BlockchainEvents<TBl> + 'static,
		<TCl as ProvideRuntimeApi<TBl>>::Api: sc_offchain::OffchainWorkerApi<TBl>,
{
	let offchain_workers = match backend.offchain_storage() {
		Some(db) => {
			Some(Arc::new(sc_offchain::OffchainWorkers::new(client.clone(), db)))
		},
		None => {
			warn!("Offchain workers disabled, due to lack of offchain storage support in backend.");
			None
		},
	};

	// Inform the offchain worker about new imported blocks
	if let Some(offchain) = offchain_workers.clone() {
		spawn_handle.spawn(
			"offchain-notifications",
			sc_offchain::notification_future(
				config.role.is_authority(),
				client.clone(),
				offchain,
				Clone::clone(&spawn_handle),
				network.clone(),
			)
		);
	}

	offchain_workers
}
/// Build a shared offchain workers instance.
Build a shared offchain workers instance.
Build a shared offchain workers instance .
pub fn build_offchain_workers<TBl, TBackend, TCl>(
	config: &Configuration,
	backend: Arc<TBackend>,
	spawn_handle: SpawnTaskHandle,
	client: Arc<TCl>,
	network: Arc<NetworkService<TBl, <TBl as BlockT>::Hash>>,
) -> Option<Arc<sc_offchain::OffchainWorkers<TCl, TBackend::OffchainStorage, TBl>>>
	where
		TBl: BlockT, TBackend: sc_client_api::Backend<TBl>,
		<TBackend as sc_client_api::Backend<TBl>>::OffchainStorage: 'static,
		TCl: Send + Sync + ProvideRuntimeApi<TBl> + BlockchainEvents<TBl> + 'static,
		<TCl as ProvideRuntimeApi<TBl>>::Api: sc_offchain::OffchainWorkerApi<TBl>,
{
	let offchain_workers = match backend.offchain_storage() {
		Some(db) => {
			Some(Arc::new(sc_offchain::OffchainWorkers::new(client.clone(), db)))
		},
		None => {
			warn!("Offchain workers disabled, due to lack of offchain storage support in backend.");
			None
		},
	};
	// Inform the offchain worker about new imported blocks
	if let Some(offchain) = offchain_workers.clone() {
		spawn_handle.spawn(
			"offchain-notifications",
			sc_offchain::notification_future(
				config.role.is_authority(),
				client.clone(),
				offchain,
				Clone::clone(&spawn_handle),
				network.clone(),
			)
		);
	}
	offchain_workers
}
pub fn build_offchain_workers < TBl , TBackend , TCl > ( config : & Configuration , backend : Arc < TBackend > , spawn_handle : SpawnTaskHandle , client : Arc < TCl > , network : Arc < NetworkService < TBl , < TBl as BlockT > :: Hash > > , ) -> Option < Arc < sc_offchain :: OffchainWorkers < TCl , TBackend :: OffchainStorage , TBl > > > where TBl : BlockT , TBackend : sc_client_api :: Backend < TBl > , < TBackend as sc_client_api :: Backend < TBl > > :: OffchainStorage : ' static , TCl : Send + Sync + ProvideRuntimeApi < TBl > + BlockchainEvents < TBl > + ' static , < TCl as ProvideRuntimeApi < TBl > > :: Api : sc_offchain :: OffchainWorkerApi < TBl > , { let offchain_workers = match backend . offchain_storage ( ) { Some ( db ) => { Some ( Arc :: new ( sc_offchain :: OffchainWorkers :: new ( client . clone ( ) , db ) ) ) } , None => { warn ! ( " " ) ; None } , } ; // Inform the offchain worker about new imported blocks if let Some ( offchain ) = offchain_workers . clone ( ) { spawn_handle . spawn ( " " , sc_offchain :: notification_future ( config . role . is_authority ( ) , client . clone ( ) , offchain , Clone :: clone ( & spawn_handle ) , network . clone ( ) , ) ) ; } offchain_workers }
Build a shared offchain workers instance.
Build a shared offchain workers instance .
config
&Configuration
backend
Arc<TBackend>
spawn_handle
SpawnTaskHandle
client
Arc<TCl>
network
Arc<NetworkService<TBl, <TBl as BlockT>::Hash>>
config
&Configuration
backend
Arc<TBackend>
spawn_handle
SpawnTaskHandle
client
Arc<TCl>
network
Arc<NetworkService<TBl, <TBl as BlockT>::Hash>>