auto is_less_or_equal_by_than(F f, const X& x) { return [f, x](const auto& y) { internal:: trigger_static_asserts<internal::unary_function_tag, F, decltype(y)>(); return is_less_or_equal(internal::invoke(f, y), x); }; }
bool verify(const epoch_context& context, const hash256& header_hash, const hash256& mix_hash, uint64_t nonce, const hash256& boundary) noexcept { const hash512 seed = hash_seed(header_hash, nonce); if (!is_less_or_equal(hash_final(seed, mix_hash), boundary)) return false; const hash256 expected_mix_hash = hash_kernel(context, seed, calculate_dataset_item); return std::memcmp(expected_mix_hash.bytes, mix_hash.bytes, sizeof(mix_hash)) == 0; }
auto is_less_or_equal_by_and_by(F f, G g) { return [f, g](const auto& x, const auto& y) { using FIn = decltype(x); using GIn = decltype(y); internal::check_compare_preprocessors_for_types<F, G, FIn, GIn>(); return is_less_or_equal(internal::invoke(f, x), internal::invoke(g, y)); }; }
uint64_t search(const epoch_context_full& context, const hash256& header_hash, const hash256& boundary, uint64_t start_nonce, size_t iterations) noexcept { const uint64_t end_nonce = start_nonce + iterations; for (uint64_t nonce = start_nonce; nonce < end_nonce; ++nonce) { result r = hash(context, header_hash, nonce); if (is_less_or_equal(r.final_hash, boundary)) return nonce; } return 0; }
bool verify_final_hash(const hash256& header_hash, const hash256& mix_hash, uint64_t nonce, const hash256& boundary) noexcept { const hash512 seed = hash_seed(header_hash, nonce); return is_less_or_equal(hash_final(seed, mix_hash), boundary); }