pub struct ProofOfWork { /* private fields */ }
Expand description
High-performance Proof of Work implementation
Implementations§
Source§impl ProofOfWork
impl ProofOfWork
Sourcepub fn with_config(config: ProofOfWorkConfig) -> Self
pub fn with_config(config: ProofOfWorkConfig) -> Self
Create a new Proof of Work instance with custom configuration
Sourcepub fn with_difficulty(difficulty: u32) -> Self
pub fn with_difficulty(difficulty: u32) -> Self
Create a simple PoW with specified difficulty
Sourcepub fn verify_sync(
&self,
challenge: &PoWChallenge,
proof: &PoWProof,
) -> Result<bool>
pub fn verify_sync( &self, challenge: &PoWChallenge, proof: &PoWProof, ) -> Result<bool>
Verify proof efficiently
Sourcepub fn difficulty(&self) -> u32
pub fn difficulty(&self) -> u32
Get the current difficulty
Sourcepub fn set_difficulty(&mut self, difficulty: u32)
pub fn set_difficulty(&mut self, difficulty: u32)
Set the difficulty
Sourcepub fn estimate_time(&self, hash_rate: f64) -> Duration
pub fn estimate_time(&self, hash_rate: f64) -> Duration
Estimate time to mine based on hash rate
Trait Implementations§
Source§impl Clone for ProofOfWork
impl Clone for ProofOfWork
Source§fn clone(&self) -> ProofOfWork
fn clone(&self) -> ProofOfWork
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ProofOfWork
impl Debug for ProofOfWork
Source§impl Default for ProofOfWork
impl Default for ProofOfWork
Source§impl KeylessCryptoPrimitive for ProofOfWork
impl KeylessCryptoPrimitive for ProofOfWork
type Input = String
type Output = String
type Challenge = PoWChallenge
type Proof = PoWProof
fn compute<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_proof<'life0, 'async_trait>(
&'life0 self,
challenge: Self::Challenge,
) -> Pin<Box<dyn Future<Output = Result<Self::Proof>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn verify_proof<'life0, 'async_trait>(
&'life0 self,
challenge: Self::Challenge,
proof: Self::Proof,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for ProofOfWork
impl RefUnwindSafe for ProofOfWork
impl Send for ProofOfWork
impl Sync for ProofOfWork
impl Unpin for ProofOfWork
impl UnwindSafe for ProofOfWork
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
Mutably borrows from an owned value. Read more