Use from_secs api to create duration (#27222)

use from_secs api to create duration
This commit is contained in:
HaoranYi 2022-08-18 11:06:52 -05:00 committed by GitHub
parent 77563bc1c9
commit 4634fb944c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -109,7 +109,7 @@ where
} else {
trace!("not converged {} {} {}", i, total + num, num * num);
}
sleep(Duration::new(1, 0));
sleep(Duration::from_secs(1));
}
exit.store(true, Ordering::Relaxed);
for (_, dr, _) in listen {
@ -251,7 +251,7 @@ pub fn cluster_info_retransmit() {
if done {
break;
}
sleep(Duration::new(1, 0));
sleep(Duration::from_secs(1));
}
assert!(done);
let mut p = Packet::default();
@ -269,7 +269,7 @@ pub fn cluster_info_retransmit() {
.into_par_iter()
.map(|s| {
let mut p = Packet::default();
s.set_read_timeout(Some(Duration::new(1, 0))).unwrap();
s.set_read_timeout(Some(Duration::from_secs(1))).unwrap();
let res = s.recv_from(p.buffer_mut());
res.is_err() //true if failed to receive the retransmit packet
})

View File

@ -5005,7 +5005,7 @@ pub mod tests {
blockstore
.insert_shreds(vec![shreds.remove(1)], None, false)
.unwrap();
let timer = Duration::new(1, 0);
let timer = Duration::from_secs(1);
assert!(recvr.recv_timeout(timer).is_err());
// Insert first shred, now we've made a consecutive block
blockstore

View File

@ -12977,7 +12977,7 @@ pub(crate) mod tests {
#[cfg(not(target_os = "linux"))]
{
error!("{} banks, sleeping for 5 sec", num_banks);
std::thread::sleep(Duration::new(5, 0));
std::thread::sleep(Duration::from_secs(5));
}
}
}