chfast / ethash

C/C++ implementation of Ethash and ProgPoW – the Ethereum Proof of Work algorithms
Apache License 2.0
142 stars 128 forks source link

Verify against difficulty #195

Closed chfast closed 3 years ago

chfast commented 3 years ago

Add new Ethash verification function verify_against_difficulty() which takes difficulty number directly. Previously only verify_against_boundary() was available which required converting difficulty to boundary (division) by users. The new verify_against_difficulty() performs check hash * difficulty <= 2^256 and division is not needed.

Closes #185.

codecov-commenter commented 3 years ago

Codecov Report

Merging #195 (abbb147) into master (3ba7f6c) will increase coverage by 0.06%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
+ Coverage   98.58%   98.65%   +0.06%     
==========================================
  Files          24       24              
  Lines        1840     1929      +89     
==========================================
+ Hits         1814     1903      +89     
  Misses         26       26              
Flag Coverage Δ
be 53.32% <47.31%> (-0.36%) :arrow_down:
default 99.78% <100.00%> (+0.01%) :arrow_up:
x86_64 90.42% <100.00%> (+0.47%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/ethash/ethash-internal.hpp 100.00% <ø> (ø)
include/ethash/ethash.hpp 100.00% <100.00%> (ø)
lib/ethash/ethash.cpp 100.00% <100.00%> (ø)
test/unittests/test_difficulty.cpp 100.00% <100.00%> (ø)
test/unittests/test_ethash.cpp 94.71% <100.00%> (+0.22%) :arrow_up: