mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 14:41:11 +00:00
node: add sentry mode flag (#3959)
* node: add sentry mode flag * cli: extend docs on validator and sentry modes * service: add missing field in test Configuration * node: Display instead of Debug when printing node role
This commit is contained in:
committed by
Bastian Köcher
parent
dc14809804
commit
c92eda9809
@@ -3,7 +3,7 @@ use futures::{future, Future, sync::oneshot};
|
||||
use std::cell::RefCell;
|
||||
use tokio::runtime::Runtime;
|
||||
pub use substrate_cli::{VersionInfo, IntoExit, error};
|
||||
use substrate_cli::{informant, parse_and_prepare, ParseAndPrepare, NoCustom};
|
||||
use substrate_cli::{display_role, informant, parse_and_prepare, ParseAndPrepare, NoCustom};
|
||||
use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration};
|
||||
use aura_primitives::sr25519::{AuthorityPair as AuraPair};
|
||||
use crate::chain_spec;
|
||||
@@ -24,7 +24,7 @@ pub fn run<I, T, E>(args: I, exit: E, version: VersionInfo) -> error::Result<()>
|
||||
info!(" by {}, 2017, 2018", version.author);
|
||||
info!("Chain specification: {}", config.chain_spec.name());
|
||||
info!("Node name: {}", config.name);
|
||||
info!("Roles: {:?}", config.roles);
|
||||
info!("Roles: {}", display_role(&config));
|
||||
let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
|
||||
match config.roles {
|
||||
ServiceRoles::LIGHT => run_until_exit(
|
||||
|
||||
@@ -80,6 +80,11 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
let name = config.name.clone();
|
||||
let disable_grandpa = config.disable_grandpa;
|
||||
|
||||
// sentry nodes announce themselves as authorities to the network
|
||||
// and should run the same protocols authorities do, but it should
|
||||
// never actively participate in any consensus process.
|
||||
let participates_in_consensus = is_authority && !config.sentry_mode;
|
||||
|
||||
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
|
||||
|
||||
let (block_import, grandpa_link) =
|
||||
@@ -92,7 +97,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
)?
|
||||
.build()?;
|
||||
|
||||
if is_authority {
|
||||
if participates_in_consensus {
|
||||
let proposer = basic_authorship::ProposerFactory {
|
||||
client: service.client(),
|
||||
transaction_pool: service.transaction_pool(),
|
||||
@@ -119,13 +124,21 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
service.spawn_essential_task(aura);
|
||||
}
|
||||
|
||||
// if the node isn't actively participating in consensus then it doesn't
|
||||
// need a keystore, regardless of which protocol we use below.
|
||||
let keystore = if participates_in_consensus {
|
||||
Some(service.keystore())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let grandpa_config = grandpa::Config {
|
||||
// FIXME #1578 make this available through chainspec
|
||||
gossip_duration: Duration::from_millis(333),
|
||||
justification_period: 512,
|
||||
name: Some(name),
|
||||
keystore: Some(service.keystore()),
|
||||
observer_enabled: true,
|
||||
keystore,
|
||||
is_authority,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user