`solana-validator monitor` now reports identity changes
This commit is contained in:
parent
03bf66a51b
commit
b44f40ee3a
|
@ -1,5 +1,8 @@
|
|||
use {
|
||||
crate::{admin_rpc_service, new_spinner_progress_bar, println_name_value, ProgressBar},
|
||||
crate::{
|
||||
admin_rpc_service, format_name_value, new_spinner_progress_bar, println_name_value,
|
||||
ProgressBar,
|
||||
},
|
||||
console::style,
|
||||
solana_client::{
|
||||
client_error, rpc_client::RpcClient, rpc_request, rpc_response::RpcContactInfo,
|
||||
|
@ -80,7 +83,7 @@ impl Dashboard {
|
|||
};
|
||||
|
||||
let rpc_client = RpcClient::new_socket(rpc_addr);
|
||||
let identity = match rpc_client.get_identity() {
|
||||
let mut identity = match rpc_client.get_identity() {
|
||||
Ok(identity) => identity,
|
||||
Err(err) => {
|
||||
println!("Failed to get validator identity over RPC: {}", err);
|
||||
|
@ -122,6 +125,12 @@ impl Dashboard {
|
|||
snapshot_slot_info = rpc_client.get_highest_snapshot_slot().ok();
|
||||
}
|
||||
|
||||
let new_identity = rpc_client.get_identity().unwrap_or(identity);
|
||||
if identity != new_identity {
|
||||
identity = new_identity;
|
||||
progress_bar.println(&format_name_value("Identity:", &identity.to_string()));
|
||||
}
|
||||
|
||||
match get_validator_stats(&rpc_client, &identity) {
|
||||
Ok((
|
||||
processed_slot,
|
||||
|
|
|
@ -108,9 +108,12 @@ pub fn port_range_validator(port_range: String) -> Result<(), String> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn format_name_value(name: &str, value: &str) -> String {
|
||||
format!("{} {}", style(name).bold(), value)
|
||||
}
|
||||
/// Pretty print a "name value"
|
||||
pub fn println_name_value(name: &str, value: &str) {
|
||||
println!("{} {}", style(name).bold(), value);
|
||||
format_name_value(name, value);
|
||||
}
|
||||
|
||||
/// Creates a new process bar for processing that will take an unknown amount of time
|
||||
|
@ -141,6 +144,10 @@ impl ProgressBar {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn println<I: AsRef<str>>(&self, msg: I) {
|
||||
self.progress_bar.println(msg);
|
||||
}
|
||||
|
||||
pub fn abandon_with_message<T: Into<Cow<'static, str>> + Display>(&self, msg: T) {
|
||||
if self.is_term {
|
||||
self.progress_bar.abandon_with_message(msg);
|
||||
|
|
Loading…
Reference in New Issue