int scanhash_x14(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) { uint32_t _ALIGN(128) hash32[8]; uint32_t _ALIGN(128) endiandata[20]; uint32_t *pdata = work->data; uint32_t *ptarget = work->target; uint32_t n = pdata[19] - 1; const uint32_t first_nonce = pdata[19]; const uint32_t Htarg = ptarget[7]; uint64_t htmax[] = { 0, 0xF, 0xFF, 0xFFF, 0xFFFF, 0x10000000 }; uint32_t masks[] = { 0xFFFFFFFF, 0xFFFFFFF0, 0xFFFFFF00, 0xFFFFF000, 0xFFFF0000, 0 }; // we need bigendian data... for (int k=0; k < 19; k++) be32enc(&endiandata[k], pdata[k]); #ifdef DEBUG_ALGO if (Htarg != 0) printf("[%d] Htarg=%X\n", thr_id, Htarg); #endif for (int m=0; m < 6; m++) { if (Htarg <= htmax[m]) { uint32_t mask = masks[m]; do { pdata[19] = ++n; be32enc(&endiandata[19], n); x14hash(hash32, endiandata); #ifndef DEBUG_ALGO if ((!(hash32[7] & mask)) && fulltest(hash32, ptarget)) { work_set_target_ratio(work, hash32); *hashes_done = n - first_nonce + 1; return true; } #else if (!(n % 0x1000) && !thr_id) printf("."); if (!(hash32[7] & mask)) { printf("[%d]",thr_id); if (fulltest(hash32, ptarget)) { work_set_target_ratio(work, hash32); *hashes_done = n - first_nonce + 1; return true; } } #endif } while (n < max_nonce && !work_restart[thr_id].restart); // see blake.c if else to understand the loop on htmax => mask break; } } *hashes_done = n - first_nonce + 1; pdata[19] = n; return 0; }
int scanhash_x14(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) { uint32_t *pdata = work->data; uint32_t *ptarget = work->target; uint32_t n = pdata[19] - 1; const uint32_t first_nonce = pdata[19]; const uint32_t Htarg = ptarget[7]; uint32_t _ALIGN(32) hash64[8]; uint32_t endiandata[32]; uint64_t htmax[] = { 0, 0xF, 0xFF, 0xFFF, 0xFFFF, 0x10000000 }; uint32_t masks[] = { 0xFFFFFFFF, 0xFFFFFFF0, 0xFFFFFF00, 0xFFFFF000, 0xFFFF0000, 0 }; // init_x14_ctx(); // we need bigendian data... be32enc( &endiandata[0], ((uint32_t*)pdata)[0] ); be32enc( &endiandata[1], ((uint32_t*)pdata)[1] ); be32enc( &endiandata[2], ((uint32_t*)pdata)[2] ); be32enc( &endiandata[3], ((uint32_t*)pdata)[3] ); be32enc( &endiandata[4], ((uint32_t*)pdata)[4] ); be32enc( &endiandata[5], ((uint32_t*)pdata)[5] ); be32enc( &endiandata[6], ((uint32_t*)pdata)[6] ); be32enc( &endiandata[7], ((uint32_t*)pdata)[7] ); be32enc( &endiandata[8], ((uint32_t*)pdata)[8] ); be32enc( &endiandata[9], ((uint32_t*)pdata)[9] ); be32enc( &endiandata[10], ((uint32_t*)pdata)[10] ); be32enc( &endiandata[11], ((uint32_t*)pdata)[11] ); be32enc( &endiandata[12], ((uint32_t*)pdata)[12] ); be32enc( &endiandata[13], ((uint32_t*)pdata)[13] ); be32enc( &endiandata[14], ((uint32_t*)pdata)[14] ); be32enc( &endiandata[15], ((uint32_t*)pdata)[15] ); be32enc( &endiandata[16], ((uint32_t*)pdata)[16] ); be32enc( &endiandata[17], ((uint32_t*)pdata)[17] ); be32enc( &endiandata[18], ((uint32_t*)pdata)[18] ); be32enc( &endiandata[19], ((uint32_t*)pdata)[19] ); be32enc( &endiandata[20], ((uint32_t*)pdata)[20] ); be32enc( &endiandata[21], ((uint32_t*)pdata)[21] ); be32enc( &endiandata[22], ((uint32_t*)pdata)[22] ); be32enc( &endiandata[23], ((uint32_t*)pdata)[23] ); be32enc( &endiandata[24], ((uint32_t*)pdata)[24] ); be32enc( &endiandata[25], ((uint32_t*)pdata)[25] ); be32enc( &endiandata[26], ((uint32_t*)pdata)[26] ); be32enc( &endiandata[27], ((uint32_t*)pdata)[27] ); be32enc( &endiandata[28], ((uint32_t*)pdata)[28] ); be32enc( &endiandata[29], ((uint32_t*)pdata)[29] ); be32enc( &endiandata[30], ((uint32_t*)pdata)[30] ); be32enc( &endiandata[31], ((uint32_t*)pdata)[31] ); // for (int kk=0; kk < 32; kk++) { // be32enc(&endiandata[kk], ((uint32_t*)pdata)[kk]); // }; #ifdef DEBUG_ALGO if (Htarg != 0) printf("[%d] Htarg=%X\n", thr_id, Htarg); #endif for (int m=0; m < 6; m++) { if (Htarg <= htmax[m]) { uint32_t mask = masks[m]; do { pdata[19] = ++n; be32enc(&endiandata[19], n); x14hash(hash64, endiandata); #ifndef DEBUG_ALGO if ((!(hash64[7] & mask)) && fulltest(hash64, ptarget)) { *hashes_done = n - first_nonce + 1; return true; } #else if (!(n % 0x1000) && !thr_id) printf("."); if (!(hash64[7] & mask)) { printf("[%d]",thr_id); if (fulltest(hash64, ptarget)) { *hashes_done = n - first_nonce + 1; return true; } } #endif } while (n < max_nonce && !work_restart[thr_id].restart); // see blake.c if else to understand the loop on htmax => mask break; } } *hashes_done = n - first_nonce + 1; pdata[19] = n; return 0; }