pub struct EquiX {
pub(crate) hash: HashX,
}
Expand description
One Equi-X instance, customized for a challenge string
This includes pre-computed state that depends on the
puzzle’s challenge as well as any options set via EquiXBuilder
.
Fields§
§hash: HashX
HashX instance generated for this puzzle’s challenge string
Implementations§
Source§impl EquiX
impl EquiX
Sourcepub fn new(challenge: &[u8]) -> Result<Self, Error>
pub fn new(challenge: &[u8]) -> Result<Self, Error>
Make a new EquiX
instance with a challenge string and
default options.
It’s normal for this to fail with a HashError::ProgramConstraints
for a small fraction of challenge values. Those challenges must be
skipped by solvers and rejected by verifiers.
Sourcepub fn runtime(&self) -> Runtime
pub fn runtime(&self) -> Runtime
Check which actual program runtime is in effect.
By default we try to generate machine code at runtime to accelerate the
hash function, but we fall back to an interpreter if this fails. The
compiler can be disabled entirely using RuntimeOption::InterpretOnly
and EquiXBuilder
.
Sourcepub fn verify(&self, solution: &Solution) -> Result<(), Error>
pub fn verify(&self, solution: &Solution) -> Result<(), Error>
Check a Solution
against this particular challenge.
Having a Solution
instance guarantees that the order of items
has already been checked. This only needs to check hash tree sums.
Returns either Ok
or Error::HashSum
.
Sourcepub fn solve(&self) -> SolutionArray
pub fn solve(&self) -> SolutionArray
Search for solutions using this particular challenge.
Returns a buffer with a variable number of solutions. Memory for the solver is allocated dynamically and not reused.
Sourcepub fn solve_with_memory(&self, mem: &mut SolverMemory) -> SolutionArray
pub fn solve_with_memory(&self, mem: &mut SolverMemory) -> SolutionArray
Search for solutions, using the provided SolverMemory
.
Returns a buffer with a variable number of solutions.
Allows reuse of solver memory. Preferred for callers which may perform several solve operations in rapid succession, such as in the common case of layering an effort adjustment protocol above Equi-X.