Tune bench-tps blockhash poller and stop panicking
This commit is contained in:
parent
5e6c58716e
commit
4b3176a9a1
|
@ -402,29 +402,33 @@ fn poll_blockhash<T: Client>(
|
||||||
client: &Arc<T>,
|
client: &Arc<T>,
|
||||||
id: &Pubkey,
|
id: &Pubkey,
|
||||||
) {
|
) {
|
||||||
let mut blockhash_time;
|
let mut blockhash_last_updated = Instant::now();
|
||||||
loop {
|
|
||||||
blockhash_time = Instant::now();
|
|
||||||
loop {
|
loop {
|
||||||
|
let blockhash_updated = {
|
||||||
let old_blockhash = *blockhash.read().unwrap();
|
let old_blockhash = *blockhash.read().unwrap();
|
||||||
if let Ok((new_blockhash, _fee)) = client.get_new_blockhash(&old_blockhash) {
|
if let Ok((new_blockhash, _fee)) = client.get_new_blockhash(&old_blockhash) {
|
||||||
*blockhash.write().unwrap() = new_blockhash;
|
*blockhash.write().unwrap() = new_blockhash;
|
||||||
break;
|
blockhash_last_updated = Instant::now();
|
||||||
|
true
|
||||||
} else {
|
} else {
|
||||||
if blockhash_time.elapsed().as_secs() > 30 {
|
if blockhash_last_updated.elapsed().as_secs() > 30 {
|
||||||
panic!("Blockhash is not updating");
|
error!("Blockhash is not updating");
|
||||||
}
|
|
||||||
sleep(Duration::from_millis(50));
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if blockhash_updated {
|
||||||
let balance = client.get_balance(id).unwrap_or(0);
|
let balance = client.get_balance(id).unwrap_or(0);
|
||||||
metrics_submit_lamport_balance(balance);
|
metrics_submit_lamport_balance(balance);
|
||||||
|
}
|
||||||
|
|
||||||
if exit_signal.load(Ordering::Relaxed) {
|
if exit_signal.load(Ordering::Relaxed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait a slot before checking again
|
||||||
|
sleep(Duration::from_millis(400));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue