Quietly re-introduce legacy --voting-keypair/--identity-keypair args for v1.0.6 compatibility

This commit is contained in:
Michael Vines 2020-03-15 10:19:07 -07:00
parent b2a0cdaa38
commit 49706172f3
1 changed files with 27 additions and 6 deletions

View File

@ -373,6 +373,7 @@ pub fn main() {
Arg::with_name("identity")
.short("i")
.long("identity")
.alias("identity-keypair") // --identity-keypair is legacy for <= v1.0.6 users
.value_name("PATH")
.takes_value(true)
.validator(is_keypair_or_ask_keyword)
@ -386,6 +387,15 @@ pub fn main() {
.validator(is_keypair_or_ask_keyword)
.help("Authorized voter keypair [default: value of --identity]"),
)
.arg(
Arg::with_name("deprecated_voting_keypair")
.long("voting-keypair")
.value_name("PATH")
.takes_value(true)
.hidden(true) // Don't document this argument, it's legacy for <= v1.0.6 users
.conflicts_with_all(&["authorized_voter", "vote_account"])
.validator(is_keypair_or_ask_keyword),
)
.arg(
Arg::with_name("vote_account")
.long("vote-account")
@ -658,6 +668,10 @@ pub fn main() {
let identity_keypair = Arc::new(keypair_of(&matches, "identity").unwrap_or_else(Keypair::new));
let authorized_voter = keypair_of(&matches, "authorized_voter")
.or_else(|| {
// Legacy v1.0.6 argument support
keypair_of(&matches, "deprecated_voting_keypair")
})
.map(Arc::new)
.unwrap_or_else(|| identity_keypair.clone());
@ -726,6 +740,19 @@ pub fn main() {
..ValidatorConfig::default()
};
let vote_account = pubkey_of(&matches, "vote_account").unwrap_or_else(|| {
if matches.is_present("deprecated_voting_keypair") {
// Legacy v1.0.6 behaviour of using `--voting-keypair` as `--vote-account`
keypair_of(&matches, "deprecated_voting_keypair")
.unwrap()
.pubkey()
} else {
warn!("--vote-account not specified, validator will not vote");
validator_config.voting_disabled = true;
Keypair::new().pubkey()
}
});
let dynamic_port_range =
solana_net_utils::parse_port_range(matches.value_of("dynamic_port_range").unwrap())
.expect("invalid dynamic_port_range");
@ -838,12 +865,6 @@ pub fn main() {
info!("{} {}", crate_name!(), solana_clap_utils::version!());
info!("Starting validator with: {:#?}", std::env::args_os());
let vote_account = pubkey_of(&matches, "vote_account").unwrap_or_else(|| {
warn!("--vote-account not specified, validator will not vote");
validator_config.voting_disabled = true;
Keypair::new().pubkey()
});
solana_metrics::set_host_id(identity_keypair.pubkey().to_string());
solana_metrics::set_panic_hook("validator");