validator: add contact-info query to admin port

This commit is contained in:
Trent Nelson
2021-12-23 00:56:16 -07:00
committed by mergify[bot]
parent d06c04d02c
commit b93ab5d295
4 changed files with 122 additions and 1 deletions

View File

@@ -1682,6 +1682,18 @@ pub fn main() {
currently running validator instance")
)
)
.subcommand(
SubCommand::with_name("contact-info")
.about("Display the validator's contact info")
.arg(
Arg::with_name("output")
.long("output")
.takes_value(true)
.value_name("MODE")
.possible_values(&["json", "json-compact"])
.help("Output display mode")
)
)
.subcommand(
SubCommand::with_name("init")
.about("Initialize the ledger directory then exit")
@@ -1809,6 +1821,26 @@ pub fn main() {
_ => unreachable!(),
}
}
("contact-info", Some(subcommand_matches)) => {
let output_mode = subcommand_matches.value_of("output");
let admin_client = admin_rpc_service::connect(&ledger_path);
let contact_info = admin_rpc_service::runtime()
.block_on(async move { admin_client.await?.contact_info().await })
.unwrap_or_else(|err| {
eprintln!("Contact info query failed: {}", err);
exit(1);
});
if let Some(mode) = output_mode {
match mode {
"json" => println!("{}", serde_json::to_string_pretty(&contact_info).unwrap()),
"json-compact" => print!("{}", serde_json::to_string(&contact_info).unwrap()),
_ => unreachable!(),
}
} else {
print!("{}", contact_info);
}
return;
}
("init", _) => Operation::Initialize,
("exit", Some(subcommand_matches)) => {
let min_idle_time = value_t_or_exit!(subcommand_matches, "min_idle_time", usize);