Struct pow_sha256::Config
source · pub struct Config {
pub salt: String,
}
Expand description
Configuration for generting proof of work Please choose a long, unique value for salt Resistance to dictionary/rainbow attacks depend on uniqueness of the salt
Fields§
§salt: String
Implementations§
source§impl Config
impl Config
sourcepub fn stepped_prove_work<T>(
&self,
t: &T,
difficulty: u32,
step: usize,
inter: Option<IncrementalSolve<T>>
) -> Result<IncrementalSolve<T>>where
T: Serialize,
pub fn stepped_prove_work<T>( &self, t: &T, difficulty: u32, step: usize, inter: Option<IncrementalSolve<T>> ) -> Result<IncrementalSolve<T>>where T: Serialize,
step is used to control the number of cycles after which the function should exit, even when the proof isn’t ready inter is used to keep track of state and complete proof generation. Set inter to None during first cyle and pass the returned value of the previous cycle to continue proof generation
sourcepub fn prove_work<T>(&self, t: &T, difficulty: u32) -> Result<PoW<T>>where
T: Serialize,
pub fn prove_work<T>(&self, t: &T, difficulty: u32) -> Result<PoW<T>>where T: Serialize,
Create Proof of Work over item of type T.
Make sure difficulty is not too high. A 64 bit difficulty, for example, takes a long time on a general purpose processor. Returns bincode::Error if serialization fails.
sourcepub fn prove_work_serialized<T>(&self, prefix: &[u8], difficulty: u32) -> PoW<T>where
T: Serialize,
pub fn prove_work_serialized<T>(&self, prefix: &[u8], difficulty: u32) -> PoW<T>where T: Serialize,
Create Proof of Work on an already serialized item of type T. The input is assumed to be serialized using network byte order.
Make sure difficulty is not too high. A 64 bit difficulty, for example, takes a long time on a general purpose processor.
sourcepub fn calculate<T>(&self, pow: &PoW<T>, t: &T) -> Result<u128>where
T: Serialize,
pub fn calculate<T>(&self, pow: &PoW<T>, t: &T) -> Result<u128>where T: Serialize,
Calculate the PoW score with the provided input T.
sourcepub fn calculate_serialized<T>(&self, pow: &PoW<T>, target: &[u8]) -> u128where
T: Serialize,
pub fn calculate_serialized<T>(&self, pow: &PoW<T>, target: &[u8]) -> u128where T: Serialize,
Calculate the PoW score of an already serialized T and self. The input is assumed to be serialized using network byte order.