Struct resource_proof::ResourceProof
[−]
[src]
pub struct ResourceProof { /* fields omitted */ }
Holds the prover requirements
Methods
impl ResourceProof
[src]
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.
fn create_proof_data(&self, nonce: &[u8]) -> VecDeque<u8>
Create the proof data with a given nonce.
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.
fn validate_all(
&self,
nonce: &[u8],
received_data: &VecDeque<u8>,
key: u64
) -> bool
&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).
fn validate_data(&self, nonce: &[u8], data: &VecDeque<u8>) -> bool
Validate the data for the given nonce
and size data.
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).