pub fn block_import<B, E, Block: BlockT<Hash=H256>, RA, PRA>(
	client: Arc<Client<B, E, Block, RA>>,
	api: Arc<PRA>
) -> Result<(GrandpaBlockImport<B, E, Block, RA, PRA>, LinkHalf<B, E, Block, RA>), ClientError>
	where
		B: Backend<Block, Blake2Hasher> + 'static,
		E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
		RA: Send + Sync,
		PRA: ProvideRuntimeApi,
		PRA::Api: GrandpaApi<Block>,
{
	use runtime_primitives::traits::Zero;

	let chain_info = client.info()?;
	let genesis_hash = chain_info.chain.genesis_hash;

	let persistent_data = aux_schema::load_persistent(
		&**client.backend(),
		genesis_hash,
		<NumberFor<Block>>::zero(),
		|| {
			let genesis_authorities = api.runtime_api()
				.grandpa_authorities(&BlockId::number(Zero::zero()))?;
			telemetry!(CONSENSUS_DEBUG; "afg.loading_authorities";
				"authorities_len" => ?genesis_authorities.len()
			);
			Ok(genesis_authorities)
		}
	)?;

	let (voter_commands_tx, voter_commands_rx) = mpsc::unbounded();

	Ok((
		GrandpaBlockImport::new(
			client.clone(),
			persistent_data.authority_set.clone(),
			voter_commands_tx,
			persistent_data.consensus_changes.clone(),
			api,
		),
		LinkHalf {
			client,
			persistent_data,
			voter_commands_rx,
		},
	))
}
/// Make block importer and link half necessary to tie the background voter
/// to it.
Make block importer and link half necessary to tie the background voter
to it.
Make block importer and link half necessary to tie the background voter to it .
pub fn block_import<B, E, Block: BlockT<Hash=H256>, RA, PRA>(
	client: Arc<Client<B, E, Block, RA>>,
	api: Arc<PRA>
) -> Result<(GrandpaBlockImport<B, E, Block, RA, PRA>, LinkHalf<B, E, Block, RA>), ClientError>
	where
		B: Backend<Block, Blake2Hasher> + 'static,
		E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
		RA: Send + Sync,
		PRA: ProvideRuntimeApi,
		PRA::Api: GrandpaApi<Block>,
{
	use runtime_primitives::traits::Zero;
	let chain_info = client.info()?;
	let genesis_hash = chain_info.chain.genesis_hash;
	let persistent_data = aux_schema::load_persistent(
		&**client.backend(),
		genesis_hash,
		<NumberFor<Block>>::zero(),
		|| {
			let genesis_authorities = api.runtime_api()
				.grandpa_authorities(&BlockId::number(Zero::zero()))?;
			telemetry!(CONSENSUS_DEBUG; "afg.loading_authorities";
				"authorities_len" => ?genesis_authorities.len()
			);
			Ok(genesis_authorities)
		}
	)?;
	let (voter_commands_tx, voter_commands_rx) = mpsc::unbounded();
	Ok((
		GrandpaBlockImport::new(
			client.clone(),
			persistent_data.authority_set.clone(),
			voter_commands_tx,
			persistent_data.consensus_changes.clone(),
			api,
		),
		LinkHalf {
			client,
			persistent_data,
			voter_commands_rx,
		},
	))
}
pub fn block_import < B , E , Block : BlockT < Hash = H256 > , RA , PRA > ( client : Arc < Client < B , E , Block , RA > > , api : Arc < PRA > ) -> Result < ( GrandpaBlockImport < B , E , Block , RA , PRA > , LinkHalf < B , E , Block , RA > ) , ClientError > where B : Backend < Block , Blake2Hasher > + ' static , E : CallExecutor < Block , Blake2Hasher > + ' static + Clone + Send + Sync , RA : Send + Sync , PRA : ProvideRuntimeApi , PRA :: Api : GrandpaApi < Block > , { use runtime_primitives :: traits :: Zero ; let chain_info = client . info ( ) ? ; let genesis_hash = chain_info . chain . genesis_hash ; let persistent_data = aux_schema :: load_persistent ( & * * client . backend ( ) , genesis_hash , < NumberFor < Block > > :: zero ( ) , | | { let genesis_authorities = api . runtime_api ( ) . grandpa_authorities ( & BlockId :: number ( Zero :: zero ( ) ) ) ? ; telemetry ! ( CONSENSUS_DEBUG " " " " genesis_authorities len ( ) ) ; Ok ( genesis_authorities ) } ) ? ; let ( voter_commands_tx , voter_commands_rx ) = mpsc :: unbounded ( ) ; Ok ( ( GrandpaBlockImport :: new ( client . clone ( ) , persistent_data . authority_set . clone ( ) , voter_commands_tx , persistent_data . consensus_changes . clone ( ) , api , ) , LinkHalf { client , persistent_data , voter_commands_rx , } , ) ) }
Make block importer and link half necessary to tie the background voter
to it.
Make block importer and link half necessary to tie the background voter to it .
client
Arc<Client<B, E, Block, RA>>
api
Arc<PRA>
client
Arc<Client<B, E, Block, RA>>
api
Arc<PRA>