ResourceProof

Struct ResourceProof 

Source
pub struct ResourceProof { /* private fields */ }
Expand description

Holds the prover requirements

Implementations§

Source§

impl ResourceProof

Source

pub fn new(min_size: usize, difficulty: u8) -> ResourceProof

Configure a new prover.

min_size is target data size in bytes. It may be small or large to test bandwidth (although it may be compressible).

difficulty is the number of leading binary zeros required in the hash. Each extra zero doubles the difficulty.

Source

pub fn create_proof_data(&self, nonce: &[u8]) -> VecDeque<u8>

Create the proof data with a given nonce.

Source

pub fn create_prover(&self, data: VecDeque<u8>) -> ResourceProver

Create a prover object. Requires a copy of the data (from create_proof_data) to be passed in.

Source

pub fn validate_all( &self, nonce: &[u8], received_data: &VecDeque<u8>, key: u64, ) -> bool

Validate the proof data and key (this is the number of zeros to be pushed onto the data).

Source

pub fn validate_data(&self, nonce: &[u8], data: &VecDeque<u8>) -> bool

Validate the data for the given nonce and size data.

Source

pub fn validate_proof(&self, nonce: &[u8], key: u64) -> bool

Validate the proof key (this must recreate the data, hence validate_all is faster when both must be checked).

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.