Skip to content
Snippets Groups Projects
Commit 35eb66d9 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

wip sketch endpoint gossip service

parent f7d5ad47
Branches
No related tags found
No related merge requests found
Pipeline #38366 waiting for manual action
...@@ -19,9 +19,14 @@ pub struct Cli { ...@@ -19,9 +19,14 @@ pub struct Cli {
#[clap(subcommand)] #[clap(subcommand)]
pub subcommand: Option<Subcommand>, pub subcommand: Option<Subcommand>,
/// substrate base options
#[clap(flatten)] #[clap(flatten)]
pub run: sc_cli::RunCmd, pub run: sc_cli::RunCmd,
/// duniter specific options
#[clap(flatten)]
pub duniter_options: DuniterConfigExtension,
/// How blocks should be sealed /// How blocks should be sealed
/// ///
/// Options are "production", "instant", "manual", or timer interval in milliseconds /// Options are "production", "instant", "manual", or timer interval in milliseconds
...@@ -29,6 +34,18 @@ pub struct Cli { ...@@ -29,6 +34,18 @@ pub struct Cli {
pub sealing: crate::cli::Sealing, 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)] #[derive(Debug, clap::Subcommand)]
pub enum Subcommand { pub enum Subcommand {
/// Build a chain specification. /// Build a chain specification.
......
...@@ -364,6 +364,8 @@ pub fn run() -> sc_cli::Result<()> { ...@@ -364,6 +364,8 @@ pub fn run() -> sc_cli::Result<()> {
} }
None => { None => {
let runner = cli.create_runner(&cli.run)?; 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 { runner.run_node_until_exit(|mut config| async move {
// Force offchain worker and offchain indexing if we have the role Authority // Force offchain worker and offchain indexing if we have the role Authority
if config.role.is_authority() { if config.role.is_authority() {
...@@ -376,7 +378,7 @@ pub fn run() -> sc_cli::Result<()> { ...@@ -376,7 +378,7 @@ pub fn run() -> sc_cli::Result<()> {
service::runtime_executor::runtime::RuntimeApi, service::runtime_executor::runtime::RuntimeApi,
Executor, Executor,
sc_network::Litep2pNetworkBackend, sc_network::Litep2pNetworkBackend,
>(config, cli.sealing) >(config, cli.sealing, config_extension)
.map_err(sc_cli::Error::Service) .map_err(sc_cli::Error::Service)
} }
}) })
......
...@@ -147,6 +147,7 @@ type FullGrandpaBlockImport<RuntimeApi, Executor> = sc_consensus_grandpa::Grandp ...@@ -147,6 +147,7 @@ type FullGrandpaBlockImport<RuntimeApi, Executor> = sc_consensus_grandpa::Grandp
pub fn new_partial<RuntimeApi, Executor>( pub fn new_partial<RuntimeApi, Executor>(
config: &Configuration, config: &Configuration,
consensus_manual: bool, consensus_manual: bool,
config_extension: DuniterConfigExtension,
) -> Result< ) -> Result<
sc_service::PartialComponents< sc_service::PartialComponents<
FullClient<RuntimeApi, Executor>, FullClient<RuntimeApi, Executor>,
...@@ -348,6 +349,28 @@ where ...@@ -348,6 +349,28 @@ where
); );
net_config.add_notification_protocol(grandpa_protocol_config); 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( let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
backend.clone(), backend.clone(),
grandpa_link.shared_authority_set().clone(), grandpa_link.shared_authority_set().clone(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment