Struct randomx_rs::RandomXVM

source ·
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

source

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.

source

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.

source

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.

source

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.

source

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§

source§

impl Debug for RandomXVM

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for RandomXVM

source§

fn drop(&mut self)

De-allocates memory for the VM object.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.