improve random_u64
This commit is contained in:
parent
873e5b1ebf
commit
08f3040381
@ -226,8 +226,10 @@ impl FunctionManager {
|
||||
|
||||
/// Create and push new empty function entry
|
||||
pub fn push_empty(&mut self) {
|
||||
self.functions
|
||||
.push((Id::new_from_u64(random_u64()), FunctionEntry::EMPTY));
|
||||
self.functions.push((
|
||||
Id::new_from_u64(random_u64().expect("unable to generate random id")),
|
||||
FunctionEntry::EMPTY,
|
||||
));
|
||||
}
|
||||
|
||||
/// Detect if any functions are using integrals
|
||||
|
||||
@ -180,8 +180,8 @@ pub const fn hashed_storage_read(data: &str) -> Option<(HashBytes, &[u8])> {
|
||||
))
|
||||
}
|
||||
|
||||
pub fn random_u64() -> u64 {
|
||||
let mut data: [u8; 8] = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
getrandom(&mut data).expect("unable to generate random number");
|
||||
u64::from_be_bytes(data)
|
||||
pub fn random_u64() -> Result<u64, getrandom::Error> {
|
||||
let mut buf = [0u8; 8];
|
||||
getrandom(&mut buf)?;
|
||||
Ok(u64::from_be_bytes(buf))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user