Skip to content
Snippets Groups Projects
Commit d67821a5 authored by André Silva's avatar André Silva Committed by Gav Wood
Browse files

node: remove grandpa authority flags (#1306)

parent a6c77e4f
No related merge requests found
......@@ -120,21 +120,10 @@ pub fn run<I, T, E>(args: I, exit: E, version: cli::VersionInfo) -> error::Resul
Err(e) => e.exit(),
};
let (spec, mut config) = cli::parse_matches::<service::Factory, _>(
let (spec, config) = cli::parse_matches::<service::Factory, _>(
load_spec, version, "substrate-node", &matches
)?;
if matches.is_present("grandpa_authority_only") {
config.custom.grandpa_authority = true;
config.custom.grandpa_authority_only = true;
// Authority Setup is only called if validator is set as true
config.roles = ServiceRoles::AUTHORITY;
} else if matches.is_present("grandpa_authority") {
config.custom.grandpa_authority = true;
// Authority Setup is only called if validator is set as true
config.roles = ServiceRoles::AUTHORITY;
}
match cli::execute_default::<service::Factory, _>(spec, exit, &matches, &config)? {
cli::Action::ExecutedInternally => (),
cli::Action::RunService(exit) => {
......
......@@ -20,14 +20,6 @@ use cli::CoreParams;
/// Extend params for Node
#[derive(Debug, StructOpt)]
pub struct Params {
/// Should run as a GRANDPA authority node
#[structopt(long = "grandpa-authority", help = "Run Node as a GRANDPA authority, implies --validator")]
grandpa_authority: bool,
/// Should run as a GRANDPA authority node only
#[structopt(long = "grandpa-authority-only", help = "Run Node as a GRANDPA authority only, don't as a usual validator, implies --grandpa-authority")]
grandpa_authority_only: bool,
#[structopt(flatten)]
core: CoreParams
}
......@@ -40,12 +40,7 @@ construct_simple_protocol! {
/// Node specific configuration
pub struct NodeConfig<F: substrate_service::ServiceFactory> {
/// should run as a grandpa authority
pub grandpa_authority: bool,
/// should run as a grandpa authority only, don't validate as usual
pub grandpa_authority_only: bool,
/// grandpa connection to import block
// FIXME: rather than putting this on the config, let's have an actual intermediate setup state
// https://github.com/paritytech/substrate/issues/1134
pub grandpa_import_setup: Option<(Arc<grandpa::BlockImportForService<F>>, grandpa::LinkHalfForService<F>)>,
......@@ -54,8 +49,6 @@ pub struct NodeConfig<F: substrate_service::ServiceFactory> {
impl<F> Default for NodeConfig<F> where F: substrate_service::ServiceFactory {
fn default() -> NodeConfig<F> {
NodeConfig {
grandpa_authority: false,
grandpa_authority_only: false,
grandpa_import_setup: None,
}
}
......@@ -77,38 +70,29 @@ construct_service_factory! {
{ |config: FactoryFullConfiguration<Self>, executor: TaskExecutor|
FullComponents::<Factory>::new(config, executor) },
AuthoritySetup = {
|mut service: Self::FullService, executor: TaskExecutor, key: Option<Arc<Pair>>| {
|mut service: Self::FullService, executor: TaskExecutor, local_key: Option<Arc<Pair>>| {
let (block_import, link_half) = service.config.custom.grandpa_import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
let local_key = if let Some(key) = key {
if !service.config.custom.grandpa_authority_only {
info!("Using authority key {}", key.public());
let proposer = Arc::new(substrate_service::ProposerFactory {
client: service.client(),
transaction_pool: service.transaction_pool(),
});
let client = service.client();
executor.spawn(start_aura(
SlotDuration::get_or_compute(&*client)?,
key.clone(),
client,
block_import.clone(),
proposer,
service.network(),
));
}
if service.config.custom.grandpa_authority {
info!("Running Grandpa session as Authority {}", key.public());
Some(key)
} else {
None
}
} else {
None
};
if let Some(ref key) = local_key {
info!("Using authority key {}", key.public());
let proposer = Arc::new(substrate_service::ProposerFactory {
client: service.client(),
transaction_pool: service.transaction_pool(),
});
let client = service.client();
executor.spawn(start_aura(
SlotDuration::get_or_compute(&*client)?,
key.clone(),
client,
block_import.clone(),
proposer,
service.network(),
));
info!("Running Grandpa session as Authority {}", key.public());
}
let voter = grandpa::run_grandpa(
grandpa::Config {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment