Update template triggered by workflow_dispatch

This commit is contained in:
Template Bot
2024-05-06 09:31:35 +00:00
parent b218abb9bc
commit c908bb14c7
9 changed files with 1200 additions and 633 deletions
+9 -1
View File
@@ -119,7 +119,15 @@ pub fn run() -> sc_cli::Result<()> {
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| async move {
service::new_full(config, cli.consensus).map_err(sc_cli::Error::Service)
match config.network.network_backend {
sc_network::config::NetworkBackendType::Libp2p =>
service::new_full::<sc_network::NetworkWorker<_, _>>(config, cli.consensus)
.map_err(sc_cli::Error::Service),
sc_network::config::NetworkBackendType::Litep2p => service::new_full::<
sc_network::Litep2pNetworkBackend,
>(config, cli.consensus)
.map_err(sc_cli::Error::Service),
}
})
},
}
+15 -3
View File
@@ -22,6 +22,7 @@ use sc_executor::WasmExecutor;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_runtime::traits::Block as BlockT;
use std::sync::Arc;
use crate::cli::Consensus;
@@ -104,7 +105,10 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
}
/// Builds a new service for a full client.
pub fn new_full(config: Configuration, consensus: Consensus) -> Result<TaskManager, ServiceError> {
pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Hash>>(
config: Configuration,
consensus: Consensus,
) -> Result<TaskManager, ServiceError> {
let sc_service::PartialComponents {
client,
backend,
@@ -116,7 +120,14 @@ pub fn new_full(config: Configuration, consensus: Consensus) -> Result<TaskManag
other: mut telemetry,
} = new_partial(&config)?;
let net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
let net_config = sc_network::config::FullNetworkConfiguration::<
Block,
<Block as BlockT>::Hash,
Network,
>::new(&config.network);
let metrics = Network::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
);
let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
@@ -129,6 +140,7 @@ pub fn new_full(config: Configuration, consensus: Consensus) -> Result<TaskManag
block_announce_validator_builder: None,
warp_sync_params: None,
block_relay: None,
metrics,
})?;
if config.offchain_worker.enabled {
@@ -143,7 +155,7 @@ pub fn new_full(config: Configuration, consensus: Consensus) -> Result<TaskManag
transaction_pool: Some(OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
)),
network_provider: network.clone(),
network_provider: Arc::new(network.clone()),
enable_http_requests: true,
custom_extensions: |_| vec![],
})