mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
Remove the service builder (#6557)
* :) * Slight tidy * Remove ServiceBuilderCommand * Remove whitespace * Keep task manager alive for check_block/import_blocks * Pass task_manager to run_until_exit * WIP * WIP * Get rid of the macros * Simplify a few chain components creation APIs related to the service * Fix basic-authorship doc tests * Remove DefaultQueue * Update client/service/src/builder.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Move ExecutionExtensions comment around * Remove unused BlakeTwo256 * Add sc-prelude * Rename sc-prelude to sc-service-prelude * Rename to sc-service-types * Improve service types * Fix line widths * Remove sc-service-types and move type definitions to crates * Update bin/node-template/node/src/service.rs Co-authored-by: Seun Lanlege <seunlanlege@gmail.com> * Add TLightClientWithHash * Rework types Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: Seun Lanlege <seunlanlege@gmail.com>
This commit is contained in:
Generated
+1
@@ -3702,6 +3702,7 @@ dependencies = [
|
||||
"sc-finality-grandpa",
|
||||
"sc-finality-grandpa-rpc",
|
||||
"sc-keystore",
|
||||
"sc-rpc",
|
||||
"sc-rpc-api",
|
||||
"sp-api",
|
||||
"sp-block-builder",
|
||||
|
||||
@@ -19,6 +19,8 @@ use crate::chain_spec;
|
||||
use crate::cli::Cli;
|
||||
use crate::service;
|
||||
use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec};
|
||||
use sc_service::ServiceParams;
|
||||
use crate::service::new_full_params;
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
@@ -68,8 +70,9 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
Some(subcommand) => {
|
||||
let runner = cli.create_runner(subcommand)?;
|
||||
runner.run_subcommand(subcommand, |config| {
|
||||
let (builder, _, _) = new_full_start!(config);
|
||||
Ok(builder.to_chain_ops_parts())
|
||||
let (ServiceParams { client, backend, task_manager, import_queue, .. }, ..)
|
||||
= new_full_params(config)?;
|
||||
Ok((client, backend, import_queue, task_manager))
|
||||
})
|
||||
}
|
||||
None => {
|
||||
|
||||
@@ -2,13 +2,9 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use sc_client_api::ExecutorProvider;
|
||||
use sc_consensus::LongestChain;
|
||||
use node_template_runtime::{self, opaque::Block, RuntimeApi};
|
||||
use sc_service::{
|
||||
error::{Error as ServiceError}, Configuration, ServiceBuilder, ServiceComponents,
|
||||
TaskManager,
|
||||
};
|
||||
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
||||
use node_template_runtime::{self, Block, RuntimeApi};
|
||||
use sc_service::{error::Error as ServiceError, Configuration, ServiceComponents, TaskManager};
|
||||
use sp_inherents::InherentDataProviders;
|
||||
use sc_executor::native_executor_instance;
|
||||
pub use sc_executor::NativeExecutor;
|
||||
@@ -24,103 +20,110 @@ native_executor_instance!(
|
||||
node_template_runtime::native_version,
|
||||
);
|
||||
|
||||
/// Starts a `ServiceBuilder` for a full service.
|
||||
///
|
||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||
/// be able to perform chain operations.
|
||||
macro_rules! new_full_start {
|
||||
($config:expr) => {{
|
||||
use std::sync::Arc;
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
|
||||
let mut import_setup = None;
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
pub fn new_full_params(config: Configuration) -> Result<(
|
||||
sc_service::ServiceParams<
|
||||
Block, FullClient,
|
||||
sc_consensus_aura::AuraImportQueue<Block, FullClient>,
|
||||
sc_transaction_pool::FullPool<Block, FullClient>,
|
||||
(), FullBackend,
|
||||
>,
|
||||
FullSelectChain,
|
||||
sp_inherents::InherentDataProviders,
|
||||
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
|
||||
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>
|
||||
), ServiceError> {
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let builder = sc_service::ServiceBuilder::new_full::<
|
||||
node_template_runtime::opaque::Block,
|
||||
node_template_runtime::RuntimeApi,
|
||||
crate::service::Executor
|
||||
>($config)?
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(sc_consensus::LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|builder| {
|
||||
let pool_api = sc_transaction_pool::FullChainApi::new(
|
||||
builder.client().clone(),
|
||||
None,
|
||||
);
|
||||
Ok(sc_transaction_pool::BasicPool::new_full(
|
||||
builder.config().transaction_pool.clone(),
|
||||
std::sync::Arc::new(pool_api),
|
||||
builder.prometheus_registry(),
|
||||
builder.spawn_handle(),
|
||||
builder.client().clone(),
|
||||
))
|
||||
})?
|
||||
.with_import_queue(|
|
||||
_config,
|
||||
client,
|
||||
mut select_chain,
|
||||
_transaction_pool,
|
||||
spawn_task_handle,
|
||||
registry,
|
||||
| {
|
||||
let select_chain = select_chain.take()
|
||||
.ok_or_else(|| sc_service::Error::SelectChainRequired)?;
|
||||
let (client, backend, keystore, task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import(
|
||||
client.clone(),
|
||||
&(client.clone() as Arc<_>),
|
||||
select_chain,
|
||||
)?;
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
|
||||
grandpa_block_import.clone(), client.clone(),
|
||||
);
|
||||
let pool_api = sc_transaction_pool::FullChainApi::new(
|
||||
client.clone(), config.prometheus_registry(),
|
||||
);
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
||||
config.transaction_pool.clone(),
|
||||
std::sync::Arc::new(pool_api),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
);
|
||||
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
aura_block_import,
|
||||
Some(Box::new(grandpa_block_import.clone())),
|
||||
None,
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
spawn_task_handle,
|
||||
registry,
|
||||
)?;
|
||||
let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import(
|
||||
client.clone(), &(client.clone() as Arc<_>), select_chain.clone(),
|
||||
)?;
|
||||
|
||||
import_setup = Some((grandpa_block_import, grandpa_link));
|
||||
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
|
||||
grandpa_block_import.clone(), client.clone(),
|
||||
);
|
||||
|
||||
Ok(import_queue)
|
||||
})?;
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
aura_block_import,
|
||||
Some(Box::new(grandpa_block_import.clone())),
|
||||
None,
|
||||
client.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
&task_manager.spawn_handle(),
|
||||
config.prometheus_registry(),
|
||||
)?;
|
||||
|
||||
(builder, import_setup, inherent_data_providers)
|
||||
}}
|
||||
let provider = client.clone() as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||
let finality_proof_provider =
|
||||
Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider));
|
||||
|
||||
let params = sc_service::ServiceParams {
|
||||
backend, client, import_queue, keystore, task_manager, transaction_pool,
|
||||
config,
|
||||
block_announce_validator_builder: None,
|
||||
finality_proof_request_builder: None,
|
||||
finality_proof_provider: Some(finality_proof_provider),
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
rpc_extensions_builder: Box::new(|_| ()),
|
||||
};
|
||||
|
||||
Ok((
|
||||
params, select_chain, inherent_data_providers,
|
||||
grandpa_block_import, grandpa_link,
|
||||
))
|
||||
}
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let role = config.role.clone();
|
||||
let force_authoring = config.force_authoring;
|
||||
let name = config.network.node_name.clone();
|
||||
let disable_grandpa = config.disable_grandpa;
|
||||
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let (
|
||||
params, select_chain, inherent_data_providers,
|
||||
block_import, grandpa_link,
|
||||
) = new_full_params(config)?;
|
||||
|
||||
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
|
||||
let (
|
||||
role, force_authoring, name, enable_grandpa, prometheus_registry,
|
||||
client, transaction_pool, keystore,
|
||||
) = {
|
||||
let sc_service::ServiceParams {
|
||||
config, client, transaction_pool, keystore, ..
|
||||
} = ¶ms;
|
||||
|
||||
let (block_import, grandpa_link) =
|
||||
import_setup.take()
|
||||
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
||||
(
|
||||
config.role.clone(),
|
||||
config.force_authoring,
|
||||
config.network.node_name.clone(),
|
||||
!config.disable_grandpa,
|
||||
config.prometheus_registry().cloned(),
|
||||
|
||||
client.clone(), transaction_pool.clone(), keystore.clone(),
|
||||
)
|
||||
};
|
||||
|
||||
let ServiceComponents {
|
||||
client, transaction_pool, task_manager, keystore, network, select_chain,
|
||||
prometheus_registry, telemetry_on_connect_sinks, ..
|
||||
} = builder
|
||||
.with_finality_proof_provider(|client, backend| {
|
||||
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
||||
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
|
||||
})?
|
||||
.build_full()?;
|
||||
task_manager, network, telemetry_on_connect_sinks, ..
|
||||
} = sc_service::build(params)?;
|
||||
|
||||
if role.is_authority() {
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
@@ -129,9 +132,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
prometheus_registry.as_ref(),
|
||||
);
|
||||
|
||||
let select_chain = select_chain
|
||||
.ok_or(ServiceError::SelectChainRequired)?;
|
||||
|
||||
let can_author_with =
|
||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
|
||||
@@ -171,7 +171,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
is_authority: role.is_network_authority(),
|
||||
};
|
||||
|
||||
let enable_grandpa = !disable_grandpa;
|
||||
if enable_grandpa {
|
||||
// start the full GRANDPA voter
|
||||
// NOTE: non-authorities could run the GRANDPA observer protocol, but at
|
||||
@@ -209,69 +208,49 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
|
||||
/// Builds a new service for a light client.
|
||||
pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let inherent_data_providers = InherentDataProviders::new();
|
||||
let (client, backend, keystore, task_manager, on_demand) =
|
||||
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
|
||||
let transaction_pool_api = Arc::new(sc_transaction_pool::LightChainApi::new(
|
||||
client.clone(), on_demand.clone(),
|
||||
));
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_light(
|
||||
config.transaction_pool.clone(),
|
||||
transaction_pool_api,
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
);
|
||||
|
||||
ServiceBuilder::new_light::<Block, RuntimeApi, Executor>(config)?
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|builder| {
|
||||
let fetcher = builder.fetcher()
|
||||
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
|
||||
let grandpa_block_import = sc_finality_grandpa::light_block_import(
|
||||
client.clone(), backend.clone(), &(client.clone() as Arc<_>),
|
||||
Arc::new(on_demand.checker().clone()) as Arc<_>,
|
||||
)?;
|
||||
let finality_proof_import = grandpa_block_import.clone();
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
let pool_api = sc_transaction_pool::LightChainApi::new(
|
||||
builder.client().clone(),
|
||||
fetcher,
|
||||
);
|
||||
let pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
|
||||
builder.config().transaction_pool.clone(),
|
||||
Arc::new(pool_api),
|
||||
builder.prometheus_registry(),
|
||||
builder.spawn_handle(),
|
||||
));
|
||||
Ok(pool)
|
||||
})?
|
||||
.with_import_queue_and_fprb(|
|
||||
_config,
|
||||
client,
|
||||
backend,
|
||||
fetcher,
|
||||
_select_chain,
|
||||
_tx_pool,
|
||||
spawn_task_handle,
|
||||
prometheus_registry,
|
||||
| {
|
||||
let fetch_checker = fetcher
|
||||
.map(|fetcher| fetcher.checker().clone())
|
||||
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
||||
let grandpa_block_import = sc_finality_grandpa::light_block_import(
|
||||
client.clone(),
|
||||
backend,
|
||||
&(client.clone() as Arc<_>),
|
||||
Arc::new(fetch_checker),
|
||||
)?;
|
||||
let finality_proof_import = grandpa_block_import.clone();
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
grandpa_block_import,
|
||||
None,
|
||||
Some(Box::new(finality_proof_import)),
|
||||
client.clone(),
|
||||
InherentDataProviders::new(),
|
||||
&task_manager.spawn_handle(),
|
||||
config.prometheus_registry(),
|
||||
)?;
|
||||
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
grandpa_block_import,
|
||||
None,
|
||||
Some(Box::new(finality_proof_import)),
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
spawn_task_handle,
|
||||
prometheus_registry,
|
||||
)?;
|
||||
let finality_proof_provider =
|
||||
Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), client.clone() as Arc<_>));
|
||||
|
||||
Ok((import_queue, finality_proof_request_builder))
|
||||
})?
|
||||
.with_finality_proof_provider(|client, backend| {
|
||||
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
||||
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
|
||||
})?
|
||||
.build_light()
|
||||
.map(|ServiceComponents { task_manager, .. }| task_manager)
|
||||
sc_service::build(sc_service::ServiceParams {
|
||||
block_announce_validator_builder: None,
|
||||
finality_proof_request_builder: Some(finality_proof_request_builder),
|
||||
finality_proof_provider: Some(finality_proof_provider),
|
||||
on_demand: Some(on_demand),
|
||||
remote_blockchain: Some(backend.remote_blockchain()),
|
||||
rpc_extensions_builder: Box::new(|_| ()),
|
||||
transaction_pool: Arc::new(transaction_pool),
|
||||
config, client, import_queue, keystore, backend, task_manager
|
||||
}).map(|ServiceComponents { task_manager, .. }| task_manager)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ use crate::{chain_spec, service, Cli, Subcommand};
|
||||
use node_executor::Executor;
|
||||
use node_runtime::{Block, RuntimeApi};
|
||||
use sc_cli::{Result, SubstrateCli, RuntimeVersion, Role, ChainSpec};
|
||||
use sc_service::ServiceParams;
|
||||
use crate::service::new_full_params;
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
@@ -94,8 +96,9 @@ pub fn run() -> Result<()> {
|
||||
Some(Subcommand::Base(subcommand)) => {
|
||||
let runner = cli.create_runner(subcommand)?;
|
||||
runner.run_subcommand(subcommand, |config| {
|
||||
let (builder, _, _, _) = new_full_start!(config);
|
||||
Ok(builder.to_chain_ops_parts())
|
||||
let (ServiceParams { client, backend, import_queue, task_manager, .. }, ..)
|
||||
= new_full_params(config)?;
|
||||
Ok((client, backend, import_queue, task_manager))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,184 +25,183 @@ use sc_consensus_babe;
|
||||
use grandpa::{
|
||||
self, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider,
|
||||
};
|
||||
use node_executor;
|
||||
use node_primitives::Block;
|
||||
use node_runtime::RuntimeApi;
|
||||
use sc_service::{
|
||||
ServiceBuilder, config::{Role, Configuration}, error::{Error as ServiceError},
|
||||
config::{Role, Configuration}, error::{Error as ServiceError},
|
||||
RpcHandlers, ServiceComponents, TaskManager,
|
||||
};
|
||||
use sp_inherents::InherentDataProviders;
|
||||
use sc_consensus::LongestChain;
|
||||
use sc_network::{Event, NetworkService};
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use futures::prelude::*;
|
||||
use sc_client_api::ExecutorProvider;
|
||||
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
||||
use sp_core::traits::BareCryptoStorePtr;
|
||||
use node_executor::Executor;
|
||||
|
||||
/// Starts a `ServiceBuilder` for a full service.
|
||||
///
|
||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||
/// be able to perform chain operations.
|
||||
macro_rules! new_full_start {
|
||||
($config:expr) => {{
|
||||
use std::sync::Arc;
|
||||
|
||||
let mut import_setup = None;
|
||||
let mut rpc_setup = None;
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let builder = sc_service::ServiceBuilder::new_full::<
|
||||
node_primitives::Block, node_runtime::RuntimeApi, node_executor::Executor
|
||||
>($config)?
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(sc_consensus::LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|builder| {
|
||||
let pool_api = sc_transaction_pool::FullChainApi::new(
|
||||
builder.client().clone(),
|
||||
builder.prometheus_registry(),
|
||||
);
|
||||
Ok(sc_transaction_pool::BasicPool::new_full(
|
||||
builder.config().transaction_pool.clone(),
|
||||
std::sync::Arc::new(pool_api),
|
||||
builder.prometheus_registry(),
|
||||
builder.spawn_handle(),
|
||||
builder.client().clone(),
|
||||
))
|
||||
})?
|
||||
.with_import_queue(|
|
||||
_config,
|
||||
client,
|
||||
mut select_chain,
|
||||
_transaction_pool,
|
||||
spawn_task_handle,
|
||||
prometheus_registry,
|
||||
| {
|
||||
let select_chain = select_chain.take()
|
||||
.ok_or_else(|| sc_service::Error::SelectChainRequired)?;
|
||||
let (grandpa_block_import, grandpa_link) = grandpa::block_import(
|
||||
client.clone(),
|
||||
&(client.clone() as Arc<_>),
|
||||
select_chain.clone(),
|
||||
)?;
|
||||
let justification_import = grandpa_block_import.clone();
|
||||
|
||||
let (block_import, babe_link) = sc_consensus_babe::block_import(
|
||||
sc_consensus_babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
)?;
|
||||
|
||||
let import_queue = sc_consensus_babe::import_queue(
|
||||
babe_link.clone(),
|
||||
block_import.clone(),
|
||||
Some(Box::new(justification_import)),
|
||||
None,
|
||||
client,
|
||||
select_chain,
|
||||
inherent_data_providers.clone(),
|
||||
spawn_task_handle,
|
||||
prometheus_registry,
|
||||
)?;
|
||||
|
||||
import_setup = Some((block_import, grandpa_link, babe_link));
|
||||
Ok(import_queue)
|
||||
})?
|
||||
.with_rpc_extensions_builder(|builder| {
|
||||
let grandpa_link = import_setup.as_ref().map(|s| &s.1)
|
||||
.expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");
|
||||
|
||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
let shared_voter_state = grandpa::SharedVoterState::empty();
|
||||
|
||||
rpc_setup = Some((shared_voter_state.clone()));
|
||||
|
||||
let babe_link = import_setup.as_ref().map(|s| &s.2)
|
||||
.expect("BabeLink is present for full services or set up failed; qed.");
|
||||
|
||||
let babe_config = babe_link.config().clone();
|
||||
let shared_epoch_changes = babe_link.epoch_changes().clone();
|
||||
|
||||
let client = builder.client().clone();
|
||||
let pool = builder.pool().clone();
|
||||
let select_chain = builder.select_chain().cloned()
|
||||
.expect("SelectChain is present for full services or set up failed; qed.");
|
||||
let keystore = builder.keystore().clone();
|
||||
|
||||
Ok(move |deny_unsafe| {
|
||||
let deps = node_rpc::FullDeps {
|
||||
client: client.clone(),
|
||||
pool: pool.clone(),
|
||||
select_chain: select_chain.clone(),
|
||||
deny_unsafe,
|
||||
babe: node_rpc::BabeDeps {
|
||||
babe_config: babe_config.clone(),
|
||||
shared_epoch_changes: shared_epoch_changes.clone(),
|
||||
keystore: keystore.clone(),
|
||||
},
|
||||
grandpa: node_rpc::GrandpaDeps {
|
||||
shared_voter_state: shared_voter_state.clone(),
|
||||
shared_authority_set: shared_authority_set.clone(),
|
||||
},
|
||||
};
|
||||
|
||||
node_rpc::create_full(deps)
|
||||
})
|
||||
})?;
|
||||
|
||||
(builder, import_setup, inherent_data_providers, rpc_setup)
|
||||
}}
|
||||
}
|
||||
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, node_executor::Executor>;
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
type GrandpaBlockImport = grandpa::GrandpaBlockImport<
|
||||
FullBackend, Block, FullClient, sc_consensus::LongestChain<FullBackend, Block>
|
||||
>;
|
||||
type BabeBlockImport = sc_consensus_babe::BabeBlockImport<Block, FullClient, GrandpaBlockImport>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
type FullGrandpaBlockImport =
|
||||
grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>;
|
||||
type LightClient = sc_service::TLightClient<Block, RuntimeApi, Executor>;
|
||||
|
||||
pub fn new_full_params(config: Configuration) -> Result<(
|
||||
sc_service::ServiceParams<
|
||||
Block, FullClient,
|
||||
sc_consensus_babe::BabeImportQueue<Block, FullClient>,
|
||||
sc_transaction_pool::FullPool<Block, FullClient>, node_rpc::IoHandler,
|
||||
FullBackend
|
||||
>,
|
||||
(
|
||||
sc_consensus_babe::BabeBlockImport<Block, FullClient, FullGrandpaBlockImport>,
|
||||
grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||
sc_consensus_babe::BabeLink<Block>,
|
||||
),
|
||||
grandpa::SharedVoterState,
|
||||
FullSelectChain,
|
||||
InherentDataProviders
|
||||
), ServiceError> {
|
||||
let (client, backend, keystore, task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let pool_api = sc_transaction_pool::FullChainApi::new(
|
||||
client.clone(), config.prometheus_registry(),
|
||||
);
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
||||
config.transaction_pool.clone(),
|
||||
std::sync::Arc::new(pool_api),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
);
|
||||
|
||||
let (grandpa_block_import, grandpa_link) = grandpa::block_import(
|
||||
client.clone(), &(client.clone() as Arc<_>), select_chain.clone(),
|
||||
)?;
|
||||
let justification_import = grandpa_block_import.clone();
|
||||
|
||||
let (block_import, babe_link) = sc_consensus_babe::block_import(
|
||||
sc_consensus_babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
)?;
|
||||
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let import_queue = sc_consensus_babe::import_queue(
|
||||
babe_link.clone(),
|
||||
block_import.clone(),
|
||||
Some(Box::new(justification_import)),
|
||||
None,
|
||||
client.clone(),
|
||||
select_chain.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
&task_manager.spawn_handle(),
|
||||
config.prometheus_registry(),
|
||||
)?;
|
||||
|
||||
let import_setup = (block_import, grandpa_link, babe_link);
|
||||
|
||||
let (rpc_extensions_builder, rpc_setup) = {
|
||||
let (_, grandpa_link, babe_link) = &import_setup;
|
||||
|
||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
let shared_voter_state = grandpa::SharedVoterState::empty();
|
||||
|
||||
let rpc_setup = shared_voter_state.clone();
|
||||
|
||||
let babe_config = babe_link.config().clone();
|
||||
let shared_epoch_changes = babe_link.epoch_changes().clone();
|
||||
|
||||
let client = client.clone();
|
||||
let pool = transaction_pool.clone();
|
||||
let select_chain = select_chain.clone();
|
||||
let keystore = keystore.clone();
|
||||
|
||||
let rpc_extensions_builder = Box::new(move |deny_unsafe| {
|
||||
let deps = node_rpc::FullDeps {
|
||||
client: client.clone(),
|
||||
pool: pool.clone(),
|
||||
select_chain: select_chain.clone(),
|
||||
deny_unsafe,
|
||||
babe: node_rpc::BabeDeps {
|
||||
babe_config: babe_config.clone(),
|
||||
shared_epoch_changes: shared_epoch_changes.clone(),
|
||||
keystore: keystore.clone(),
|
||||
},
|
||||
grandpa: node_rpc::GrandpaDeps {
|
||||
shared_voter_state: shared_voter_state.clone(),
|
||||
shared_authority_set: shared_authority_set.clone(),
|
||||
},
|
||||
};
|
||||
|
||||
node_rpc::create_full(deps)
|
||||
});
|
||||
|
||||
(rpc_extensions_builder, rpc_setup)
|
||||
};
|
||||
|
||||
let provider = client.clone() as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
|
||||
let finality_proof_provider =
|
||||
Arc::new(grandpa::FinalityProofProvider::new(backend.clone(), provider));
|
||||
|
||||
let params = sc_service::ServiceParams {
|
||||
config, backend, client, import_queue, keystore, task_manager, rpc_extensions_builder,
|
||||
transaction_pool,
|
||||
block_announce_validator_builder: None,
|
||||
finality_proof_request_builder: None,
|
||||
finality_proof_provider: Some(finality_proof_provider),
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
};
|
||||
|
||||
Ok((params, import_setup, rpc_setup, select_chain, inherent_data_providers))
|
||||
}
|
||||
|
||||
/// Creates a full service from the configuration.
|
||||
pub fn new_full_base(
|
||||
config: Configuration,
|
||||
with_startup_data: impl FnOnce(&BabeBlockImport, &sc_consensus_babe::BabeLink<Block>)
|
||||
with_startup_data: impl FnOnce(
|
||||
&sc_consensus_babe::BabeBlockImport<Block, FullClient, FullGrandpaBlockImport>,
|
||||
&sc_consensus_babe::BabeLink<Block>,
|
||||
)
|
||||
) -> Result<(
|
||||
TaskManager,
|
||||
InherentDataProviders,
|
||||
Arc<FullClient>, Arc<NetworkService<Block, <Block as BlockT>::Hash>>,
|
||||
Arc<sc_transaction_pool::BasicPool<sc_transaction_pool::FullChainApi<FullClient, Block>, Block>>
|
||||
TaskManager, InherentDataProviders, Arc<FullClient>,
|
||||
Arc<NetworkService<Block, <Block as BlockT>::Hash>>,
|
||||
Arc<sc_transaction_pool::FullPool<Block, FullClient>>,
|
||||
), ServiceError> {
|
||||
let (
|
||||
role,
|
||||
force_authoring,
|
||||
name,
|
||||
disable_grandpa,
|
||||
) = (
|
||||
config.role.clone(),
|
||||
config.force_authoring,
|
||||
config.network.node_name.clone(),
|
||||
config.disable_grandpa,
|
||||
);
|
||||
let (params, import_setup, rpc_setup, select_chain, inherent_data_providers)
|
||||
= new_full_params(config)?;
|
||||
|
||||
let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) =
|
||||
new_full_start!(config);
|
||||
let (
|
||||
role, force_authoring, name, enable_grandpa, prometheus_registry,
|
||||
client, transaction_pool, keystore,
|
||||
) = {
|
||||
let sc_service::ServiceParams {
|
||||
config, client, transaction_pool, keystore, ..
|
||||
} = ¶ms;
|
||||
|
||||
(
|
||||
config.role.clone(),
|
||||
config.force_authoring,
|
||||
config.network.node_name.clone(),
|
||||
!config.disable_grandpa,
|
||||
config.prometheus_registry().cloned(),
|
||||
|
||||
client.clone(), transaction_pool.clone(), keystore.clone(),
|
||||
)
|
||||
};
|
||||
|
||||
let ServiceComponents {
|
||||
client, transaction_pool, task_manager, keystore, network, select_chain,
|
||||
prometheus_registry, telemetry_on_connect_sinks, ..
|
||||
} = builder
|
||||
.with_finality_proof_provider(|client, backend| {
|
||||
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
||||
let provider = client as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
|
||||
Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, provider)) as _)
|
||||
})?
|
||||
.build_full()?;
|
||||
|
||||
let (block_import, grandpa_link, babe_link) = import_setup.take()
|
||||
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
||||
|
||||
let shared_voter_state = rpc_setup.take()
|
||||
.expect("The SharedVoterState is present for Full Services or setup failed before. qed");
|
||||
task_manager, network, telemetry_on_connect_sinks, ..
|
||||
} = sc_service::build(params)?;
|
||||
|
||||
let (block_import, grandpa_link, babe_link) = import_setup;
|
||||
let shared_voter_state = rpc_setup;
|
||||
|
||||
(with_startup_data)(&block_import, &babe_link);
|
||||
|
||||
@@ -213,9 +212,6 @@ pub fn new_full_base(
|
||||
prometheus_registry.as_ref(),
|
||||
);
|
||||
|
||||
let select_chain = select_chain
|
||||
.ok_or(sc_service::Error::SelectChainRequired)?;
|
||||
|
||||
let can_author_with =
|
||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
|
||||
@@ -287,7 +283,6 @@ pub fn new_full_base(
|
||||
is_authority: role.is_network_authority(),
|
||||
};
|
||||
|
||||
let enable_grandpa = !disable_grandpa;
|
||||
if enable_grandpa {
|
||||
// start the full GRANDPA voter
|
||||
// NOTE: non-authorities could run the GRANDPA observer protocol, but at
|
||||
@@ -331,108 +326,82 @@ pub fn new_full(config: Configuration)
|
||||
})
|
||||
}
|
||||
|
||||
type LightClient = sc_service::TLightClient<Block, RuntimeApi, node_executor::Executor>;
|
||||
type LightFetcher = sc_network::config::OnDemand<Block>;
|
||||
|
||||
pub fn new_light_base(config: Configuration) -> Result<(
|
||||
TaskManager, Arc<RpcHandlers>, Arc<LightClient>,
|
||||
Arc<NetworkService<Block, <Block as BlockT>::Hash>>,
|
||||
Arc<sc_transaction_pool::BasicPool<
|
||||
sc_transaction_pool::LightChainApi<LightClient, LightFetcher, Block>, Block
|
||||
>>
|
||||
Arc<sc_transaction_pool::LightPool<Block, LightClient, sc_network::config::OnDemand<Block>>>
|
||||
), ServiceError> {
|
||||
let inherent_data_providers = InherentDataProviders::new();
|
||||
let (client, backend, keystore, task_manager, on_demand) =
|
||||
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
|
||||
let ServiceComponents {
|
||||
task_manager, rpc_handlers, client, network, transaction_pool, ..
|
||||
} = ServiceBuilder::new_light::<Block, RuntimeApi, node_executor::Executor>(config)?
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|builder| {
|
||||
let fetcher = builder.fetcher()
|
||||
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
|
||||
let pool_api = sc_transaction_pool::LightChainApi::new(
|
||||
builder.client().clone(),
|
||||
fetcher,
|
||||
);
|
||||
let pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
|
||||
builder.config().transaction_pool.clone(),
|
||||
Arc::new(pool_api),
|
||||
builder.prometheus_registry(),
|
||||
builder.spawn_handle(),
|
||||
));
|
||||
Ok(pool)
|
||||
})?
|
||||
.with_import_queue_and_fprb(|
|
||||
_config,
|
||||
client,
|
||||
backend,
|
||||
fetcher,
|
||||
mut select_chain,
|
||||
_tx_pool,
|
||||
spawn_task_handle,
|
||||
registry,
|
||||
| {
|
||||
let select_chain = select_chain.take()
|
||||
.ok_or_else(|| sc_service::Error::SelectChainRequired)?;
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let fetch_checker = fetcher
|
||||
.map(|fetcher| fetcher.checker().clone())
|
||||
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
||||
let transaction_pool_api = Arc::new(sc_transaction_pool::LightChainApi::new(
|
||||
client.clone(),
|
||||
on_demand.clone(),
|
||||
));
|
||||
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
|
||||
config.transaction_pool.clone(),
|
||||
transaction_pool_api,
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
));
|
||||
|
||||
let grandpa_block_import = grandpa::light_block_import(
|
||||
client.clone(),
|
||||
backend,
|
||||
&(client.clone() as Arc<_>),
|
||||
Arc::new(fetch_checker),
|
||||
)?;
|
||||
let grandpa_block_import = grandpa::light_block_import(
|
||||
client.clone(), backend.clone(), &(client.clone() as Arc<_>),
|
||||
Arc::new(on_demand.checker().clone()),
|
||||
)?;
|
||||
|
||||
let finality_proof_import = grandpa_block_import.clone();
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
let finality_proof_import = grandpa_block_import.clone();
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
let (babe_block_import, babe_link) = sc_consensus_babe::block_import(
|
||||
sc_consensus_babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
)?;
|
||||
let (babe_block_import, babe_link) = sc_consensus_babe::block_import(
|
||||
sc_consensus_babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
)?;
|
||||
|
||||
let import_queue = sc_consensus_babe::import_queue(
|
||||
babe_link,
|
||||
babe_block_import,
|
||||
None,
|
||||
Some(Box::new(finality_proof_import)),
|
||||
client,
|
||||
select_chain,
|
||||
inherent_data_providers.clone(),
|
||||
spawn_task_handle,
|
||||
registry,
|
||||
)?;
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
Ok((import_queue, finality_proof_request_builder))
|
||||
})?
|
||||
.with_finality_proof_provider(|client, backend| {
|
||||
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
||||
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
|
||||
})?
|
||||
.with_rpc_extensions(|builder| {
|
||||
let fetcher = builder.fetcher()
|
||||
.ok_or_else(|| "Trying to start node RPC without active fetcher")?;
|
||||
let remote_blockchain = builder.remote_backend()
|
||||
.ok_or_else(|| "Trying to start node RPC without active remote blockchain")?;
|
||||
let import_queue = sc_consensus_babe::import_queue(
|
||||
babe_link,
|
||||
babe_block_import,
|
||||
None,
|
||||
Some(Box::new(finality_proof_import)),
|
||||
client.clone(),
|
||||
select_chain.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
&task_manager.spawn_handle(),
|
||||
config.prometheus_registry(),
|
||||
)?;
|
||||
|
||||
let light_deps = node_rpc::LightDeps {
|
||||
remote_blockchain,
|
||||
fetcher,
|
||||
client: builder.client().clone(),
|
||||
pool: builder.pool(),
|
||||
};
|
||||
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
||||
let provider = client.clone() as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||
let finality_proof_provider =
|
||||
Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider));
|
||||
|
||||
Ok(node_rpc::create_light(light_deps))
|
||||
})?
|
||||
.build_light()?;
|
||||
let light_deps = node_rpc::LightDeps {
|
||||
remote_blockchain: backend.remote_blockchain(),
|
||||
fetcher: on_demand.clone(),
|
||||
client: client.clone(),
|
||||
pool: transaction_pool.clone(),
|
||||
};
|
||||
|
||||
let rpc_extensions = node_rpc::create_light(light_deps);
|
||||
|
||||
let ServiceComponents { task_manager, rpc_handlers, network, .. } =
|
||||
sc_service::build(sc_service::ServiceParams {
|
||||
block_announce_validator_builder: None,
|
||||
finality_proof_request_builder: Some(finality_proof_request_builder),
|
||||
finality_proof_provider: Some(finality_proof_provider),
|
||||
on_demand: Some(on_demand),
|
||||
remote_blockchain: Some(backend.remote_blockchain()),
|
||||
rpc_extensions_builder: Box::new(sc_service::NoopRpcExtensionBuilder(rpc_extensions)),
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
config, import_queue, keystore, backend, task_manager,
|
||||
})?;
|
||||
|
||||
Ok((task_manager, rpc_handlers, client, network, transaction_pool))
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
sc-client-api = { version = "2.0.0-rc5", path = "../../../client/api" }
|
||||
sc-rpc = { version = "2.0.0-rc5", path = "../../../client/rpc" }
|
||||
jsonrpc-core = "14.2.0"
|
||||
node-primitives = { version = "2.0.0-rc5", path = "../primitives" }
|
||||
node-runtime = { version = "2.0.0-rc5", path = "../runtime" }
|
||||
|
||||
@@ -94,6 +94,9 @@ pub struct FullDeps<C, P, SC> {
|
||||
pub grandpa: GrandpaDeps,
|
||||
}
|
||||
|
||||
/// A IO handler that uses all Full RPC extensions.
|
||||
pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
|
||||
|
||||
/// Instantiate all Full RPC extensions.
|
||||
pub fn create_full<C, P, M, SC>(
|
||||
deps: FullDeps<C, P, SC>,
|
||||
|
||||
@@ -714,7 +714,7 @@ fn authorities<A, B, C>(client: &C, at: &BlockId<B>) -> Result<Vec<A>, Consensus
|
||||
}
|
||||
|
||||
/// The Aura import queue type.
|
||||
pub type AuraImportQueue<B, Transaction> = BasicQueue<B, Transaction>;
|
||||
pub type AuraImportQueue<B, Client> = BasicQueue<B, sp_api::TransactionFor<Client, B>>;
|
||||
|
||||
/// Register the aura inherent data provider, if not registered already.
|
||||
fn register_aura_inherent_data_provider(
|
||||
@@ -824,7 +824,7 @@ pub fn import_queue<B, I, C, P, S>(
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
spawner: &S,
|
||||
registry: Option<&Registry>,
|
||||
) -> Result<AuraImportQueue<B, sp_api::TransactionFor<C, B>>, sp_consensus::Error> where
|
||||
) -> Result<AuraImportQueue<B, C>, sp_consensus::Error> where
|
||||
B: BlockT,
|
||||
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B, Error = sp_blockchain::Error>,
|
||||
C: 'static + ProvideRuntimeApi<B> + BlockOf + ProvideCache<B> + Send + Sync + AuxStore + HeaderBackend<B>,
|
||||
|
||||
@@ -968,7 +968,7 @@ where
|
||||
}
|
||||
|
||||
/// The BABE import queue type.
|
||||
pub type BabeImportQueue<B, Transaction> = BasicQueue<B, Transaction>;
|
||||
pub type BabeImportQueue<B, Client> = BasicQueue<B, sp_api::TransactionFor<Client, B>>;
|
||||
|
||||
/// Register the babe inherent data provider, if not registered already.
|
||||
fn register_babe_inherent_data_provider(
|
||||
@@ -1368,7 +1368,7 @@ pub fn import_queue<Block: BlockT, Client, SelectChain, Inner>(
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
spawner: &impl sp_core::traits::SpawnNamed,
|
||||
registry: Option<&Registry>,
|
||||
) -> ClientResult<BabeImportQueue<Block, sp_api::TransactionFor<Client, Block>>> where
|
||||
) -> ClientResult<BabeImportQueue<Block, Client>> where
|
||||
Inner: BlockImport<Block, Error = ConsensusError, Transaction = sp_api::TransactionFor<Client, Block>>
|
||||
+ Send + Sync + 'static,
|
||||
Client: ProvideRuntimeApi<Block> + ProvideCache<Block> + Send + Sync + AuxStore + 'static,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -52,9 +52,10 @@ use sp_utils::{status_sinks, mpsc::{tracing_unbounded, TracingUnboundedReceiver,
|
||||
|
||||
pub use self::error::Error;
|
||||
pub use self::builder::{
|
||||
new_full_client, new_client,
|
||||
ServiceBuilder, TFullClient, TLightClient, TFullBackend, TLightBackend,
|
||||
TFullCallExecutor, TLightCallExecutor, RpcExtensionBuilder,
|
||||
new_full_client, new_client, new_full_parts, new_light_parts, build,
|
||||
ServiceParams, TFullClient, TLightClient, TFullBackend, TLightBackend,
|
||||
TLightBackendWithHash, TLightClientWithBackend,
|
||||
TFullCallExecutor, TLightCallExecutor, RpcExtensionBuilder, NoopRpcExtensionBuilder,
|
||||
};
|
||||
pub use config::{
|
||||
BasePath, Configuration, DatabaseConfig, PruningMode, Role, RpcMethods, TaskExecutor, TaskType,
|
||||
@@ -150,25 +151,15 @@ impl TelemetryOnConnectSinks {
|
||||
|
||||
/// The individual components of the chain, built by the service builder. You are encouraged to
|
||||
/// deconstruct this into its fields.
|
||||
pub struct ServiceComponents<TBl: BlockT, TBackend: Backend<TBl>, TSc, TExPool, TCl> {
|
||||
/// A blockchain client.
|
||||
pub client: Arc<TCl>,
|
||||
/// A shared transaction pool instance.
|
||||
pub transaction_pool: Arc<TExPool>,
|
||||
pub struct ServiceComponents<TBl: BlockT, TBackend: Backend<TBl>, TCl> {
|
||||
/// The chain task manager.
|
||||
pub task_manager: TaskManager,
|
||||
/// A keystore that stores keys.
|
||||
pub keystore: sc_keystore::KeyStorePtr,
|
||||
/// A shared network instance.
|
||||
pub network: Arc<sc_network::NetworkService<TBl, <TBl as BlockT>::Hash>>,
|
||||
/// RPC handlers that can perform RPC queries.
|
||||
pub rpc_handlers: Arc<RpcHandlers>,
|
||||
/// A shared instance of the chain selection algorithm.
|
||||
pub select_chain: Option<TSc>,
|
||||
/// Sinks to propagate network status updates.
|
||||
pub network_status_sinks: NetworkStatusSinks<TBl>,
|
||||
/// A prometheus metrics registry, (if enabled).
|
||||
pub prometheus_registry: Option<prometheus_endpoint::Registry>,
|
||||
/// Shared Telemetry connection sinks,
|
||||
pub telemetry_on_connect_sinks: TelemetryOnConnectSinks,
|
||||
/// A shared offchain workers instance.
|
||||
|
||||
@@ -64,6 +64,11 @@ type ReadyIteratorFor<PoolApi> = BoxedReadyIterator<
|
||||
|
||||
type PolledIterator<PoolApi> = Pin<Box<dyn Future<Output=ReadyIteratorFor<PoolApi>> + Send>>;
|
||||
|
||||
/// A transaction pool for a full node.
|
||||
pub type FullPool<Block, Client> = BasicPool<FullChainApi<Client, Block>, Block>;
|
||||
/// A transaction pool for a light node.
|
||||
pub type LightPool<Block, Client, Fetcher> = BasicPool<LightChainApi<Client, Fetcher, Block>, Block>;
|
||||
|
||||
/// Basic implementation of transaction pool that can be customized by providing PoolApi.
|
||||
pub struct BasicPool<PoolApi, Block>
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user