diff --git a/node/src/cli.rs b/node/src/cli.rs index a494a87277526392ea467bd24b12c5e60f1d553c..647845b5f39f6e2444d689ea69464654933d9ff3 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -19,9 +19,14 @@ pub struct Cli { #[clap(subcommand)] pub subcommand: Option<Subcommand>, + /// substrate base options #[clap(flatten)] pub run: sc_cli::RunCmd, + /// duniter specific options + #[clap(flatten)] + pub duniter_options: DuniterConfigExtension, + /// How blocks should be sealed /// /// Options are "production", "instant", "manual", or timer interval in milliseconds @@ -29,6 +34,18 @@ pub struct Cli { pub sealing: crate::cli::Sealing, } +/// add options specific to duniter client +#[derive(Debug, Clone, clap::Parser)] +pub struct DuniterConfigExtension { + /// Public RPC endpoint to gossip on the network and make available in the apps. + #[arg(long)] + pub public_rpc: Option<String>, + + /// Public Squid graphql endpoint to gossip on the network and make available in the apps. + #[arg(long)] + pub public_squid: Option<String>, +} + #[derive(Debug, clap::Subcommand)] pub enum Subcommand { /// Build a chain specification. diff --git a/node/src/command.rs b/node/src/command.rs index 29af1944580fb2cbd3d0cef340c20c0fb9e2b70d..9bac5239695c9668bb34a43b42419f2a4037c9af 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -364,6 +364,8 @@ pub fn run() -> sc_cli::Result<()> { } None => { let runner = cli.create_runner(&cli.run)?; + // TODO add endpoint config here + let config_extension: DuniterConfigExtension = (); runner.run_node_until_exit(|mut config| async move { // Force offchain worker and offchain indexing if we have the role Authority if config.role.is_authority() { @@ -376,7 +378,7 @@ pub fn run() -> sc_cli::Result<()> { service::runtime_executor::runtime::RuntimeApi, Executor, sc_network::Litep2pNetworkBackend, - >(config, cli.sealing) + >(config, cli.sealing, config_extension) .map_err(sc_cli::Error::Service) } }) diff --git a/node/src/service.rs b/node/src/service.rs index 8946443088e3857c2f5c5c6feb4c9c43582919f9..48b2c255c1149b1abfef5b7a99aed632331cfd3d 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -147,6 +147,7 @@ type FullGrandpaBlockImport<RuntimeApi, Executor> = sc_consensus_grandpa::Grandp pub fn new_partial<RuntimeApi, Executor>( config: &Configuration, consensus_manual: bool, + config_extension: DuniterConfigExtension, ) -> Result< sc_service::PartialComponents< FullClient<RuntimeApi, Executor>, @@ -348,6 +349,28 @@ where ); net_config.add_notification_protocol(grandpa_protocol_config); + // endpoint gossip + // only active for non-authority (to save workload) + if !role.is_authority() { + // configure protocol + let (endpoint_gossip_protocol_config, endpoint_gossip_notification_service) = ((), ()); + net_config.add_notification_protocol(endpoint_gossip_protocol_config); + let endpoint_gossip_config = (); + let endpoint_gossip_params = EndpointGossipParams { + config: endpoint_gossip_config, + network, + notification_service: endpoint_gossip_notification_service, + // offchain storage + offchain_endpoint_tester: (), + }; + // spawn task + task_manager.spawn_handle().spawn( + "endpoint-gossip", + None, + run_gossip_worker(endpoint_gossip_params)?, + ); + } + let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( backend.clone(), grandpa_link.shared_authority_set().clone(),