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:
André Silva
2019-10-29 18:58:34 +00:00
committed by Bastian Köcher
parent dc14809804
commit c92eda9809
8 changed files with 79 additions and 10 deletions
+15 -2
View File
@@ -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,
};