This commit is contained in:
Jay D Dee
2016-11-28 12:59:56 -05:00
parent c551fb4a25
commit 06f82c5b97
10 changed files with 58 additions and 1297 deletions

View File

@@ -8,7 +8,8 @@ void zcoin_hash(void *state, const void *input, uint32_t height)
uint32_t _ALIGN(256) hash[16];
LYRA2Z(hash, 32, input, 80, input, 80, 2, height, 256);
// LYRA2Z(hash, 32, input, 80, input, 80, 2, height, 256);
LYRA2Z(hash, 32, input, 80, input, 80, 2, 8192, 256);
memcpy(state, hash, 32);
}

View File

@@ -1056,7 +1056,6 @@ int scanhash_neoscrypt( int thr_id, struct work *work,
while (pdata[19] < max_nonce && !work_restart[thr_id].restart)
{
neoscrypt((uint8_t *) hash, (uint8_t *) pdata );
// , 0x80000020 | (opt_nfactor << 8) );
/* Quick hash check */
if (hash[7] <= Htarg && fulltest_le(hash, ptarget)) {
@@ -1071,15 +1070,7 @@ int scanhash_neoscrypt( int thr_id, struct work *work,
return 0;
}
int64_t get_neoscrypt_max64()
{
int64_t max64 = opt_scrypt_n < 16 ? 0x3ffff : 0x3fffff / opt_scrypt_n;
if ( opt_nfactor > 3)
max64 >>= ( opt_nfactor - 3);
else if ( opt_nfactor > 16)
max64 = 0xF;
return max64;
}
int64_t get_neoscrypt_max64() { return 0x3ffff; }
void neoscrypt_wait_for_diff( struct stratum_ctx *stratum )
{

File diff suppressed because it is too large Load Diff

View File

@@ -48,6 +48,7 @@ static const uint32_t finalblk[16] = {
};
static __thread char *scratchbuf;
int scratchbuf_size = 0;
static inline void HMAC_SHA256_80_init(const uint32_t *key,
uint32_t *tstate, uint32_t *ostate)
@@ -726,29 +727,29 @@ extern int scanhash_scrypt( int thr_id, struct work *work, uint32_t max_nonce,
#if defined(HAVE_SHA256_4WAY)
if (throughput == 4)
scrypt_1024_1_1_256_4way(data, hash, midstate,
scratchbuf, opt_scrypt_n);
scratchbuf, scratchbuf_size );
else
#endif
#if defined(HAVE_SCRYPT_3WAY) && defined(HAVE_SHA256_4WAY)
if (throughput == 12)
scrypt_1024_1_1_256_12way(data, hash, midstate,
scratchbuf, opt_scrypt_n);
scratchbuf, scratchbuf_size );
else
#endif
#if defined(HAVE_SCRYPT_6WAY)
if (throughput == 24)
scrypt_1024_1_1_256_24way(data, hash, midstate,
scratchbuf, opt_scrypt_n);
scratchbuf, scratchbuf_size );
else
#endif
#if defined(HAVE_SCRYPT_3WAY)
if (throughput == 3)
scrypt_1024_1_1_256_3way(data, hash, midstate,
scratchbuf, opt_scrypt_n);
scratchbuf, scratchbuf_size );
else
#endif
scrypt_1024_1_1_256(data, hash, midstate, scratchbuf,
opt_scrypt_n);
scratchbuf_size );
for (i = 0; i < throughput; i++) {
if (unlikely(hash[i * 8 + 7] <= Htarg && fulltest(hash + i * 8, ptarget))) {
@@ -764,19 +765,11 @@ extern int scanhash_scrypt( int thr_id, struct work *work, uint32_t max_nonce,
return 0;
}
int64_t scrypt_get_max64()
{
int64_t max64 = opt_scrypt_n < 16 ? 0x3ffff : 0x3fffff / opt_scrypt_n;
if ( opt_nfactor > 3)
max64 >>= ( opt_nfactor - 3);
else if ( opt_nfactor > 16)
max64 = 0xF;
return max64;
}
int64_t scrypt_get_max64() { return 0xfff; }
bool scrypt_miner_thread_init( int thr_id )
{
scratchbuf = scrypt_buffer_alloc( opt_scrypt_n );
scratchbuf = scrypt_buffer_alloc( scratchbuf_size );
if ( scratchbuf )
return true;
applog( LOG_ERR, "Thread %u: Scrypt buffer allocation failed", thr_id );
@@ -791,8 +784,10 @@ bool register_scrypt_algo( algo_gate_t* gate )
gate->hash_alt = (void*)&scrypt_1024_1_1_256_24way;
gate->set_target = (void*)&scrypt_set_target;
gate->get_max64 = (void*)&scrypt_get_max64;
if ( opt_nfactor == 0 )
opt_nfactor = 6;
return true;
if ( !opt_scrypt_n )
scratchbuf_size = 1024;
else
scratchbuf_size = opt_scrypt_n;
};

View File

@@ -45,6 +45,8 @@
#define scrypt_maxr scrypt_r_32kb /* 32kb */
#define scrypt_maxp 25 /* (1 << 25) = ~33 million */
uint64_t sj_N;
typedef struct scrypt_aligned_alloc_t {
uint8_t *mem, *ptr;
} scrypt_aligned_alloc;
@@ -140,7 +142,8 @@ int scanhash_scryptjane( int thr_id, struct work *work, uint32_t max_nonce,
{
scrypt_aligned_alloc YX, V;
uint8_t *X, *Y;
uint32_t N, chunk_bytes;
// uint32_t N, chunk_bytes;
uint32_t chunk_bytes;
const uint32_t r = SCRYPT_R;
const uint32_t p = SCRYPT_P;
@@ -162,10 +165,14 @@ int scanhash_scryptjane( int thr_id, struct work *work, uint32_t max_nonce,
// //scrypt_fatal_error("scrypt: N out of range");
//}
N = (1 << ( opt_scrypt_n + 1));
// opt_scrypt_n default is 1024 which makes no sense in this context
// and results in N = 2, but it seems to work on Nicehash scryptjanenf16
// (leocoin). Need to test with proper NF 16 for functionality and performance.
// Also test yacoin (NF 18).
// N = (1 << ( opt_scrypt_n + 1));
chunk_bytes = SCRYPT_BLOCK_BYTES * r * 2;
if (!scrypt_alloc((uint64_t)N * chunk_bytes, &V)) return 1;
if (!scrypt_alloc( sj_N * chunk_bytes, &V ) ) return 1;
if (!scrypt_alloc((p + 1) * chunk_bytes, &YX)) {
scrypt_free(&V);
return 1;
@@ -181,7 +188,7 @@ int scanhash_scryptjane( int thr_id, struct work *work, uint32_t max_nonce,
scrypt_N_1_1((unsigned char *)endiandata, 80,
(unsigned char *)endiandata, 80,
N, (unsigned char *)hash, 32, X, Y, V.ptr);
sj_N, (unsigned char *)hash, 32, X, Y, V.ptr);
if (hash[7] <= Htarg && fulltest(hash, ptarget)) {
pdata[19] = nonce;
@@ -208,14 +215,13 @@ void scryptjanehash(void *output, const void *input )
scrypt_aligned_alloc YX, V;
uint8_t *X, *Y;
uint32_t chunk_bytes;
uint32_t N = (1 << ( opt_scrypt_n + 1));
const uint32_t r = SCRYPT_R;
const uint32_t p = SCRYPT_P;
memset(output, 0, 32);
chunk_bytes = SCRYPT_BLOCK_BYTES * r * 2;
if (!scrypt_alloc((uint64_t)N * chunk_bytes, &V)) return;
if (!scrypt_alloc( sj_N * chunk_bytes, &V ) ) return;
if (!scrypt_alloc((p + 1) * chunk_bytes, &YX)) {
scrypt_free(&V);
return;
@@ -225,7 +231,7 @@ void scryptjanehash(void *output, const void *input )
X = Y + chunk_bytes;
scrypt_N_1_1((unsigned char*)input, 80, (unsigned char*)input, 80,
N, (unsigned char*)output, 32, X, Y, V.ptr);
sj_N, (unsigned char*)output, 32, X, Y, V.ptr);
scrypt_free(&V);
scrypt_free(&YX);
@@ -238,8 +244,23 @@ bool register_scryptjane_algo( algo_gate_t* gate )
gate->hash_alt = (void*)&scryptjanehash;
gate->set_target = (void*)&scrypt_set_target;
gate->get_max64 = (void*)&get_max64_0x40LL;
if ( opt_nfactor == 0 )
opt_nfactor = 16;
// figure out if arg in N or Nfactor
if ( !opt_scrypt_n )
{
applog( LOG_ERR, "The N factor must be specified in the form algo:nf");
return false;
}
else if ( opt_scrypt_n < 32 )
{
// arg is Nfactor, calculate N
sj_N = 1 << ( opt_scrypt_n + 1 );
}
else
{
// arg is N
sj_N = opt_scrypt_n;
}
return true;
}