mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Remove set_finality_proof_request_builder (#3087)
* Remove set_finality_proof_request_builder * Fix Babe * Fix Grandpa * Fix service doctests
This commit is contained in:
committed by
Bastian Köcher
parent
814b9056b3
commit
efed2e3098
@@ -130,7 +130,11 @@ pub fn import_blocks<F, E, R>(
|
||||
let client = new_client::<F>(&config)?;
|
||||
// FIXME #1134 this shouldn't need a mutable config.
|
||||
let select_chain = components::FullComponents::<F>::build_select_chain(&mut config, client.clone())?;
|
||||
let mut queue = components::FullComponents::<F>::build_import_queue(&mut config, client.clone(), select_chain)?;
|
||||
let (mut queue, _) = components::FullComponents::<F>::build_import_queue(
|
||||
&mut config,
|
||||
client.clone(),
|
||||
select_chain
|
||||
)?;
|
||||
|
||||
let (exit_send, exit_recv) = std::sync::mpsc::channel();
|
||||
::std::thread::spawn(move || {
|
||||
|
||||
@@ -23,7 +23,7 @@ use client_db;
|
||||
use client::{self, Client, runtime_api};
|
||||
use crate::{error, Service, AuthorityKeyProvider};
|
||||
use consensus_common::{import_queue::ImportQueue, SelectChain};
|
||||
use network::{self, OnDemand, FinalityProofProvider};
|
||||
use network::{self, OnDemand, FinalityProofProvider, config::BoxFinalityProofRequestBuilder};
|
||||
use substrate_executor::{NativeExecutor, NativeExecutionDispatch};
|
||||
use transaction_pool::txpool::{self, Options as TransactionPoolOptions, Pool as TransactionPool};
|
||||
use runtime_primitives::{
|
||||
@@ -356,7 +356,7 @@ pub trait ServiceFactory: 'static + Sized {
|
||||
fn build_light_import_queue(
|
||||
config: &mut FactoryFullConfiguration<Self>,
|
||||
_client: Arc<LightClient<Self>>
|
||||
) -> Result<Self::LightImportQueue, error::Error> {
|
||||
) -> Result<(Self::LightImportQueue, BoxFinalityProofRequestBuilder<Self::Block>), error::Error> {
|
||||
if let Some(name) = config.chain_spec.consensus_engine() {
|
||||
match name {
|
||||
_ => Err(format!("Chain Specification defines unknown consensus engine '{}'", name).into())
|
||||
@@ -407,12 +407,13 @@ pub trait Components: Sized + 'static {
|
||||
fn build_transaction_pool(config: TransactionPoolOptions, client: Arc<ComponentClient<Self>>)
|
||||
-> Result<TransactionPool<Self::TransactionPoolApi>, error::Error>;
|
||||
|
||||
/// instance of import queue for clients
|
||||
/// Build the queue that imports blocks from the network, and optionally a way for the network
|
||||
/// to build requests for proofs of finality.
|
||||
fn build_import_queue(
|
||||
config: &mut FactoryFullConfiguration<Self::Factory>,
|
||||
client: Arc<ComponentClient<Self>>,
|
||||
select_chain: Option<Self::SelectChain>,
|
||||
) -> Result<Self::ImportQueue, error::Error>;
|
||||
) -> Result<(Self::ImportQueue, Option<BoxFinalityProofRequestBuilder<FactoryBlock<Self::Factory>>>), error::Error>;
|
||||
|
||||
/// Finality proof provider for serving network requests.
|
||||
fn build_finality_proof_provider(
|
||||
@@ -513,10 +514,11 @@ impl<Factory: ServiceFactory> Components for FullComponents<Factory> {
|
||||
config: &mut FactoryFullConfiguration<Self::Factory>,
|
||||
client: Arc<ComponentClient<Self>>,
|
||||
select_chain: Option<Self::SelectChain>,
|
||||
) -> Result<Self::ImportQueue, error::Error> {
|
||||
) -> Result<(Self::ImportQueue, Option<BoxFinalityProofRequestBuilder<FactoryBlock<Self::Factory>>>), error::Error> {
|
||||
let select_chain = select_chain
|
||||
.ok_or(error::Error::SelectChainRequired)?;
|
||||
Factory::build_full_import_queue(config, client, select_chain)
|
||||
.map(|queue| (queue, None))
|
||||
}
|
||||
|
||||
fn build_select_chain(
|
||||
@@ -615,8 +617,9 @@ impl<Factory: ServiceFactory> Components for LightComponents<Factory> {
|
||||
config: &mut FactoryFullConfiguration<Self::Factory>,
|
||||
client: Arc<ComponentClient<Self>>,
|
||||
_select_chain: Option<Self::SelectChain>,
|
||||
) -> Result<Self::ImportQueue, error::Error> {
|
||||
) -> Result<(Self::ImportQueue, Option<BoxFinalityProofRequestBuilder<FactoryBlock<Self::Factory>>>), error::Error> {
|
||||
Factory::build_light_import_queue(config, client)
|
||||
.map(|(queue, builder)| (queue, Some(builder)))
|
||||
}
|
||||
|
||||
fn build_finality_proof_provider(
|
||||
|
||||
@@ -65,7 +65,7 @@ use components::{StartRPC, MaintainTransactionPool, OffchainWorker};
|
||||
#[doc(hidden)]
|
||||
pub use std::{ops::Deref, result::Result, sync::Arc};
|
||||
#[doc(hidden)]
|
||||
pub use network::{FinalityProofProvider, OnDemand};
|
||||
pub use network::{FinalityProofProvider, OnDemand, config::BoxFinalityProofRequestBuilder};
|
||||
#[doc(hidden)]
|
||||
pub use futures::future::Executor;
|
||||
|
||||
@@ -205,11 +205,12 @@ impl<Components: components::Components> Service<Components> {
|
||||
|
||||
let (client, on_demand) = Components::build_client(&config, executor)?;
|
||||
let select_chain = Components::build_select_chain(&mut config, client.clone())?;
|
||||
let import_queue = Box::new(Components::build_import_queue(
|
||||
let (import_queue, finality_proof_request_builder) = Components::build_import_queue(
|
||||
&mut config,
|
||||
client.clone(),
|
||||
select_chain.clone(),
|
||||
)?);
|
||||
)?;
|
||||
let import_queue = Box::new(import_queue);
|
||||
let finality_proof_provider = Components::build_finality_proof_provider(client.clone())?;
|
||||
let chain_info = client.info().chain;
|
||||
|
||||
@@ -248,6 +249,7 @@ impl<Components: components::Components> Service<Components> {
|
||||
network_config: config.network.clone(),
|
||||
chain: client.clone(),
|
||||
finality_proof_provider,
|
||||
finality_proof_request_builder,
|
||||
on_demand,
|
||||
transaction_pool: transaction_pool_adapter.clone() as _,
|
||||
import_queue,
|
||||
@@ -913,7 +915,7 @@ impl offchain::AuthorityKeyProvider for AuthorityKeyProvider {
|
||||
/// # FullComponents, LightComponents, FactoryFullConfiguration, FullClient
|
||||
/// # };
|
||||
/// # use transaction_pool::{self, txpool::{Pool as TransactionPool}};
|
||||
/// # use network::construct_simple_protocol;
|
||||
/// # use network::{config::DummyFinalityProofRequestBuilder, construct_simple_protocol};
|
||||
/// # use client::{self, LongestChain};
|
||||
/// # use consensus_common::import_queue::{BasicQueue, Verifier};
|
||||
/// # use consensus_common::{BlockOrigin, ImportBlock, well_known_cache_keys::Id as CacheKeyId};
|
||||
@@ -967,9 +969,12 @@ impl offchain::AuthorityKeyProvider for AuthorityKeyProvider {
|
||||
/// LightService = LightComponents<Self>
|
||||
/// { |config| <LightComponents<Factory>>::new(config) },
|
||||
/// FullImportQueue = BasicQueue<Block>
|
||||
/// { |_, client, _| Ok(BasicQueue::new(Arc::new(MyVerifier), Box::new(client), None, None, None)) },
|
||||
/// { |_, client, _| Ok(BasicQueue::new(Arc::new(MyVerifier), Box::new(client), None, None)) },
|
||||
/// LightImportQueue = BasicQueue<Block>
|
||||
/// { |_, client| Ok(BasicQueue::new(Arc::new(MyVerifier), Box::new(client), None, None, None)) },
|
||||
/// { |_, client| {
|
||||
/// let fprb = Box::new(DummyFinalityProofRequestBuilder::default()) as Box<_>;
|
||||
/// Ok((BasicQueue::new(Arc::new(MyVerifier), Box::new(client), None, None), fprb))
|
||||
/// }},
|
||||
/// SelectChain = LongestChain<FullBackend<Self>, Self::Block>
|
||||
/// { |config: &FactoryFullConfiguration<Self>, client: Arc<FullClient<Self>>| {
|
||||
/// #[allow(deprecated)]
|
||||
@@ -1065,7 +1070,7 @@ macro_rules! construct_service_factory {
|
||||
fn build_light_import_queue(
|
||||
config: &mut FactoryFullConfiguration<Self>,
|
||||
client: Arc<$crate::LightClient<Self>>,
|
||||
) -> Result<Self::LightImportQueue, $crate::Error> {
|
||||
) -> Result<(Self::LightImportQueue, $crate::BoxFinalityProofRequestBuilder<$block>), $crate::Error> {
|
||||
( $( $light_import_queue_init )* ) (config, client)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user