Skip to content

Commit

Permalink
Tweaks to make ztex work on a tp-link router with openwrt
Browse files Browse the repository at this point in the history
  • Loading branch information
nelisky committed Apr 16, 2012
1 parent a960087 commit 608a520
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cgminer.c
Expand Up @@ -1528,13 +1528,16 @@ static bool submit_upstream_work(const struct work *work)
res = json_object_get(val, "result");

if (!QUIET) {
#ifndef MIPSEB
// This one segfaults on my router for some reason
isblock = regeneratehash(work);
if (isblock)
found_blocks++;
hash32 = (uint32_t *)(work->hash);
sprintf(hashshow, "%08lx.%08lx.%08lx%s",
(unsigned long)(hash32[7]), (unsigned long)(hash32[6]), (unsigned long)(hash32[5]),
isblock ? " BLOCK!" : "");
#endif
}

/* Theoretically threads could race when modifying accepted and
Expand Down
16 changes: 12 additions & 4 deletions ztex.c
Expand Up @@ -124,7 +124,12 @@ static bool ztex_checkNonce (struct libztex_device *ztex,
unsigned char hash2[32];
uint32_t *hash2_32 = (uint32_t *)hash2;
int i;


#if defined(__BIGENDIAN__) || defined(MIPSEB)
hdata->nonce = swab32(hdata->nonce);
hdata->hash7 = swab32(hdata->hash7);
#endif

work->data[64 + 12 + 0] = (hdata->nonce >> 0) & 0xff;
work->data[64 + 12 + 1] = (hdata->nonce >> 8) & 0xff;
work->data[64 + 12 + 2] = (hdata->nonce >> 16) & 0xff;
Expand All @@ -135,8 +140,11 @@ static bool ztex_checkNonce (struct libztex_device *ztex,

sha2(swap, 80, hash1, false);
sha2(hash1, 32, hash2, false);

#if defined(__BIGENDIAN__) || defined(MIPSEB)
if (hash2_32[7] != ((hdata->hash7 + 0x5be0cd19) & 0xFFFFFFFF)) {
#else
if (swab32(hash2_32[7]) != ((hdata->hash7 + 0x5be0cd19) & 0xFFFFFFFF)) {
#endif
ztex->errorCount[ztex->freqM] += 1.0/ztex->numNonces;
applog(LOG_DEBUG, "%s: checkNonce failed for %0.8X", ztex->repr, hdata->nonce);
return false;
Expand Down Expand Up @@ -207,7 +215,7 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
ztex->errorWeight[ztex->freqM] = ztex->errorWeight[ztex->freqM] * 0.995 + 1.0;

for (i=0; i<ztex->numNonces; i++) {
nonce = hdata[i].nonce;
nonce = swab32(hdata[i].nonce);
if (nonce > noncecnt)
noncecnt = nonce;
if ((nonce >> 4) < (lastnonce[i] >> 4)) {
Expand All @@ -234,7 +242,7 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
if (backlog_p >= GOLDEN_BACKLOG) {
backlog_p = 0;
}
#ifdef __BIG_ENDIAN__
#if defined(__BIGENDIAN__) || defined(MIPSEB)
nonce = swab32(nonce);
#endif
work->blk.nonce = 0xffffffff;
Expand Down

0 comments on commit 608a520

Please sign in to comment.