pub struct RandomXVM { /* private fields */ }
Expand description
The RandomX Virtual Machine (VM) is a complex instruction set computer that executes generated programs.
Implementations§
Source§impl RandomXVM
impl RandomXVM
Sourcepub fn new(
flags: RandomXFlag,
cache: Option<RandomXCache>,
dataset: Option<RandomXDataset>,
) -> Result<RandomXVM, RandomXError>
pub fn new( flags: RandomXFlag, cache: Option<RandomXCache>, dataset: Option<RandomXDataset>, ) -> Result<RandomXVM, RandomXError>
Creates a new VM
and initializes it, error on failure.
flags
is any combination of the following 5 flags:
- FLAG_LARGE_PAGES
- FLAG_HARD_AES
- FLAG_FULL_MEM
- FLAG_JIT
- FLAG_SECURE
Or
- FLAG_DEFAULT
cache
is a cache object, optional if FLAG_FULL_MEM is set.
dataset
is a dataset object, optional if FLAG_FULL_MEM is not set.
Sourcepub fn reinit_cache(&mut self, cache: RandomXCache) -> Result<(), RandomXError>
pub fn reinit_cache(&mut self, cache: RandomXCache) -> Result<(), RandomXError>
Re-initializes the VM
with a new cache that was initialised without
RandomXFlag::FLAG_FULL_MEM.
Sourcepub fn reinit_dataset(
&mut self,
dataset: RandomXDataset,
) -> Result<(), RandomXError>
pub fn reinit_dataset( &mut self, dataset: RandomXDataset, ) -> Result<(), RandomXError>
Re-initializes the VM
with a new dataset that was initialised with
RandomXFlag::FLAG_FULL_MEM.
Sourcepub fn calculate_hash(&self, input: &[u8]) -> Result<Vec<u8>, RandomXError>
pub fn calculate_hash(&self, input: &[u8]) -> Result<Vec<u8>, RandomXError>
Calculates a RandomX hash value and returns it, error on failure.
input
is a sequence of u8 to be hashed.
Sourcepub fn calculate_hash_set(
&self,
input: &[&[u8]],
) -> Result<Vec<Vec<u8>>, RandomXError>
pub fn calculate_hash_set( &self, input: &[&[u8]], ) -> Result<Vec<Vec<u8>>, RandomXError>
Calculates hashes from a set of inputs.
input
is an array of a sequence of u8 to be hashed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RandomXVM
impl RefUnwindSafe for RandomXVM
impl !Sync for RandomXVM
impl Unpin for RandomXVM
impl UnwindSafe for RandomXVM
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes