| 83 | } |
| 84 | |
| 85 | static void grind_task(uint32_t nBits, CBlockHeader& header_orig, uint32_t offset, uint32_t step, std::atomic<bool>& found) |
| 86 | { |
| 87 | arith_uint256 target; |
| 88 | bool neg, over; |
| 89 | target.SetCompact(nBits, &neg, &over); |
| 90 | if (target == 0 || neg || over) return; |
| 91 | CBlockHeader header = header_orig; // working copy |
| 92 | header.nNonce = offset; |
| 93 | |
| 94 | uint32_t finish = std::numeric_limits<uint32_t>::max() - step; |
| 95 | finish = finish - (finish % step) + offset; |
| 96 | |
| 97 | while (!found && header.nNonce < finish) { |
| 98 | const uint32_t next = (finish - header.nNonce < 5000*step) ? finish : header.nNonce + 5000*step; |
| 99 | do { |
| 100 | if (UintToArith256(header.GetHash()) <= target) { |
| 101 | if (!found.exchange(true)) { |
| 102 | header_orig.nNonce = header.nNonce; |
| 103 | } |
| 104 | return; |
| 105 | } |
| 106 | header.nNonce += step; |
| 107 | } while(header.nNonce != next); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | static int Grind(const std::vector<std::string>& args, std::string& strPrint) |
| 112 | { |
nothing calls this directly
no test coverage detected