Skip to content

Commit

Permalink
compatibility with stratum servers fixing 17 nonce bytes (eg. nicehash)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbevand committed Nov 7, 2016
1 parent ebfbffd commit 0d371a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Current tip

* Add nicehash compatibility (stratum servers fixing 17 bytes of the nonce)
* Add nerdralph's optimization (OPTIM_FOR_FGLRX)
* Drop the libsodium dependency; instead use our own SHA256 implementation
* Only apply set_target to *next* mining job
Expand Down
8 changes: 6 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,12 @@ uint32_t solve_equihash(cl_context ctx, cl_command_queue queue,
memset(nonce_ptr, 0, ZCASH_NONCE_LEN);
// add the nonce
if (mining)
// increment bytes 16-19
*(uint32_t *)((uint8_t *)nonce_ptr + 16) += nonce;
{
// increment bytes 17-19
*(uint32_t *)((uint8_t *)nonce_ptr + 17) += nonce;
// byte 20 and above must be zero
*(uint32_t *)((uint8_t *)nonce_ptr + 20) = 0;
}
else
*nonce_ptr += nonce;
debug("\nSolving nonce %s\n", s_hexdump(nonce_ptr, ZCASH_NONCE_LEN));
Expand Down
6 changes: 3 additions & 3 deletions silentarmy
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ class Silentarmy:
self.nonce_leftpart = bytes.fromhex(n)
l = len(self.nonce_leftpart)
very_verbose('Stratum server fixes %d bytes of the nonce' % l)
if l > 16:
# SILENTARMY requires the last 12 bytes to be zero, then 4 bytes
# to vary the nonce, this leaves at most 16 bytes that can be
if l > 17:
# SILENTARMY requires the last 12 bytes to be zero, then 3 bytes
# to vary the nonce, this leaves at most 17 bytes that can be
# fixed by the server.
fatal('Stratum: SILENTARMY is not compatible with servers ' +
'fixing the first %d bytes of the nonce' % l)
Expand Down

0 comments on commit 0d371a9

Please sign in to comment.