mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +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
@@ -236,6 +236,17 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a string displaying the node role, special casing the sentry mode
|
||||
/// (returning `SENTRY`), since the node technically has an `AUTHORITY` role but
|
||||
/// doesn't participate.
|
||||
pub fn display_role<A, B>(config: &Configuration<(), A, B>) -> String {
|
||||
if config.sentry_mode {
|
||||
"SENTRY".to_string()
|
||||
} else {
|
||||
format!("{:?}", config.roles)
|
||||
}
|
||||
}
|
||||
|
||||
/// Output of calling `parse_and_prepare`.
|
||||
#[must_use]
|
||||
pub enum ParseAndPrepare<'a, CC, RP> {
|
||||
@@ -658,16 +669,20 @@ where
|
||||
config.state_cache_size = cli.state_cache_size;
|
||||
|
||||
let is_dev = cli.shared_params.dev;
|
||||
let is_authority = cli.validator || cli.sentry || is_dev || cli.keyring.account.is_some();
|
||||
|
||||
let role =
|
||||
if cli.light {
|
||||
service::Roles::LIGHT
|
||||
} else if cli.validator || is_dev || cli.keyring.account.is_some() {
|
||||
} else if is_authority {
|
||||
service::Roles::AUTHORITY
|
||||
} else {
|
||||
service::Roles::FULL
|
||||
};
|
||||
|
||||
// set sentry mode (i.e. act as an authority but **never** actively participate)
|
||||
config.sentry_mode = cli.sentry;
|
||||
|
||||
// by default we disable pruning if the node is an authority (i.e.
|
||||
// `ArchiveAll`), otherwise we keep state for the last 256 blocks. if the
|
||||
// node is an authority and pruning is enabled explicitly, then we error
|
||||
|
||||
Reference in New Issue
Block a user