diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index 2f7f4cb8f..25115715e 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -402,29 +402,33 @@ fn poll_blockhash( client: &Arc, id: &Pubkey, ) { - let mut blockhash_time; + let mut blockhash_last_updated = Instant::now(); loop { - blockhash_time = Instant::now(); - loop { + let blockhash_updated = { let old_blockhash = *blockhash.read().unwrap(); if let Ok((new_blockhash, _fee)) = client.get_new_blockhash(&old_blockhash) { *blockhash.write().unwrap() = new_blockhash; - break; + blockhash_last_updated = Instant::now(); + true } else { - if blockhash_time.elapsed().as_secs() > 30 { - panic!("Blockhash is not updating"); + if blockhash_last_updated.elapsed().as_secs() > 30 { + error!("Blockhash is not updating"); } - sleep(Duration::from_millis(50)); - continue; + false } - } + }; - let balance = client.get_balance(id).unwrap_or(0); - metrics_submit_lamport_balance(balance); + if blockhash_updated { + let balance = client.get_balance(id).unwrap_or(0); + metrics_submit_lamport_balance(balance); + } if exit_signal.load(Ordering::Relaxed) { break; } + + // Wait a slot before checking again + sleep(Duration::from_millis(400)); } }