pub struct PoWGrinder<S: PowStrategy> { /* private fields */ }Expand description
Standalone proof-of-work grinder that can work with any byte challenge.
This structure provides a clean separation between the PoW solving logic and the transcript/sponge operations.
Implementations§
Source§impl<S: PowStrategy> PoWGrinder<S>
impl<S: PowStrategy> PoWGrinder<S>
Sourcepub fn new(challenge: [u8; 32], bits: f64) -> Self
pub fn new(challenge: [u8; 32], bits: f64) -> Self
Creates a new PoW grounder with the given challenge and difficulty.
§Arguments
challenge- A 32-byte challenge arraybits- The difficulty in bits (logarithm of expected work)
Sourcepub fn grind(&mut self) -> Option<PoWSolution>
pub fn grind(&mut self) -> Option<PoWSolution>
Attempts to find a nonce that satisfies the proof-of-work requirement.
Returns the minimal nonce that makes the hash fall below the target threshold, or None if no valid nonce is found (extremely unlikely for reasonable difficulty).
Auto Trait Implementations§
impl<S> Freeze for PoWGrinder<S>where
S: Freeze,
impl<S> RefUnwindSafe for PoWGrinder<S>where
S: RefUnwindSafe,
impl<S> Send for PoWGrinder<S>where
S: Send,
impl<S> Sync for PoWGrinder<S>
impl<S> Unpin for PoWGrinder<S>where
S: Unpin,
impl<S> UnwindSafe for PoWGrinder<S>where
S: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more