Slow down `solana-validator monitor` refresh interval when talking to a real node

This commit is contained in:
Michael Vines 2021-03-06 11:53:21 -08:00 committed by mergify[bot]
parent b2b7617ec3
commit 04d11ca6c6
3 changed files with 10 additions and 12 deletions

View File

@ -30,7 +30,7 @@ use {
path::{Path, PathBuf}, path::{Path, PathBuf},
process::exit, process::exit,
sync::mpsc::channel, sync::mpsc::channel,
time::{SystemTime, UNIX_EPOCH}, time::{Duration, SystemTime, UNIX_EPOCH},
}, },
}; };
@ -413,7 +413,7 @@ fn main() {
match genesis.start_with_mint_address(mint_address) { match genesis.start_with_mint_address(mint_address) {
Ok(test_validator) => { Ok(test_validator) => {
if let Some(dashboard) = dashboard { if let Some(dashboard) = dashboard {
dashboard.run(); dashboard.run(Duration::from_millis(250));
} }
test_validator.join(); test_validator.join();
} }

View File

@ -7,10 +7,7 @@ use {
}, },
solana_core::validator::ValidatorStartProgress, solana_core::validator::ValidatorStartProgress,
solana_sdk::{ solana_sdk::{
clock::{Slot, DEFAULT_TICKS_PER_SLOT, MS_PER_TICK}, clock::Slot, commitment_config::CommitmentConfig, native_token::Sol, pubkey::Pubkey,
commitment_config::CommitmentConfig,
native_token::Sol,
pubkey::Pubkey,
}, },
std::{ std::{
io, io,
@ -58,7 +55,7 @@ impl Dashboard {
}) })
} }
pub fn run(self) { pub fn run(self, refresh_interval: Duration) {
let Self { let Self {
exit, exit,
ledger_path, ledger_path,
@ -76,6 +73,7 @@ impl Dashboard {
&ledger_path, &ledger_path,
&exit, &exit,
progress_bar, progress_bar,
refresh_interval,
)) { )) {
None => continue, None => continue,
Some(results) => results, Some(results) => results,
@ -158,9 +156,7 @@ impl Dashboard {
transaction_count, transaction_count,
identity_balance identity_balance
)); ));
thread::sleep(Duration::from_millis( thread::sleep(refresh_interval);
MS_PER_TICK * DEFAULT_TICKS_PER_SLOT / 2,
));
} }
Err(err) => { Err(err) => {
progress_bar progress_bar
@ -177,19 +173,20 @@ async fn wait_for_validator_startup(
ledger_path: &Path, ledger_path: &Path,
exit: &Arc<AtomicBool>, exit: &Arc<AtomicBool>,
progress_bar: ProgressBar, progress_bar: ProgressBar,
refresh_interval: Duration,
) -> Option<(SocketAddr, SystemTime)> { ) -> Option<(SocketAddr, SystemTime)> {
let mut admin_client = None; let mut admin_client = None;
loop { loop {
if exit.load(Ordering::Relaxed) { if exit.load(Ordering::Relaxed) {
return None; return None;
} }
thread::sleep(Duration::from_secs(1));
if admin_client.is_none() { if admin_client.is_none() {
match admin_rpc_service::connect(&ledger_path).await { match admin_rpc_service::connect(&ledger_path).await {
Ok(new_admin_client) => admin_client = Some(new_admin_client), Ok(new_admin_client) => admin_client = Some(new_admin_client),
Err(err) => { Err(err) => {
progress_bar.set_message(&format!("Unable to connect to validator: {}", err)); progress_bar.set_message(&format!("Unable to connect to validator: {}", err));
thread::sleep(refresh_interval);
continue; continue;
} }
} }
@ -225,6 +222,7 @@ async fn wait_for_validator_startup(
.set_message(&format!("Failed to get validator start progress: {}", err)); .set_message(&format!("Failed to get validator start progress: {}", err));
} }
} }
thread::sleep(refresh_interval);
} }
} }

View File

@ -2100,7 +2100,7 @@ pub fn main() {
); );
exit(1); exit(1);
}); });
dashboard.run(); dashboard.run(Duration::from_secs(2));
} }
Operation::WaitForRestartWindow { Operation::WaitForRestartWindow {
min_idle_time_in_minutes, min_idle_time_in_minutes,