pub struct Puzzle<N: Network> { /* private fields */ }
Implementations§
Source§impl<N: Network> Puzzle<N>
impl<N: Network> Puzzle<N>
Sourcepub fn new<P: PuzzleTrait<N> + 'static>() -> Self
pub fn new<P: PuzzleTrait<N> + 'static>() -> Self
Initializes a new puzzle instance.
Sourcepub fn get_leaves(
&self,
solution: &PartialSolution<N>,
) -> Result<Vec<Vec<bool>>>
pub fn get_leaves( &self, solution: &PartialSolution<N>, ) -> Result<Vec<Vec<bool>>>
Returns the Merkle leaves for the puzzle, given the solution.
Sourcepub fn get_all_leaves(
&self,
solutions: &PuzzleSolutions<N>,
) -> Result<Vec<Vec<Vec<bool>>>>
pub fn get_all_leaves( &self, solutions: &PuzzleSolutions<N>, ) -> Result<Vec<Vec<Vec<bool>>>>
Returns each of the Merkle leaves for the puzzle, given the solutions.
Sourcepub fn get_proof_target(&self, solution: &Solution<N>) -> Result<u64>
pub fn get_proof_target(&self, solution: &Solution<N>) -> Result<u64>
Returns the proof target given the solution.
Sourcepub fn get_proof_target_unchecked(&self, solution: &Solution<N>) -> Result<u64>
pub fn get_proof_target_unchecked(&self, solution: &Solution<N>) -> Result<u64>
Returns the proof target given the solution.
Note: This method does not check the proof target against the expected proof target.
Sourcepub fn get_proof_target_from_partial_solution(
&self,
partial_solution: &PartialSolution<N>,
) -> Result<u64>
pub fn get_proof_target_from_partial_solution( &self, partial_solution: &PartialSolution<N>, ) -> Result<u64>
Returns the proof target given the partial solution.
Sourcepub fn get_proof_targets(
&self,
solutions: &PuzzleSolutions<N>,
) -> Result<Vec<u64>>
pub fn get_proof_targets( &self, solutions: &PuzzleSolutions<N>, ) -> Result<Vec<u64>>
Returns the proof targets given the solutions.
Sourcepub fn get_combined_proof_target(
&self,
solutions: &PuzzleSolutions<N>,
) -> Result<u128>
pub fn get_combined_proof_target( &self, solutions: &PuzzleSolutions<N>, ) -> Result<u128>
Returns the combined proof target of the solutions.
Sourcepub fn prove(
&self,
epoch_hash: N::BlockHash,
address: Address<N>,
counter: u64,
minimum_proof_target: Option<u64>,
) -> Result<Solution<N>>
pub fn prove( &self, epoch_hash: N::BlockHash, address: Address<N>, counter: u64, minimum_proof_target: Option<u64>, ) -> Result<Solution<N>>
Returns a solution to the puzzle.
Sourcepub fn check_solution(
&self,
solution: &Solution<N>,
expected_epoch_hash: N::BlockHash,
expected_proof_target: u64,
) -> Result<()>
pub fn check_solution( &self, solution: &Solution<N>, expected_epoch_hash: N::BlockHash, expected_proof_target: u64, ) -> Result<()>
Returns Ok(())
if the solution is valid.
Sourcepub fn check_solution_mut(
&self,
solution: &mut Solution<N>,
expected_epoch_hash: N::BlockHash,
expected_proof_target: u64,
) -> Result<()>
pub fn check_solution_mut( &self, solution: &mut Solution<N>, expected_epoch_hash: N::BlockHash, expected_proof_target: u64, ) -> Result<()>
ATTENTION: This function will update the target if the solution target is different from the calculated one.
Returns Ok(())
if the solution is valid.
Sourcepub fn check_solutions(
&self,
solutions: &PuzzleSolutions<N>,
expected_epoch_hash: N::BlockHash,
expected_proof_target: u64,
) -> Result<()>
pub fn check_solutions( &self, solutions: &PuzzleSolutions<N>, expected_epoch_hash: N::BlockHash, expected_proof_target: u64, ) -> Result<()>
Returns Ok(())
if the solutions are valid.
Trait Implementations§
Auto Trait Implementations§
impl<N> Freeze for Puzzle<N>
impl<N> !RefUnwindSafe for Puzzle<N>
impl<N> Send for Puzzle<N>
impl<N> Sync for Puzzle<N>
impl<N> Unpin for Puzzle<N>
impl<N> !UnwindSafe for Puzzle<N>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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